summary refs log tree commit diff
path: root/io
diff options
context:
space:
mode:
Diffstat (limited to 'io')
-rw-r--r--io/Makefile17
-rw-r--r--io/bug-ftw5.c25
-rw-r--r--io/fstat.c12
-rw-r--r--io/fstat64.c9
-rw-r--r--io/fstatat.c9
-rw-r--r--io/fstatat64.c9
-rw-r--r--io/ftw.c28
-rw-r--r--io/lstat.c12
-rw-r--r--io/lstat64.c9
-rw-r--r--io/mknod.c12
-rw-r--r--io/mknodat.c10
-rw-r--r--io/stat.c12
-rw-r--r--io/stat64.c9
13 files changed, 141 insertions, 32 deletions
diff --git a/io/Makefile b/io/Makefile
index 18287b201a..6623551769 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1992-2002,2003,2005,2006 Free Software Foundation, Inc.
+# Copyright (C) 1992-2002,2003,2005,2006, 2007 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -66,7 +66,7 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
 		   tst-renameat tst-fchownat tst-fchmodat tst-faccessat \
 		   tst-symlinkat tst-linkat tst-readlinkat tst-mkdirat \
-		   tst-mknodat tst-mkfifoat tst-ttyname_r
+		   tst-mknodat tst-mkfifoat tst-ttyname_r bug-ftw5
 
 distribute	:= ftwtest-sh
 
@@ -90,6 +90,19 @@ CFLAGS-posix_fallocate64.c = -fexceptions
 CFLAGS-test-stat.c = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
 CFLAGS-test-lfs.c = -D_LARGEFILE64_SOURCE
 
+ifeq (yes,$(have-protected))
+CFLAGS-stat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-fstat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-lstat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-mknod.c = -DHAVE_DOT_HIDDEN
+CFLAGS-stat64.c = -DHAVE_DOT_HIDDEN
+CFLAGS-fstat64.c = -DHAVE_DOT_HIDDEN
+CFLAGS-lstat64.c = -DHAVE_DOT_HIDDEN
+CFLAGS-fstatat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-fstatat64.c = -DHAVE_DOT_HIDDEN
+CFLAGS-mknodat.c = -DHAVE_DOT_HIDDEN
+endif
+
 test-stat2-ARGS = Makefile . $(objpfx)test-stat2
 
 tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
diff --git a/io/bug-ftw5.c b/io/bug-ftw5.c
new file mode 100644
index 0000000000..c1cd81d30e
--- /dev/null
+++ b/io/bug-ftw5.c
@@ -0,0 +1,25 @@
+#include <errno.h>
+#include <ftw.h>
+#include <stdio.h>
+
+static int
+fn (const char *file, const struct stat *sb, int flag, struct FTW *s)
+{
+  puts (file);
+  return FTW_STOP;
+}
+
+static int
+do_test (void)
+{
+  if (nftw ("/", fn, 0, FTW_CHDIR | FTW_ACTIONRETVAL) < 0)
+    {
+      printf ("nftw / FTW_CHDIR: %m\n");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/io/fstat.c b/io/fstat.c
index e2f9abd384..0f95c1a6e2 100644
--- a/io/fstat.c
+++ b/io/fstat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -47,10 +47,16 @@
 #undef fstat
 #undef __fstat
 int
-attribute_hidden
 __fstat (int fd, struct stat *buf)
 {
   return __fxstat (_STAT_VER, fd, buf);
 }
 
-weak_hidden_alias (__fstat, fstat)
+weak_alias (__fstat, fstat)
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tfstat");
+asm (".hidden\t__fstat");
+#endif
diff --git a/io/fstat64.c b/io/fstat64.c
index fe655444b2..79bd967d8f 100644
--- a/io/fstat64.c
+++ b/io/fstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -46,8 +46,13 @@
 
 #undef fstat64
 int
-attribute_hidden
 fstat64 (int fd, struct stat64 *buf)
 {
   return __fxstat64 (_STAT_VER, fd, buf);
 }
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tfstat64");
+#endif
diff --git a/io/fstatat.c b/io/fstatat.c
index abf083c72e..1ac80597a0 100644
--- a/io/fstatat.c
+++ b/io/fstatat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -46,8 +46,13 @@
 
 #undef fstatat
 int
-attribute_hidden
 fstatat (int fd, const char *file, struct stat *buf, int flag)
 {
   return __fxstatat (_STAT_VER, fd, file, buf, flag);
 }
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tfstatat");
+#endif
diff --git a/io/fstatat64.c b/io/fstatat64.c
index 6fdf709af5..a14b42d42e 100644
--- a/io/fstatat64.c
+++ b/io/fstatat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -46,8 +46,13 @@
 
 #undef fstatat64
 int
-attribute_hidden
 fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
 {
   return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
 }
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tfstatat64");
+#endif
diff --git a/io/ftw.c b/io/ftw.c
index 413871744e..5495bc7ecc 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -1,5 +1,5 @@
 /* File tree walker functions.
-   Copyright (C) 1996-2003, 2004, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1996-2003, 2004, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -348,8 +348,17 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
 	}
       else
 	{
-	  const char *name = ((data->flags & FTW_CHDIR)
-			      ? data->dirbuf + data->ftw.base: data->dirbuf);
+	  const char *name;
+
+	  if (data->flags & FTW_CHDIR)
+	    {
+	      name = data->dirbuf + data->ftw.base;
+	      if (name[0] == '\0')
+		name = ".";
+	    }
+	  else
+	    name = data->dirbuf;
+
 	  dirp->stream = __opendir (name);
 	}
 
@@ -721,9 +730,16 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
   /* Get stat info for start directory.  */
   if (result == 0)
     {
-      const char *name = ((data.flags & FTW_CHDIR)
-			  ? data.dirbuf + data.ftw.base
-			  : data.dirbuf);
+      const char *name;
+
+      if (data.flags & FTW_CHDIR)
+	{
+	  name = data.dirbuf + data.ftw.base;
+	  if (name[0] == '\0')
+	    name = ".";
+	}
+      else
+	name = data.dirbuf;
 
       if (((flags & FTW_PHYS)
 	   ? LXSTAT (_STAT_VER, name, &st)
diff --git a/io/lstat.c b/io/lstat.c
index 620e47877a..c4d7abe2c2 100644
--- a/io/lstat.c
+++ b/io/lstat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -47,10 +47,16 @@
 #undef lstat
 #undef __lstat
 int
-attribute_hidden
 __lstat (const char *file, struct stat *buf)
 {
   return __lxstat (_STAT_VER, file, buf);
 }
 
-weak_hidden_alias (__lstat, lstat)
+weak_alias (__lstat, lstat)
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tlstat");
+asm (".hidden\t__lstat");
+#endif
diff --git a/io/lstat64.c b/io/lstat64.c
index 3e4ba2d972..8a994e4867 100644
--- a/io/lstat64.c
+++ b/io/lstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -46,8 +46,13 @@
 
 #undef lstat64
 int
-attribute_hidden
 lstat64 (const char *file, struct stat64 *buf)
 {
   return __lxstat64 (_STAT_VER, file, buf);
 }
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tlstat64");
+#endif
diff --git a/io/mknod.c b/io/mknod.c
index cc5fd26105..7d43593a25 100644
--- a/io/mknod.c
+++ b/io/mknod.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -47,10 +47,16 @@
    all callers.  */
 
 int
-attribute_hidden
 __mknod (const char *path, mode_t mode, dev_t dev)
 {
   return __xmknod (_MKNOD_VER, path, mode, &dev);
 }
 
-weak_hidden_alias (__mknod, mknod)
+weak_alias (__mknod, mknod)
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tmknod");
+asm (".hidden\t__mknod");
+#endif
diff --git a/io/mknodat.c b/io/mknodat.c
index b02ba695f9..ac515b5b48 100644
--- a/io/mknodat.c
+++ b/io/mknodat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 2001, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 2001, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -47,8 +47,14 @@
    all callers.  */
 
 int
-attribute_hidden
 mknodat (int fd, const char *path, mode_t mode, dev_t dev)
 {
   return __xmknodat (_MKNOD_VER, fd, path, mode, &dev);
 }
+
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tmknodat");
+#endif
diff --git a/io/stat.c b/io/stat.c
index 6f1c28fc56..6af604957e 100644
--- a/io/stat.c
+++ b/io/stat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -46,10 +46,16 @@
 
 #undef stat
 int
-attribute_hidden
 __stat (const char *file, struct stat *buf)
 {
   return __xstat (_STAT_VER, file, buf);
 }
 
-weak_hidden_alias (__stat, stat)
+weak_alias (__stat, stat)
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tstat");
+asm (".hidden\t__stat");
+#endif
diff --git a/io/stat64.c b/io/stat64.c
index 14e036a700..cadf1e1f1d 100644
--- a/io/stat64.c
+++ b/io/stat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -46,8 +46,13 @@
 
 #undef stat64
 int
-attribute_hidden
 stat64 (const char *file, struct stat64 *buf)
 {
   return __xstat64 (_STAT_VER, file, buf);
 }
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tstat64");
+#endif