]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl) |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
4 | .\" |
5 | .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl> | |
6 | .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>: | |
7 | .\" In 1.3.X, returns only one entry each time; return value is different. | |
b4c0e1cb MK |
8 | .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS |
9 | .\" | |
4c1c5274 | 10 | .TH readdir 2 (date) "Linux man-pages (unreleased)" |
fea681da MK |
11 | .SH NAME |
12 | readdir \- read directory entry | |
f737fbd8 AC |
13 | .SH LIBRARY |
14 | Standard C library | |
8fc3b2cf | 15 | .RI ( libc ", " \-lc ) |
fea681da MK |
16 | .SH SYNOPSIS |
17 | .nf | |
8f33ee07 AC |
18 | .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" |
19 | .B #include <unistd.h> | |
68e4db0a | 20 | .PP |
8f33ee07 AC |
21 | .BI "int syscall(SYS_readdir, unsigned int " fd , |
22 | .BI " struct old_linux_dirent *" dirp ", unsigned int " count ); | |
fea681da | 23 | .fi |
dbfe9c70 | 24 | .PP |
45c99e3e | 25 | .IR Note : |
8f33ee07 AC |
26 | There is no definition of |
27 | .BR "struct old_linux_dirent" ; | |
28 | see NOTES. | |
fea681da MK |
29 | .SH DESCRIPTION |
30 | This is not the function you are interested in. | |
31 | Look at | |
32 | .BR readdir (3) | |
33 | for the POSIX conforming C library interface. | |
34 | This page documents the bare kernel system call interface, | |
f8c4a808 | 35 | which is superseded by |
fea681da MK |
36 | .BR getdents (2). |
37 | .PP | |
e511ffb6 | 38 | .BR readdir () |
fea681da | 39 | reads one |
b82f860a | 40 | .I old_linux_dirent |
fea681da | 41 | structure from the directory |
602995ec | 42 | referred to by the file descriptor |
fea681da | 43 | .I fd |
602995ec | 44 | into the buffer pointed to by |
fea681da | 45 | .IR dirp . |
c4bb193f | 46 | The argument |
fea681da | 47 | .I count |
d3c8f8e2 | 48 | is ignored; at most one |
b82f860a | 49 | .I old_linux_dirent |
d3c8f8e2 | 50 | structure is read. |
fea681da MK |
51 | .PP |
52 | The | |
b82f860a | 53 | .I old_linux_dirent |
85722724 ES |
54 | structure is declared (privately in Linux kernel file |
55 | .BR fs/readdir.c ) | |
56 | as follows: | |
fea681da | 57 | .PP |
088a639b | 58 | .in +4n |
b8302363 | 59 | .EX |
b82f860a | 60 | struct old_linux_dirent { |
85722724 ES |
61 | unsigned long d_ino; /* inode number */ |
62 | unsigned long d_offset; /* offset to this \fIold_linux_dirent\fP */ | |
63 | unsigned short d_namlen; /* length of this \fId_name\fP */ | |
d064d41a | 64 | char d_name[1]; /* filename (null\-terminated) */ |
fea681da | 65 | } |
b8302363 | 66 | .EE |
a08ea57c | 67 | .in |
fea681da MK |
68 | .PP |
69 | .I d_ino | |
70 | is an inode number. | |
85722724 | 71 | .I d_offset |
fea681da | 72 | is the distance from the start of the directory to this |
b82f860a | 73 | .IR old_linux_dirent . |
fea681da MK |
74 | .I d_reclen |
75 | is the size of | |
a5e0a0e4 | 76 | .IR d_name , |
d1a71985 | 77 | not counting the terminating null byte (\(aq\e0\(aq). |
fea681da | 78 | .I d_name |
2c5f1089 | 79 | is a null-terminated filename. |
47297adb | 80 | .SH RETURN VALUE |
fea681da MK |
81 | On success, 1 is returned. |
82 | On end of directory, 0 is returned. | |
83 | On error, \-1 is returned, and | |
84 | .I errno | |
f6a4078b | 85 | is set to indicate the error. |
fea681da MK |
86 | .SH ERRORS |
87 | .TP | |
88 | .B EBADF | |
89 | Invalid file descriptor | |
90 | .IR fd . | |
91 | .TP | |
92 | .B EFAULT | |
93 | Argument points outside the calling process's address space. | |
94 | .TP | |
95 | .B EINVAL | |
96 | Result buffer is too small. | |
97 | .TP | |
98 | .B ENOENT | |
99 | No such directory. | |
100 | .TP | |
101 | .B ENOTDIR | |
102 | File descriptor does not refer to a directory. | |
3113c7f3 | 103 | .SH STANDARDS |
8382f16d | 104 | This system call is Linux-specific. |
c12fd10d | 105 | .SH NOTES |
1dfd87ee MK |
106 | You will need to define the |
107 | .I old_linux_dirent | |
108 | structure yourself. | |
45c99e3e MK |
109 | However, probably you should use |
110 | .BR readdir (3) | |
111 | instead. | |
efeece04 | 112 | .PP |
d80cadc1 | 113 | This system call does not exist on x86-64. |
47297adb | 114 | .SH SEE ALSO |
fea681da MK |
115 | .BR getdents (2), |
116 | .BR readdir (3) |