unsigned long d_off; /* Offset to next \fIlinux_dirent\fP */
unsigned short d_reclen; /* Length of this \fIlinux_dirent\fP */
char d_name[]; /* Filename (null-terminated) */
- /* length is actually (d_reclen \- 2 \-
- offsetof(struct linux_dirent, d_name) */
+ /* length is actually (d_reclen \- 2 \-
+ offsetof(struct linux_dirent, d_name)) */
/*
char pad; // Zero padding byte
- char d_type; // File type (only since Linux 2.6.4;
- // offset is (d_reclen \- 1))
+ char d_type; // File type (only since Linux
+ // 2.6.4); offset is (d_reclen \- 1)
*/
}
Currently,
.\" kernel 2.6.27
.\" The same sentence is in readdir.2
-only some file systems (among them: Btrfs, ext2, ext3, and ext4)
+only some filesystems (among them: Btrfs, ext2, ext3, and ext4)
have full support for returning the file type in
.IR d_type .
All applications must properly handle a return of
The original Linux
.BR getdents ()
-system call did not handle large file systems and large file offsets.
+system call did not handle large filesystems and large file offsets.
Consequently, Linux 2.4 added
.BR getdents64 (),
with wider types for the
.IR linux_dirent
structure.
.SH EXAMPLE
-.\" FIXME: This program uses the older getdents(0 system call
-.\" and the structure with smaller field widths.
+.\" FIXME The example program needs to be revised, since it uses the older
+.\" getdents() system call and the structure with smaller field widths.
The program below demonstrates the use of
.BR getdents ().
The following output shows an example of what we see when running this
.nf
.RB "$" " ./a.out /testfs/"
--------------- nread=120 ---------------
-i-node# file type d_reclen d_off d_name
+inode# file type d_reclen d_off d_name
2 directory 16 12 .
2 directory 16 24 ..
11 directory 24 44 lost+found
break;
printf("\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=%d \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\\n", nread);
- printf("i\-node# file type d_reclen d_off d_name\\n");
+ printf("inode# file type d_reclen d_off d_name\\n");
for (bpos = 0; bpos < nread;) {
d = (struct linux_dirent *) (buf + bpos);
printf("%8ld ", d\->d_ino);
.SH SEE ALSO
.BR readdir (2),
.BR readdir (3)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.