]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl) |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
c13182ef | 11 | .\" |
fea681da MK |
12 | .\" Since the Linux kernel and libraries are constantly changing, this |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl> | |
24 | .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>: | |
25 | .\" In 1.3.X, returns only one entry each time; return value is different. | |
b4c0e1cb MK |
26 | .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS |
27 | .\" | |
45c99e3e | 28 | .TH READDIR 2 2012-07-13 "Linux" "Linux Programmer's Manual" |
fea681da MK |
29 | .SH NAME |
30 | readdir \- read directory entry | |
31 | .SH SYNOPSIS | |
32 | .nf | |
fea681da | 33 | .sp |
b82f860a | 34 | .BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp "," |
93e4c37f | 35 | .BI " unsigned int " count ); |
fea681da | 36 | .fi |
45c99e3e MK |
37 | |
38 | .IR Note : | |
39 | There is no glibc wrapper for this system call; see NOTES. | |
fea681da MK |
40 | .SH DESCRIPTION |
41 | This is not the function you are interested in. | |
42 | Look at | |
43 | .BR readdir (3) | |
44 | for the POSIX conforming C library interface. | |
45 | This page documents the bare kernel system call interface, | |
f8c4a808 | 46 | which is superseded by |
fea681da MK |
47 | .BR getdents (2). |
48 | .PP | |
e511ffb6 | 49 | .BR readdir () |
fea681da | 50 | reads one |
b82f860a | 51 | .I old_linux_dirent |
fea681da | 52 | structure from the directory |
602995ec | 53 | referred to by the file descriptor |
fea681da | 54 | .I fd |
602995ec | 55 | into the buffer pointed to by |
fea681da | 56 | .IR dirp . |
c4bb193f | 57 | The argument |
fea681da | 58 | .I count |
d3c8f8e2 | 59 | is ignored; at most one |
b82f860a | 60 | .I old_linux_dirent |
d3c8f8e2 | 61 | structure is read. |
fea681da MK |
62 | .PP |
63 | The | |
b82f860a | 64 | .I old_linux_dirent |
fea681da MK |
65 | structure is declared as follows: |
66 | .PP | |
088a639b | 67 | .in +4n |
fea681da | 68 | .nf |
b82f860a | 69 | struct old_linux_dirent { |
8c1e7c9c MK |
70 | long d_ino; /* inode number */ |
71 | off_t d_off; /* offset to this \fIold_linux_dirent\fP */ | |
72 | unsigned short d_reclen; /* length of this \fId_name\fP */ | |
73 | char d_name[NAME_MAX+1]; /* filename (null-terminated) */ | |
fea681da MK |
74 | } |
75 | .fi | |
a08ea57c | 76 | .in |
fea681da MK |
77 | .PP |
78 | .I d_ino | |
79 | is an inode number. | |
80 | .I d_off | |
81 | is the distance from the start of the directory to this | |
b82f860a | 82 | .IR old_linux_dirent . |
fea681da MK |
83 | .I d_reclen |
84 | is the size of | |
a5e0a0e4 | 85 | .IR d_name , |
cb8c0c9b | 86 | not counting the terminating null byte. |
fea681da | 87 | .I d_name |
2c5f1089 | 88 | is a null-terminated filename. |
47297adb | 89 | .SH RETURN VALUE |
fea681da MK |
90 | On success, 1 is returned. |
91 | On end of directory, 0 is returned. | |
92 | On error, \-1 is returned, and | |
93 | .I errno | |
94 | is set appropriately. | |
95 | .SH ERRORS | |
96 | .TP | |
97 | .B EBADF | |
98 | Invalid file descriptor | |
99 | .IR fd . | |
100 | .TP | |
101 | .B EFAULT | |
102 | Argument points outside the calling process's address space. | |
103 | .TP | |
104 | .B EINVAL | |
105 | Result buffer is too small. | |
106 | .TP | |
107 | .B ENOENT | |
108 | No such directory. | |
109 | .TP | |
110 | .B ENOTDIR | |
111 | File descriptor does not refer to a directory. | |
47297adb | 112 | .SH CONFORMING TO |
8382f16d | 113 | This system call is Linux-specific. |
c12fd10d MK |
114 | .SH NOTES |
115 | Glibc does not provide a wrapper for this system call; call it using | |
116 | .BR syscall (2). | |
1dfd87ee MK |
117 | You will need to define the |
118 | .I old_linux_dirent | |
119 | structure yourself. | |
45c99e3e MK |
120 | However, probably you should use |
121 | .BR readdir (3) | |
122 | instead. | |
47297adb | 123 | .SH SEE ALSO |
fea681da MK |
124 | .BR getdents (2), |
125 | .BR readdir (3) |