Linux Manual Pages development
 help / color / mirror / Atom feed
* [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

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