From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by sourceware.org (Postfix) with ESMTPS id 8C70A383D039 for ; Thu, 17 Jun 2021 02:59:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C70A383D039 Received: by mail-qk1-x732.google.com with SMTP id d196so1673180qkg.12 for ; Wed, 16 Jun 2021 19:59:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=4yqbMSYEKrg61S1hhK85WdBgWKvOrNkQ6KYXmzjoFN4=; b=iiPJgv+s9FntSMHYKAH56UfcsbWgJJoxDbmX6TiK0Mstj+YRpVebD6niaM82iGjajB 5juyDkSsPbHi++1Twx976khNkr0qyJtOGRpMU+tM5W8yOzHbhDTXY9TyIN49NoXtWuzz Cbz9qv+oafdFMhkM6haXoAml1gYCPj60BJ7wiHyhXowUtuzN87G72mjsZohwUSJmLvx4 hAZA0X1Dbm1xdg6ycAIIroCacmAhkuRz1b7Pbh+XilnMiKV+JaCmvkY41IhJ9Eq1v69h rfrxCecJ2OLU3ZB82mP7ugWi2Na8lqPqPjm0xCXEn9dGvM9lfauLkhKpRIUEzEowsfvc 6spA== X-Gm-Message-State: AOAM531JrrmymcbU2zVq5lBb8RrMXwc/8OU5+h0TuRAHTrONWiF9+mRg i0GR1lcZIdAk/1cNqmTfB4jueUFfY07iPWMMaAKNou7/TeN+xQ== X-Google-Smtp-Source: ABdhPJxQs4QFsoSB/UEmUu4pmXKDZhrua2qEbkpXoTqrCLAs/NQigPw+R39uNOg0jE+tJPuf/KYVrMGvuJRVejK5Ask= X-Received: by 2002:a05:620a:1675:: with SMTP id d21mr1557552qko.390.1623898766967; Wed, 16 Jun 2021 19:59:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: flint pyrite Date: Wed, 16 Jun 2021 20:59:06 -0600 Message-ID: Subject: Re: readdir and ENOENT error or EOF? To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2021 02:59:28 -0000 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 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. > > >