Skip to content

Commit 0c9bce2

Browse files
committed
directory(3): minor markup tweaks
1 parent 7f031ef commit 0c9bce2

1 file changed

Lines changed: 58 additions & 13 deletions

File tree

lib/libc/gen/directory.3

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" $NetBSD: directory.3,v 1.44 2026/01/22 04:01:14 dholland Exp $
1+
.\" $NetBSD: directory.3,v 1.45 2026/01/22 10:34:30 uwe Exp $
22
.\"
33
.\" Copyright (c) 1983, 1991, 1993
44
.\" The Regents of the University of California. All rights reserved.
@@ -32,6 +32,7 @@
3232
.Dd January 21, 2026
3333
.Dt DIRECTORY 3
3434
.Os
35+
.
3536
.Sh NAME
3637
.Nm fdopendir ,
3738
.Nm opendir ,
@@ -43,28 +44,45 @@
4344
.Nm closedir ,
4445
.Nm dirfd
4546
.Nd directory operations
47+
.
4648
.Sh LIBRARY
4749
.Lb libc
50+
.
4851
.Sh SYNOPSIS
52+
.
4953
.In dirent.h
54+
.
5055
.Ft DIR *
5156
.Fn opendir "const char *filename"
57+
.
5258
.Ft DIR *
5359
.Fn fdopendir "int fd"
60+
.
5461
.Ft struct dirent *
5562
.Fn readdir "DIR *dirp"
63+
.
5664
.Ft int
57-
.Fn readdir_r "DIR * restrict dirp" "struct dirent * restrict entry" "struct dirent ** restrict result"
65+
.Fo readdir_r
66+
.Fa "DIR * restrict dirp"
67+
.Fa "struct dirent * restrict entry"
68+
.Fa "struct dirent ** restrict result"
69+
.Fc
70+
.
5871
.Ft long
5972
.Fn telldir "DIR *dirp"
73+
.
6074
.Ft void
6175
.Fn seekdir "DIR *dirp" "long loc"
76+
.
6277
.Ft void
6378
.Fn rewinddir "DIR *dirp"
79+
.
6480
.Ft int
6581
.Fn closedir "DIR *dirp"
82+
.
6683
.Ft int
6784
.Fn dirfd "DIR *dirp"
85+
.
6886
.Sh DESCRIPTION
6987
The type
7088
.Vt DIR
@@ -77,9 +95,11 @@ structure is similar to that of the
7795
structure maintained by the
7896
.Xr stdio 3
7997
library functions.
98+
.
8099
.Sh FUNCTIONS
81100
The following standard directory operations are defined.
82-
.Bl -tag -width XXX
101+
.Bl -tag -width Fn
102+
.
83103
.It Fn opendir "filename"
84104
The
85105
.Fn opendir
@@ -94,6 +114,7 @@ Otherwise,
94114
.Fn opendir
95115
returns
96116
.Dv NULL .
117+
.
97118
.It Fn fdopendir "fd"
98119
The
99120
.Fn fdopendir
@@ -118,6 +139,7 @@ other than by means of
118139
the behavior is undefined.
119140
The file descriptor can be closed by calling
120141
.Fn closedir .
142+
.
121143
.It Fn readdir "dirp"
122144
The
123145
.Fn readdir
@@ -134,13 +156,14 @@ The returned structure is described in
134156
.Xr dirent 3 .
135157
.Pp
136158
The returned pointer to the
137-
.Em dirent
159+
.Vt dirent
138160
structure points to data which may be overwritten by another call to
139161
.Fn readdir
140162
on the same directory stream.
141163
This data is not however overwritten by another call to
142164
.Fn readdir
143165
on a different directory stream.
166+
.
144167
.It Fn readdir_r "dirp" "entry" "result"
145168
The
146169
.Fn readdir_r
@@ -169,10 +192,14 @@ the
169192
.Fn readdir_r
170193
function may buffer several directory entries per actual read operation.
171194
Both functions mark for update the
172-
.Em st_atime
173-
field (see
174-
.Xr stat 2 )
195+
.Fa st_atime
196+
field
197+
.Po
198+
see
199+
.Xr stat 2
200+
.Pc
175201
of the directory each time the directory is actually read.
202+
.
176203
.It Fn telldir "dirp"
177204
The
178205
.Fn telldir
@@ -189,6 +216,7 @@ is the same as
189216
supplied as an argument to the
190217
.Fn seekdir
191218
call.
219+
.
192220
.It Fn seekdir "dirp" "loc"
193221
The
194222
.Fn seekdir
@@ -223,6 +251,7 @@ value becomes invalid.
223251
.Fn seekdir
224252
returns no value.
225253
There is no supported way to detect if the operation succeeded.
254+
.
226255
.It Fn rewinddir "dirp"
227256
The
228257
.Fn rewinddir
@@ -232,11 +261,14 @@ It also causes the directory stream to refer to the
232261
current state of the corresponding directory, as if a call to
233262
.Fn opendir
234263
was made.
235-
It is not specified whether this refers to the ``corresponding directory''
264+
It is not specified whether this refers to the
265+
.Dq corresponding directory
236266
by name or by underlying object.
237-
(These can differ if
267+
.Po
268+
These can differ if
238269
.Xr rename 2
239-
has been used.)
270+
has been used
271+
.Pc .
240272
.\" Note: currently the underlying fd is reopened if and only if
241273
.\" __DTF_READALL is in effect, which is true for union mounts and
242274
.\" nfs; documenting that exactly seems inadvisable since it might
@@ -245,6 +277,7 @@ has been used.)
245277
If
246278
.Fa dirp
247279
does not refer to a valid directory stream, the behavior is undefined.
280+
.
248281
.It Fn closedir "dirp"
249282
The
250283
.Fn closedir
@@ -253,6 +286,7 @@ and frees the structure associated with the
253286
.Fa dirp
254287
pointer,
255288
returning 0 on success and \-1 on failure.
289+
.
256290
.It Fn dirfd "dirp"
257291
The
258292
.Fn dirfd
@@ -294,13 +328,14 @@ if (dirp != NULL) {
294328
}
295329
return (NOT_FOUND);
296330
.Ed
331+
.
297332
.Sh COMPATIBILITY
298333
The described directory operations have traditionally been problematic
299334
in terms of portability.
300335
A good example is the semantics of
301-
.Sq \&.
336+
.Sq Li \&.
302337
(dot) and
303-
.Sq \&..
338+
.Sq Li \&..
304339
(dot-dot).
305340
Based on historical implementations,
306341
the rules about file descriptors apply to directory streams as well.
@@ -312,7 +347,8 @@ implemented by using file descriptors.
312347
The following additional remarks can be noted from the
313348
.St -p1003.1-2008
314349
standard.
315-
.Bl -bullet -offset 2n
350+
.Bl -bullet
351+
.
316352
.It
317353
If the type
318354
.Vt DIR
@@ -323,6 +359,7 @@ applications should be able to open only
323359
.Dv OPEN_MAX
324360
files and directories.
325361
Otherwise the limit is left as unspecified.
362+
.
326363
.It
327364
When a file descriptor is used to implement the directory stream, the
328365
.Fn closedir
@@ -332,12 +369,14 @@ flag had been set for the file descriptor.
332369
In other words, it is mandatory that
333370
.Fn closedir
334371
deallocates the file descriptor.
372+
.
335373
.It
336374
If directory streams are not implemented by using file descriptors,
337375
functions such as
338376
.Fn dirfd
339377
may fail with
340378
.Er ENOTSUP .
379+
.
341380
.It
342381
If a file is removed from or added to the directory
343382
after the most recent call to
@@ -347,6 +386,7 @@ or
347386
it is unspecified whether a subsequent call to
348387
.Fn readdir
349388
returns an entry for that file.
389+
.
350390
.It
351391
When using the function
352392
.Fn seekdir ,
@@ -363,6 +403,7 @@ and
363403
the results of any subsequent call to
364404
.Fn readdir
365405
are unspecified, possibly resulting in undefined behavior.
406+
.
366407
.It
367408
After a call to
368409
.Xr fork 2 ,
@@ -375,19 +416,22 @@ or
375416
However, if both the parent and child processes use these functions,
376417
the result is undefined.
377418
.El
419+
.
378420
.Sh ERRORS
379421
.\"
380422
.\" XXX: The errors should be enumerated.
381423
.\"
382424
All described functions may set
383425
.Vt errno
384426
to indicate the error.
427+
.
385428
.Sh SEE ALSO
386429
.Xr close 2 ,
387430
.Xr lseek 2 ,
388431
.Xr open 2 ,
389432
.Xr read 2 ,
390433
.Xr dirent 3
434+
.
391435
.Sh STANDARDS
392436
The
393437
.Fn opendir ,
@@ -399,6 +443,7 @@ functions conform to
399443
.St -p1003.1-90 .
400444
The other functions conform to
401445
.St -p1003.1-2008 .
446+
.
402447
.Sh HISTORY
403448
The
404449
.Fn opendir ,

0 commit comments

Comments
 (0)