public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: flint pyrite <flintnpyrite@gmail.com>
To: libc-help@sourceware.org
Subject: Re: readdir and ENOENT error or EOF?
Date: Wed, 16 Jun 2021 20:59:06 -0600	[thread overview]
Message-ID: <CAPdH1ff7TdJPRHbTCokxapjYdVDg04dUNk2tJb9bTx5xKp=7+g@mail.gmail.com> (raw)
In-Reply-To: <CAPdH1feeZWYTOEgz=Q14PnfccHqz=gE6qwr9-L0bfK7rh2xDQg@mail.gmail.com>

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.
>
>
>

      reply	other threads:[~2021-06-17  2:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  2:38 flint pyrite
2021-06-17  2:59 ` flint pyrite [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPdH1ff7TdJPRHbTCokxapjYdVDg04dUNk2tJb9bTx5xKp=7+g@mail.gmail.com' \
    --to=flintnpyrite@gmail.com \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).