From 5edee471f3e45d962c6112e29ceaeadd1d3e902b Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Fri, 28 Nov 2014 16:47:12 +0900 Subject: [PATCH] fdopendir: port to OS/2 kLIBC * lib/fdopendir.c (fdopendir): Implement on OS/2 kLIBC. --- lib/fdopendir.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/fdopendir.c b/lib/fdopendir.c index b6c94a0..6c1e55f 100644 --- a/lib/fdopendir.c +++ b/lib/fdopendir.c @@ -62,6 +62,23 @@ static DIR *fd_clone_opendir (int, struct saved_cwd const *); If this function returns successfully, FD is under control of the dirent.h system, and the caller should not close or modify the state of FD other than by the dirent.h functions. */ +# ifdef __KLIBC__ +# include + +DIR * +fdopendir (int fd) +{ + char path[_MAX_PATH]; + + /* Get a path from fd */ + if (__libc_Back_ioFHToPath (fd, path, sizeof (path))) + return NULL; + + /* FIXME: close() fd explicitly after closedir(), or fd leaks */ + + return opendir (path); +} +# else DIR * fdopendir (int fd) { @@ -84,6 +101,7 @@ fdopendir (int fd) return dir; } +# endif /* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known to be a dup of FD which is less than FD - 1 and which will be -- 1.8.5.2