]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Sun, 12 Jan 2003 20:44:20 +0000 (20:44 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 12 Jan 2003 20:44:20 +0000 (20:44 +0000)
2003-01-12  Ulrich Drepper  <drepper@redhat.com>

* io/ftw.c (process_entry): Use relative path when using chdir()
to change direcoty after call to ftw_dir.
* io/ftwtest-sh: Add test for relative path argument to nftw()
with FTW_CHDIR option.

ChangeLog
io/ftw.c
io/ftwtest-sh

index 4393fa5cafd97286122e815c4e41bc20c546ee41..c1269a6ba45b16be6c6dd04500570b577c2b403e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-01-12  Ulrich Drepper  <drepper@redhat.com>
+
+       * io/ftw.c (process_entry): Use relative path when using chdir()
+       to change direcoty after call to ftw_dir.
+       * io/ftwtest-sh: Add test for relative path argument to nftw()
+       with FTW_CHDIR option.
+
 2002-01-12  Franz Sirl  <Franz.Sirl-kernel@lauterbach.com>
 
        * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_VFORK_SYSCALL):
index 4debcc05425fc0cf66e1af94f701ae44f269539a..f93d00f332957bd4a81b0eaaa7a72f1506e84c08 100644 (file)
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -212,7 +212,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp)
                {
                  char *newp;
                  bufsize += MAX (1024, 2 * this_len);
-                 newp = realloc (buf, bufsize);
+                 newp = (char *) realloc (buf, bufsize);
                  if (newp == NULL)
                    {
                      /* No more memory.  */
@@ -357,15 +357,8 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
                            result = -1;
                        }
                      else
-                       {
-                         /* Please note that we overwrite a slash.  */
-                         data->dirbuf[data->ftw.base - 1] = '\0';
-
-                         if (__chdir (data->dirbuf) < 0)
-                           result = -1;
-
-                         data->dirbuf[data->ftw.base - 1] = '/';
-                       }
+                       if (__chdir ("..") < 0)
+                         result = 1;
                    }
                }
            }
index 7fc82088ecf81588a98f4bdcb9752397c27812af..27b810073de9f2050697ce6d86ad46021154cdc5 100644 (file)
@@ -138,6 +138,28 @@ base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd
 EOF
 rm $testout
 
+curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
+cd "$tmp"
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
+    sort > $testout
+cd "$curwd"
+
+cat <<EOF | diff -u $testout - || exit 1
+base = "", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
+base = "ftwtest.d/", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
+base = "ftwtest.d/foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
+base = "ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5
+EOF
+rm $testout
+
 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --early-exit $tmpdir |
     sort > $testout
 
This page took 0.052086 seconds and 5 git commands to generate.