* [bug report] opendir(3): document file offset behavior for fdopendir()
@ 2026-11-13 21:28 Jorge Almeida
2026-11-13 21:39 ` Alejandro Colomar
0 siblings, 1 reply; 2+ messages in thread
From: Jorge Almeida @ 2026-11-13 21:28 UTC (permalink / raw)
To: linux-man
Hi,
The opendir(3) manual page currently describes fdopendir() as being
"like opendir(), but returns a directory stream for the directory
referred to by the open file descriptor fd."
However, it omits a critical detail documented in POSIX (fdopendir(3p))
and the BSD man pages: fdopendir() uses the current file offset of fd
rather than resetting it to zero.
If a caller duplicates an open directory descriptor with dup() and
exhausts the stream with readdir(), subsequent dup() + fdopendir()
calls will immediately hit EOF unless rewinddir() or lseek() is called.
By contrast, fdopen(3) explicitly warns that the stream's file
position indicator is set to that belonging to fd.
Could a similar note be added to the fdopendir() description in
opendir(3)?
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] opendir(3): document file offset behavior for fdopendir()
2026-11-13 21:28 [bug report] opendir(3): document file offset behavior for fdopendir() Jorge Almeida
@ 2026-11-13 21:39 ` Alejandro Colomar
0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2026-11-13 21:39 UTC (permalink / raw)
To: Jorge Almeida; +Cc: linux-man
[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]
Hi Jorge,
> Date: 2026-11-13 21:28:32+0000
> From: Jorge Almeida <jjalmeida@gmail.com>
>
> Hi,
>
> The opendir(3) manual page currently describes fdopendir() as being
> "like opendir(), but returns a directory stream for the directory
> referred to by the open file descriptor fd."
>
> However, it omits a critical detail documented in POSIX (fdopendir(3p))
> and the BSD man pages: fdopendir() uses the current file offset of fd
> rather than resetting it to zero.
>
> If a caller duplicates an open directory descriptor with dup() and
> exhausts the stream with readdir(), subsequent dup() + fdopendir()
> calls will immediately hit EOF unless rewinddir() or lseek() is called.
> By contrast, fdopen(3) explicitly warns that the stream's file
> position indicator is set to that belonging to fd.
>
> Could a similar note be added to the fdopendir() description in
> opendir(3)?
Would you mind sending a patch?
If so, you can have a look at
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING>
and
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING.d/>
for some help (and I will gladly help if you have any questions).
Have a lovely night!
Alex
>
> Thanks.
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-13 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 21:28 [bug report] opendir(3): document file offset behavior for fdopendir() Jorge Almeida
2026-11-13 21:39 ` Alejandro Colomar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox