Skip to content

Commit a7ea6d6

Browse files
committed
Handle seekdir as well
1 parent dc9d077 commit a7ea6d6

File tree

1 file changed

+11
-1
lines changed
  • libc-bottom-half/cloudlibc/src/libc/dirent

1 file changed

+11
-1
lines changed

libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int ensure_has_directory_stream(DIR *dirp, filesystem_borrow_descriptor_t
7070
return 0;
7171
}
7272

73-
struct dirent *readdir(DIR *dirp) {
73+
static struct dirent *readdir_next(DIR *dirp) {
7474
filesystem_metadata_hash_value_t metadata;
7575
filesystem_error_code_t error_code;
7676
filesystem_borrow_descriptor_t dir_handle;
@@ -152,6 +152,16 @@ struct dirent *readdir(DIR *dirp) {
152152

153153
return dirp->dirent;
154154
}
155+
156+
struct dirent *readdir(DIR *dirp) {
157+
struct dirent *result = readdir_next(dirp);
158+
while (result != NULL && dirp->skip > 0) {
159+
dirp->skip -= 1;
160+
result = readdir_next(dirp);
161+
}
162+
return result;
163+
}
164+
155165
#else
156166
struct dirent *readdir(DIR *dirp) {
157167
for (;;) {

0 commit comments

Comments
 (0)