Files
vlibc/src/dirent/rewinddir.c
T

30 lines
727 B
C

#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;
}