From 34c86f425441d13e9e6cebd2ce1ebd99fc373ce2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 8 Feb 2003 18:29:49 +0000 Subject: Update. 2003-02-08 Ulrich Drepper * io/ftwtest.c: Get current working directory before and after the nftw call and make sure they match. 2003-02-08 Jim Meyering * ftw.c (ftw_startup): When using FTW_CHDIR, always remember the current directory, not just when DIR contains a slash. Reported by Manoj Srivastava. --- io/ftw.c | 4 ++-- io/ftwtest.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'io') diff --git a/io/ftw.c b/io/ftw.c index 227f3f3b52..3d2d940cd8 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -629,13 +629,13 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, data.known_objects = NULL; /* Now go to the directory containing the initial file/directory. */ - if ((flags & FTW_CHDIR) && data.ftw.base > 0) + if (flags & FTW_CHDIR) { /* GNU extension ahead. */ cwd = __getcwd (NULL, 0); if (cwd == NULL) result = -1; - else + else if (data.ftw.base > 0) { /* Change to the directory the file is in. In data.dirbuf we have a writable copy of the file name. Just NUL diff --git a/io/ftwtest.c b/io/ftwtest.c index 851ed1d587..4f527997df 100644 --- a/io/ftwtest.c +++ b/io/ftwtest.c @@ -70,9 +70,22 @@ main (int argc, char *argv[]) if (do_phys) flag |= FTW_PHYS; + char *cw1 = getcwd (NULL, 0); + r = nftw (optind < argc ? argv[optind] : ".", cb, do_exit ? 1 : 3, flag); if (r < 0) perror ("nftw"); + + char *cw2 = getcwd (NULL, 0); + + if (strcmp (cw1, cw2) != 0) + { + printf ("current working directory before and after nftw call differ:\n" + "before: %s\n" + "after: %s\n", cw1, cw2); + exit (1); + } + if (do_exit) { puts (r == 26 ? "succeeded" : "failed"); -- cgit v1.2.1