#define DT_UNKNOWN 0 #define DT_FIFO 1 #define DT_CHR 2 #define DT_DIR 4 #define DT_BLK 6 #define DT_REG 8 #define DT_LNK 10 #define DT_SOCK 12 #define DT_WHT 14 struct dirent { uint64_t d_ino; uint64_t d_off; uint16_t d_reclen; uint8_t d_type; // One of the DT_ values. char d_name[61]; // Null-terminated. }; ssize_t getdents(int fd, struct dirent *buffer, size_t size);
This syscall reads the contents of the passed directory, and advances the file position for the directory by the amount of read directory entries. Partial reads are supported.
The syscalls return the read length in bytes on success, or 0
if no
contents or -1
on failure, with the following errno:
EFAULT
: Incorrect addresses for the arguments.
EBADFD
: fd
does not contain a valid file.
ENOENT
: fd
is not a directory.
EINVAL
: size
is not big enough to fit all the directory entries.