Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: fusl/src/dirent/readdir.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/dirent/opendir.c ('k') | fusl/src/dirent/readdir_r.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/dirent/readdir.c
diff --git a/fusl/src/dirent/readdir.c b/fusl/src/dirent/readdir.c
new file mode 100644
index 0000000000000000000000000000000000000000..2cf0632c207ef2547d6dfe8b67ed23783cf151d4
--- /dev/null
+++ b/fusl/src/dirent/readdir.c
@@ -0,0 +1,28 @@
+#include <dirent.h>
+#include <errno.h>
+#include "__dirent.h"
+#include "syscall.h"
+#include "libc.h"
+
+int __getdents(int, struct dirent *, size_t);
+
+struct dirent *readdir(DIR *dir)
+{
+ struct dirent *de;
+
+ if (dir->buf_pos >= dir->buf_end) {
+ int len = __syscall(SYS_getdents, dir->fd, dir->buf, sizeof dir->buf);
+ if (len <= 0) {
+ if (len < 0 && len != -ENOENT) errno = -len;
+ return 0;
+ }
+ dir->buf_end = len;
+ dir->buf_pos = 0;
+ }
+ de = (void *)(dir->buf + dir->buf_pos);
+ dir->buf_pos += de->d_reclen;
+ dir->tell = de->d_off;
+ return de;
+}
+
+LFS64(readdir);
« no previous file with comments | « fusl/src/dirent/opendir.c ('k') | fusl/src/dirent/readdir_r.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698