search for: __klibc_dirent_internals

Displaying 1 result from an estimated 1 matches for "__klibc_dirent_internals".

2011 Aug 10
1
[PATCH v2] dirent.h add fdopendir()
...a/usr/klibc/fdopendir.c b/usr/klibc/fdopendir.c new file mode 100644 index 0000000..e22cba8 --- /dev/null +++ b/usr/klibc/fdopendir.c @@ -0,0 +1,40 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdlib.h> +#include <errno.h> + +#define __KLIBC_DIRENT_INTERNALS +#include <dirent.h> + +DIR *fdopendir(int fd) +{ + DIR *dp; + int flags; + struct stat st; + + if (fstat(fd, &st)) + return NULL; + if (!S_ISDIR(st.st_mode)) { + errno = ENOTDIR; + return NULL; + } + + flags = fcntl(fd, F_GETFL); + if (flags == -1) + return NULL; + if ((flags & O...