diff options
-rw-r--r-- | include/dirent.h | 1 | ||||
-rw-r--r-- | userland/libc/dirent/opendir.c | 2 | ||||
-rw-r--r-- | userland/libc/dirent/readdir.c | 13 |
3 files changed, 5 insertions, 11 deletions
diff --git a/include/dirent.h b/include/dirent.h index 66e8e8f..be9c928 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -17,7 +17,6 @@ struct dirent { typedef struct { int fd; struct dirent internal_direntry; - int dir_num; } DIR; #ifndef KERNEL diff --git a/userland/libc/dirent/opendir.c b/userland/libc/dirent/opendir.c index efe8b6d..8f5d818 100644 --- a/userland/libc/dirent/opendir.c +++ b/userland/libc/dirent/opendir.c @@ -6,7 +6,6 @@ DIR *fdopendir(int fd) { return NULL; } rc->fd = fd; - rc->dir_num = 0; return rc; } @@ -20,6 +19,5 @@ DIR *opendir(const char *dirname) { return NULL; } rc->fd = fd; - rc->dir_num = 0; return rc; } 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); } |