public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/29228] New: ftw() does not find all directories
@ 2022-06-06  8:50 galaxyking0419 at gmail dot com
  2022-06-06 17:58 ` [Bug libc/29228] " fweimer at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: galaxyking0419 at gmail dot com @ 2022-06-06  8:50 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29228

            Bug ID: 29228
           Summary: ftw() does not find all directories
           Product: glibc
           Version: 2.35
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: galaxyking0419 at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The ftw() function will miss some directories on my system (.e.g
/usr/local/man) unless use the directory as the starting directory.

Consider the following snippet:
#include <errno.h>
#include <stdio.h>
#include <string.h>

#include <ftw.h>

static inline int callback(const char *path, const struct stat *stat, int flag)
{
    if (strcmp(path, "/usr/local/man") == 0)
        printf("Found %s\n", path);
        return 0;
}

int main(int argc, const char *argv[])
{
    if (ftw(argv[1], callback, 4096) != 0) {
        printf("ERROR: Failed to traverse the directory tree! (%s)\n",
strerror(errno));
        return 3;
    }
    return 0;
}

Command Output:
[root@NoteBook xxx]# ./a.out /usr
[root@NoteBook xxx]# ./a.out /usr/local
[root@NoteBook xxx]# ./a.out /usr/local/man
Found /usr/local/man

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-06-07  9:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06  8:50 [Bug libc/29228] New: ftw() does not find all directories galaxyking0419 at gmail dot com
2022-06-06 17:58 ` [Bug libc/29228] " fweimer at redhat dot com
2022-06-07  2:26 ` galaxyking0419 at gmail dot com
2022-06-07  6:10 ` fweimer at redhat dot com
2022-06-07  6:11 ` fweimer at redhat dot com
2022-06-07  6:56 ` galaxyking0419 at gmail dot com
2022-06-07  7:28 ` fweimer at redhat dot com
2022-06-07  9:49 ` galaxyking0419 at gmail dot com
2022-06-07  9:55 ` fweimer at redhat dot com

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