]>
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 | .\" | |
d9343c5c | 28 | .TH READDIR 2 2007-06-01 "Linux" "Linux Programmer's Manual" |
fea681da MK |
29 | .SH NAME |
30 | readdir \- read directory entry | |
31 | .SH SYNOPSIS | |
32 | .nf | |
b4c0e1cb | 33 | .B #include <linux/types.h> |
fea681da | 34 | .B #include <linux/dirent.h> |
fea681da | 35 | .sp |
93e4c37f MK |
36 | .BI "int readdir(unsigned int " fd ", struct dirent *" dirp "," |
37 | .BI " unsigned int " count ); | |
fea681da MK |
38 | .fi |
39 | .SH DESCRIPTION | |
40 | This is not the function you are interested in. | |
41 | Look at | |
42 | .BR readdir (3) | |
43 | for the POSIX conforming C library interface. | |
44 | This page documents the bare kernel system call interface, | |
45 | which can change, and which is superseded by | |
46 | .BR getdents (2). | |
47 | .PP | |
e511ffb6 | 48 | .BR readdir () |
fea681da MK |
49 | reads one |
50 | .I dirent | |
51 | structure from the directory | |
52 | pointed at by | |
53 | .I fd | |
54 | into the memory area pointed to by | |
55 | .IR dirp . | |
c13182ef | 56 | The parameter |
fea681da | 57 | .I count |
d3c8f8e2 MK |
58 | is ignored; at most one |
59 | .I dirent | |
60 | structure is read. | |
fea681da MK |
61 | .PP |
62 | The | |
63 | .I dirent | |
64 | structure is declared as follows: | |
65 | .PP | |
66 | .RS | |
67 | .nf | |
389fe6c8 | 68 | struct dirent { |
fea681da MK |
69 | long d_ino; /* inode number */ |
70 | off_t d_off; /* offset to this \fIdirent\fP */ | |
71 | unsigned short d_reclen; /* length of this \fId_name\fP */ | |
2c5f1089 | 72 | char d_name [NAME_MAX+1]; /* filename (null-terminated) */ |
fea681da MK |
73 | } |
74 | .fi | |
75 | .RE | |
76 | .PP | |
77 | .I d_ino | |
78 | is an inode number. | |
79 | .I d_off | |
80 | is the distance from the start of the directory to this | |
81 | .IR dirent . | |
82 | .I d_reclen | |
83 | is the size of | |
a5e0a0e4 | 84 | .IR d_name , |
fea681da MK |
85 | not counting the null terminator. |
86 | .I d_name | |
2c5f1089 | 87 | is a null-terminated filename. |
fea681da MK |
88 | .SH "RETURN VALUE" |
89 | On success, 1 is returned. | |
90 | On end of directory, 0 is returned. | |
91 | On error, \-1 is returned, and | |
92 | .I errno | |
93 | is set appropriately. | |
94 | .SH ERRORS | |
95 | .TP | |
96 | .B EBADF | |
97 | Invalid file descriptor | |
98 | .IR fd . | |
99 | .TP | |
100 | .B EFAULT | |
101 | Argument points outside the calling process's address space. | |
102 | .TP | |
103 | .B EINVAL | |
104 | Result buffer is too small. | |
105 | .TP | |
106 | .B ENOENT | |
107 | No such directory. | |
108 | .TP | |
109 | .B ENOTDIR | |
110 | File descriptor does not refer to a directory. | |
111 | .SH "CONFORMING TO" | |
112 | This system call is Linux specific. | |
c12fd10d MK |
113 | .SH NOTES |
114 | Glibc does not provide a wrapper for this system call; call it using | |
115 | .BR syscall (2). | |
fea681da MK |
116 | .SH "SEE ALSO" |
117 | .BR getdents (2), | |
118 | .BR readdir (3) |