summary refs log tree commit diff
path: root/io/ftw.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-02-21 09:36:46 +0000
committerUlrich Drepper <drepper@redhat.com>2007-02-21 09:36:46 +0000
commit63a2f30529aca7a97f84a7f2a6f8afc40f0a3cdb (patch)
tree0c7a8b02e3f4963fd1408cecd3b506749c2489d9 /io/ftw.c
parentc8703f884991059dcaea8a78a4ae00ff7b1118eb (diff)
downloadglibc-63a2f30529aca7a97f84a7f2a6f8afc40f0a3cdb.tar.gz
glibc-63a2f30529aca7a97f84a7f2a6f8afc40f0a3cdb.tar.xz
glibc-63a2f30529aca7a97f84a7f2a6f8afc40f0a3cdb.zip
	* io/ftw.c (ftw_startup): Handle special case of FTW_CHDIR in /.
	(open_dir_stream): Likewise.
	* io/Makefile (tests): Add bug-ftw5.
	io/bug-ftw5.c: New file.
Diffstat (limited to 'io/ftw.c')
-rw-r--r--io/ftw.c28
1 files changed, 22 insertions, 6 deletions
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)