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