reading directories: opendir, readdir, closedir.
More...
Go to the source code of this file.
|
| typedef struct dir_stream | DIR |
|
| DIR * | opendir (const char *path) |
| | open a directory for reading.
|
| DIR * | fdopendir (int fd) |
| | a directory stream on an open directory (closedir closes fd)
|
| struct dirent * | readdir (DIR *dir) |
| | read the next entry.
|
| int | closedir (DIR *dir) |
| | close a directory stream and its file descriptor.
|
| int | dirfd (DIR *dir) |
| | the file descriptor under a directory stream.
|
| int | getdents (int fd, void *buf, unsigned int size) |
| | read raw getdents records (the syscall under readdir).
|
reading directories: opendir, readdir, closedir.
built on the getdents syscall, whose record layout and DT_ values are ABI (src/kernel/vfs/dirent.h).
◆ DT_UNKNOWN
◆ DT_FIFO
◆ DT_CHR
◆ DT_DIR
◆ DT_BLK
◆ DT_REG
◆ DT_LNK
◆ DT_SOCK
◆ DIR
| typedef struct dir_stream DIR |
◆ opendir()
| DIR * opendir |
( |
const char * | path | ) |
|
open a directory for reading.
- Returns
- the stream, or NULL (errno set).
◆ fdopendir()
| DIR * fdopendir |
( |
int | fd | ) |
|
a directory stream on an open directory (closedir closes fd)
◆ readdir()
read the next entry.
the returned struct is overwritten by the next call.
- Returns
- the entry, or NULL at the end of the directory or on error.
◆ closedir()
| int closedir |
( |
DIR * | dir | ) |
|
close a directory stream and its file descriptor.
- Returns
- 0, or -1 (errno set).
◆ dirfd()
the file descriptor under a directory stream.
◆ getdents()
| int getdents |
( |
int | fd, |
|
|
void * | buf, |
|
|
unsigned int | size ) |
read raw getdents records (the syscall under readdir).
- Returns
- bytes read, 0 at the end, or -1 (errno set).