about summary refs log tree commit diff
path: root/sysdeps/generic/glob.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-02-13 22:17:17 +0000
committerUlrich Drepper <drepper@redhat.com>2001-02-13 22:17:17 +0000
commit2958e6cc5f39ac2487b4fcbc2db48462a34ce23d (patch)
tree6a55d2abeae2e9ba1b5412c591743fdd733832ab /sysdeps/generic/glob.c
parentf1a26a85046fa11da2ea51aa6d4edfbfc8549c39 (diff)
downloadglibc-2958e6cc5f39ac2487b4fcbc2db48462a34ce23d.tar.gz
glibc-2958e6cc5f39ac2487b4fcbc2db48462a34ce23d.tar.xz
glibc-2958e6cc5f39ac2487b4fcbc2db48462a34ce23d.zip
Update.
	* io/ftw.c: Always use readdir64.
	* io/ftw64.c: Likewise.
	* sysdeps/unix/sysv/linux/ttyname.c: Likewise.
	* sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
	* sysdeps/generic/glob.c: Likewise.  Convert results if gl_readdir
	callback to dirent.  Still allow compiling outside glibc.
	* sysdeps/gnu/glob64.c: Define COMPILE_GLOB64.
	* sysdeps/unix/sysv/linux/i386/glob64.c: Likewise.

	* malloc/mtrace.c: Use fopen64.
	* posix/spawni.c: Use __open64.
	* sysdeps/unix/opendir.c: Likewise.
	* sysdeps/unix/sysv/linux/gethostid.c: Likewise.

	* sysdeps/generic/ftruncate64.c: Define __ftruncate64 and make old
	name a weak alias.
	* sysdeps/unix/sysv/aix/ftruncate64.c: Likewise.
	* sysdeps/unix/sysv/linux/ftruncate64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/ftruncate64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ftruncate64.c: Likewise.

	* resolv/res_data.c: Add cast to avoid warning.

	* include/unistd.h: Declare __ftruncate64.

	* sysdeps/generic/utmp_file.c: Use LFS functions and type.
Diffstat (limited to 'sysdeps/generic/glob.c')
-rw-r--r--sysdeps/generic/glob.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index fd7e149539..3357bb3d17 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
@@ -121,6 +121,40 @@ extern int errno;
 # define HAVE_D_TYPE	1
 #endif
 
+#if _LIBC
+# define HAVE_DIRENT64	1
+#endif
+
+/* If the system has the `struct dirent64' type we use it internally.  */
+#if defined HAVE_DIRENT64 && !defined COMPILE_GLOB64
+# if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
+#  define CONVERT_D_NAMLEN(d64, d32)
+# else
+#  define CONVERT_D_NAMLEN(d64, d32) \
+  (d64)->d_namlen = (d32)->d_namlen;
+# endif
+
+# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
+#  define CONVERT_D_INO(d64, d32)
+# else
+#  define CONVERT_D_INO(d64, d32) \
+  (d64)->d_ino = (d32)->d_ino;
+# endif
+
+# ifdef HAVE_D_TYPE
+#  define CONVERT_D_TYPE(d64, d32) \
+  (d64)->d_type = (d32)->d_type;
+# else
+#  define CONVERT_D_TYPE(d64, d32)
+# endif
+
+# define CONVERT_DIRENT_DIRENT64(d64, d32) \
+  memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32));			      \
+  CONVERT_D_NAMLEN (d64, d32)						      \
+  CONVERT_D_INO (d64, d32)						      \
+  CONVERT_D_TYPE (d64, d32)
+#endif
+
 
 #if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
 /* Posix does not require that the d_ino field be present, and some
@@ -246,7 +280,7 @@ extern char *alloca ();
 # define sysconf(id) __sysconf (id)
 # define closedir(dir) __closedir (dir)
 # define opendir(name) __opendir (name)
-# define readdir(str) __readdir (str)
+# define readdir(str) __readdir64 (str)
 # define getpwnam_r(name, bufp, buf, len, res) \
    __getpwnam_r (name, bufp, buf, len, res)
 # ifndef __stat64
@@ -1339,10 +1373,29 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
 		{
 		  const char *name;
 		  size_t len;
-		  struct dirent *d =
-		    ((flags & GLOB_ALTDIRFUNC)
-		     ? (struct dirent *)((*pglob->gl_readdir) (stream))
-		     : readdir ((DIR *) stream));
+#if defined HAVE_DIRENT64 && !defined COMPILE_GLOB64
+		  struct dirent64 *d;
+		  struct dirent64 d64;
+
+		  if (flags & GLOB_ALTDIRFUNC)
+		    {
+		      struct dirent *d32 = (*pglob->gl_readdir) (stream);
+		      if (d32 != NULL)
+			{
+			  CONVERT_DIRENT_DIRENT64 (&d64, d32);
+			  d = &d64;
+			}
+		      else
+			d = NULL;
+		    }
+		  else
+		    d = __readdir64 ((DIR *) stream);
+#else
+		  struct dirent *d = ((flags & GLOB_ALTDIRFUNC)
+				      ? ((struct dirent *)
+					 (*pglob->gl_readdir) (stream))
+				      : __readdir ((DIR *) stream));
+#endif
 		  if (d == NULL)
 		    break;
 		  if (! REAL_DIR_ENTRY (d))