diff options
Diffstat (limited to 'userland/libc/dirent/readdir.c')
-rw-r--r-- | userland/libc/dirent/readdir.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/userland/libc/dirent/readdir.c b/userland/libc/dirent/readdir.c index a7f0d66..3e1460c 100644 --- a/userland/libc/dirent/readdir.c +++ b/userland/libc/dirent/readdir.c @@ -1,30 +1,27 @@ #include <dirent.h> +#include <stdio.h> #include <unistd.h> int readdir_multi(DIR *dir, struct dirent *entries, int num_entries) { - size_t offset = dir->dir_num * sizeof(struct dirent); int rc; - if (-1 == (rc = pread(dir->fd, entries, num_entries * sizeof(struct dirent), - offset))) { + if (-1 == + (rc = read(dir->fd, entries, num_entries * sizeof(struct dirent)))) { return -1; } int num_read_entries = rc / sizeof(struct dirent); - dir->dir_num += num_read_entries; return num_read_entries; } struct dirent *readdir(DIR *dir) { - size_t offset = dir->dir_num * sizeof(struct dirent); int rc; - if (-1 == (rc = pread(dir->fd, &dir->internal_direntry, sizeof(struct dirent), - offset))) { + if (-1 == + (rc = read(dir->fd, &dir->internal_direntry, sizeof(struct dirent)))) { return NULL; } if (rc < (int)sizeof(struct dirent)) { return NULL; } - dir->dir_num++; return &(dir->internal_direntry); } |