内容简介
#include <linux/types.h> #include <linux/dirent.h> int readdir(unsigned int fd, struct dirent *dirp, unsigned int count) |
描述
This is not the function you are interested in. Look at%uA0readdir(3) for the POSIX conforming C library interface. This page documents the bare kernel system call interface, which can change, and which is superseded by%uA0getdents(2).readdir() reads one%uA0dirent%uA0structure from the directory pointed at by%uA0fd%uA0into the memory area pointed to by%uA0dirp. The parameter%uA0count%uA0is ignored at most one dirent structure is read.
The%uA0dirent%uA0structure is declared as follows:
struct dirent { long d_ino /* inode number */ off_t d_off /* offset to this dirent */ unsigned short d_reclen /* length of this d_name */ char d_name [NAME_MAX+1] /* filename (null-terminated) */ } |
d_ino%uA0is an inode number.%uA0d_off%uA0is the distance from the start of the directory to thisdirent.%uA0d_reclen%uA0is the size of%uA0d_name, not counting the null terminator.%uA0d_name%uA0is a null-terminated filename.
返回值
On success, 1 is returned. On end of directory, 0 is returned. On error, -1 is returned, and%uA0errno%uA0is set appropriately.错误
标签 | 描述 |
---|---|
EBADF | Invalid file descriptor%uA0fd. |
EFAULT | Argument points outside the calling process’s address space. |
EINVAL | Result buffer is too small. |
ENOENT | No such directory. |
ENOTDIR | |
%uA0 | File descriptor does not refer to a directory. |