about summary refs log tree commit diff
path: root/io
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-17 23:10:14 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-17 23:10:14 +0000
commit46089c83d119050998387d7a8fb896514c92618b (patch)
treeb314e6353836ac1c906071156cd996dd94ad7854 /io
parent0e24e73d6dfd32c842afe028d6d37e2ea3c3bd54 (diff)
downloadglibc-46089c83d119050998387d7a8fb896514c92618b.tar.gz
glibc-46089c83d119050998387d7a8fb896514c92618b.tar.xz
glibc-46089c83d119050998387d7a8fb896514c92618b.zip
Update.
2001-12-17  Ulrich Drepper  <drepper@redhat.com>

	* io/ftw.c (ftw_dir): Handle inaccessibility of toplevel dir
	different than implemented in last patch.
	* io/bug-ftw3.c: Adjust test for changed handling of
	inaccessibility of toplevel dir.
Diffstat (limited to 'io')
-rw-r--r--io/bug-ftw3.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/io/bug-ftw3.c b/io/bug-ftw3.c
index 98bb563f0c..e3f24d61e1 100644
--- a/io/bug-ftw3.c
+++ b/io/bug-ftw3.c
@@ -4,10 +4,13 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+static int cb_called;
+
 static int
 cb (const char *fname, const struct stat *st, int flag)
 {
   printf ("%s %d\n", fname, flag);
+  cb_called = 1;
   return 0;
 }
 
@@ -15,7 +18,9 @@ int
 main (void)
 {
   char tmp[] = "/tmp/ftwXXXXXX";
+  char tmp2[] = "/tmp/ftwXXXXXX/ftwXXXXXX";
   char *dname;
+  char *dname2;
   int r;
   int e;
 
@@ -26,13 +31,23 @@ main (void)
       exit (1);
     }
 
-  if (chmod (dname, S_IWUSR|S_IXUSR|S_IWGRP|S_IXGRP|S_IWOTH|S_IXOTH) != 0)
+  memcpy (tmp2, tmp, strlen (tmp));
+  dname2 = mkdtemp (tmp2);
+  if (dname2 == NULL)
+    {
+      printf ("mkdtemp: %m\n");
+      rmdir (dname);
+      exit (1);
+    }
+
+  if (chmod (dname, S_IWUSR|S_IWGRP|S_IWOTH) != 0)
     {
       printf ("chmod: %m\n");
+      rmdir (dname);
       exit (1);
     }
 
-  r = ftw (dname, cb, 10);
+  r = ftw (dname2, cb, 10);
   e = errno;
   printf ("r = %d", r);
   if (r != 0)
@@ -40,7 +55,8 @@ main (void)
   puts ("");
 
   chmod (dname, S_IRWXU|S_IRWXG|S_IRWXO);
+  rmdir (dname2);
   rmdir (dname);
 
-  return r != -1 && e == EACCES;
+  return (r != -1 && e == EACCES) || cb_called;
 }