From f8cbad7b3e292ac38446d683501874266476c5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 14 Sep 2004 23:10:29 +0000 Subject: [PATCH] Implemented readdir_r(). Added note to dirfd() that it should be excluded from the kernel build once the build system allows this. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8958 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/dirent.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/kernel/libroot/posix/dirent.c b/src/kernel/libroot/posix/dirent.c index 457d2c9301..dab57a56fc 100644 --- a/src/kernel/libroot/posix/dirent.c +++ b/src/kernel/libroot/posix/dirent.c @@ -76,6 +76,23 @@ readdir(DIR *dir) } +int +readdir_r(DIR *dir, struct dirent *entry, struct dirent **_result) +{ + ssize_t count = _kern_read_dir(dir->fd, entry, sizeof(struct dirent) + B_FILE_NAME_LENGTH, 1); + if (count < B_OK) + return count; + + if (count == 0) { + // end of directory + *_result = NULL; + } else + *_result = entry; + + return 0; +} + + void rewinddir(DIR *dir) { @@ -89,6 +106,7 @@ rewinddir(DIR *dir) * but here for BeOS compatiblity. */ +// ToDo: disable this for the kernel build! (will be possible once we use Kernel build rules for the kernel only) int dirfd(DIR *dir);