feat(dirent): directory iteration

This commit is contained in:
2026-09-05 21:08:57 -04:00
parent a2f7c33601
commit 5af4197ee9
14 changed files with 1139 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <dirent.h>
#include <unistd.h>
#include "../internal/syscall.h"
#include "dirent_impl.h"
/*
* rewinddir (todo 24): return the stream to the start of the directory.
* SYS_lseek back to offset 0 resets the kernel's per-fd directory
* position; the cached records (if any) are dropped and the stored seek
* cookie is reset, so the next readdir refills from the first entry.
* rewinddir has no error return; a failed lseek leaves the stream
* positioned wherever the kernel is.
*/
void
rewinddir(DIR *dir)
{
struct vlibc_DIR *d = dir;
syscall_ret(__syscall3(SYS_lseek, d->fd, 0, SEEK_SET));
d->buf_pos = 0;
d->buf_end = 0;
d->de.d_off = 0;
}