aboutsummaryrefslogtreecommitdiffstats
path: root/man/man3/readdir.3
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2025-05-28 20:44:28 +0200
committerAlejandro Colomar <alx@kernel.org>2025-11-09 13:03:07 +0100
commit573f28a9954ac043eeb1bc57815c88ecedeb1268 (patch)
tree8d3e5ced29e77cb025d28a601112cdce267d978a /man/man3/readdir.3
parent662f2afcefd843c32352f5d772b9fb0770aaf5d7 (diff)
downloadman-pages-573f28a9954ac043eeb1bc57815c88ecedeb1268.tar.gz
man/: Use '.member' notation for referring to struct/union members
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man/man3/readdir.3')
-rw-r--r--man/man3/readdir.344
1 files changed, 22 insertions, 22 deletions
diff --git a/man/man3/readdir.3 b/man/man3/readdir.3
index 0871aab8c1..e1c7d2a6a6 100644
--- a/man/man3/readdir.3
+++ b/man/man3/readdir.3
@@ -47,9 +47,9 @@ struct dirent {
The only fields in the
.I dirent
structure that are mandated by POSIX.1 are
-.I d_name
+.I .d_name
and
-.IR d_ino .
+.IR .d_ino .
The other fields are unstandardized, and not present on all systems;
see VERSIONS.
.P
@@ -57,17 +57,17 @@ The fields of the
.I dirent
structure are as follows:
.TP
-.I d_ino
+.I .d_ino
This is the inode number of the file.
.TP
-.I d_off
+.I .d_off
The value returned in
-.I d_off
+.I .d_off
is the same as would be returned by calling
.BR telldir (3)
at the current position in the directory stream.
Be aware that despite its type and name, the
-.I d_off
+.I .d_off
field is seldom any kind of directory offset on modern filesystems.
.\" https://lwn.net/Articles/544298/
Applications should treat this field as an opaque value,
@@ -75,12 +75,12 @@ making no assumptions about its contents;
see also
.BR telldir (3).
.TP
-.I d_reclen
+.I .d_reclen
This is the size (in bytes) of the returned record.
This may not match the size of the structure definition shown above;
see VERSIONS.
.TP
-.I d_type
+.I .d_type
This field contains a value indicating the file type,
making it possible to avoid the expense of calling
.BR lstat (2)
@@ -92,7 +92,7 @@ since glibc 2.19, or
.B _BSD_SOURCE
on glibc 2.19 and earlier),
glibc defines the following macro constants for the value returned in
-.IR d_type :
+.IR .d_type :
.RS
.TP 12
.B DT_BLK
@@ -125,11 +125,11 @@ Currently,
.\" The same sentence is in getdents.2
only some filesystems (among them: Btrfs, ext2, ext3, and ext4)
have full support for returning the file type in
-.IR d_type .
+.IR .d_type .
All applications must properly handle a return of
.BR DT_UNKNOWN .
.TP
-.I d_name
+.I .d_name
This field contains the null terminated filename;
see VERSIONS.
.P
@@ -203,13 +203,13 @@ will require that
be thread-safe when concurrently employed on different directory streams.
.SH VERSIONS
Only the fields
-.I d_name
+.I .d_name
and (as an XSI extension)
-.I d_ino
+.I .d_ino
are specified in POSIX.1.
.\" POSIX.1-2001, POSIX.1-2008
Other than Linux, the
-.I d_type
+.I .d_type
field is available mainly only on BSD systems.
The remaining fields are available on many, but not all systems.
Under glibc,
@@ -222,17 +222,17 @@ or
.B _DIRENT_HAVE_D_TYPE
are defined.
.\"
-.SS The d_name field
+.SS The \f[I].d_name\f[] field
The
.I dirent
structure definition shown above is taken from the glibc headers,
and shows the
-.I d_name
+.I .d_name
field with a fixed size.
.P
.IR Warning :
applications should avoid any dependence on the size of the
-.I d_name
+.I .d_name
field.
POSIX defines it as
.IR "char\ d_name[]",
@@ -242,17 +242,17 @@ characters preceding the terminating null byte (\[aq]\[rs]0\[aq]).
.P
POSIX.1 explicitly notes that this field should not be used as an lvalue.
The standard also notes that the use of
-.I sizeof(d_name)
+.I sizeof(.d_name)
is incorrect;
use
-.I strlen(d_name)
+.I strlen(.d_name)
instead.
(On some systems, this field is defined as
.IR char\~d_name[1] !)
By implication, the use
.I sizeof(struct dirent)
to capture the size of the record including the size of
-.I d_name
+.I .d_name
is also incorrect.
.P
Note that while the call
@@ -266,10 +266,10 @@ fpathconf(fd, _PC_NAME_MAX)
returns the value 255 for most filesystems,
on some filesystems (e.g., CIFS, Windows SMB servers),
the null-terminated filename that is (correctly) returned in
-.I d_name
+.I .d_name
can actually exceed this size.
In such cases, the
-.I d_reclen
+.I .d_reclen
field will contain a value that exceeds the size of the glibc
.I dirent
structure shown above.