#include <unistd.h> #include <linux/dirent.h> #include <linux/unistd.h> _syscall3(int, readdir, uint, fd, struct dirent *, dirp, uint, count); int readdir(unsigned int fd, struct dirent *dirp, unsigned int count);
readdir 는 fd 에 의해 포인트된 디렉토리에서 dirp에 의해 포인트된 메모리 지역에 dirent 구조체를 읽는다. count 인자는 무시된다;
dirent 구조체에 다음과 같이 선언된다:
struct dirent
{
long d_ino; /* 아이노드 수 */
off_t d_off; /* dirent 의 오프셋 */
unsigned short d_reclen; /* d_name 의 길이 */
char d_name [NAME_MAX+1]; /* 파일 이름(널로 종료) */
}
d_ino 는 inode 숫자이다. d_off 는 디렉토리의 시작에서 dirent까지의 거리이다. d_reclen 는 널 종결자를 세지 않은 d_name의 크기이다. d_name 는 널로 끝난 파일 이름이다.