public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* readdir and ENOENT error or EOF?
@ 2021-06-17  2:38 flint pyrite
  2021-06-17  2:59 ` flint pyrite
  0 siblings, 1 reply; 2+ messages in thread
From: flint pyrite @ 2021-06-17  2:38 UTC (permalink / raw)
  To: libc-help

There appears to be ambiguity in user documentation for readdir when
it returns NULL and errno is set to ENOENT.

Is this an EOF condition or an actual error that should be handled?

...
/* On some systems getdents fails with ENOENT when the
open directory has been rmdir'd already. POSIX.1
requires that we treat this condition like normal EOF. */
if (bytes < 0 && errno == ENOENT)
bytes = 0;
...
https://code.woboq.org/userspace/glibc/sysdeps/posix/readdir.c.htmlin

Thanks in advance for your time and help on this matter.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: readdir and ENOENT error or EOF?
  2021-06-17  2:38 readdir and ENOENT error or EOF? flint pyrite
@ 2021-06-17  2:59 ` flint pyrite
  0 siblings, 0 replies; 2+ messages in thread
From: flint pyrite @ 2021-06-17  2:59 UTC (permalink / raw)
  To: libc-help

NOTE:
https://www.austingroupbugs.net/view.php?id=697

message:
(0004947)
geoffclare (manager)
2020-08-28 08:21
edited on: 2020-10-08 16:32

...
The posix_getdents() function shall start reading at the current file
offset in the open file description associated with fildes. On
successful return, the file offset shall be incremented to point to
the directory entry immediately following the last entry whose
information was returned in buf, or to point to end-of-file if there
are no more directory entries. On failure, the value of the file
offset is unspecified. The current file offset can be set and
retrieved using lseek() on the open file description associated with
fildes. The behavior is unspecified if lseek() is used to set the file
offset to a value other than zero or a value returned by a previous
call to lseek() on the same open file description.
...
ERRORS

The posix_getdents() function shall fail if:
...
[ENOENT]

The current file offset is not located at a valid directory entry.

The ENOENT condition makes it sound like it is not an ERROR but an EOF
status indicator


On Wed, Jun 16, 2021 at 8:38 PM flint pyrite <flintnpyrite@gmail.com> wrote:
>
> There appears to be ambiguity in user documentation for readdir when
> it returns NULL and errno is set to ENOENT.
>
> Is this an EOF condition or an actual error that should be handled?
>
> ...
> /* On some systems getdents fails with ENOENT when the
> open directory has been rmdir'd already. POSIX.1
> requires that we treat this condition like normal EOF. */
> if (bytes < 0 && errno == ENOENT)
> bytes = 0;
> ...
> https://code.woboq.org/userspace/glibc/sysdeps/posix/readdir.c.htmlin
>
> Thanks in advance for your time and help on this matter.
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-17  2:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17  2:38 readdir and ENOENT error or EOF? flint pyrite
2021-06-17  2:59 ` flint pyrite

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).