[ostree] tests: Use readdir64 when _FILE_OFFSET_BITS set



commit 2e0521804d26f0804f86fbba9d06884b82720cc8
Author: Dan Nicholson <nicholson endlessm com>
Date:   Wed Jun 3 12:34:37 2015 -0700

    tests: Use readdir64 when _FILE_OFFSET_BITS set
    
    On 32 bit systems, _FILE_OFFSET_BITS will be set to 64 by
    AC_SYS_LARGEFILE. This causes the glibc headers to use readdir64 rather
    than readdir. Emulate that behavior in the preloader or the tests will
    all fail with "No such file or directory".

 tests/readdir-rand.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/tests/readdir-rand.c b/tests/readdir-rand.c
index bf37b11..527d4a3 100644
--- a/tests/readdir-rand.c
+++ b/tests/readdir-rand.c
@@ -30,6 +30,17 @@
 #include <sys/stat.h>
 #include <glib.h>
 
+/* Glibc uses readdir64 when _FILE_OFFSET_BITS == 64 as set by
+ * AC_SYS_LARGEFILE on 32 bit systems.
+ */
+#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
+# define READDIR "readdir64"
+# define READDIR_R "readdir64_r"
+#else
+# define READDIR "readdir"
+# define READDIR_R "readdir_r"
+#endif
+
 static GHashTable *direntcache;
 static GMutex direntcache_lock;
 static gsize initialized;
@@ -69,7 +80,7 @@ ensure_initialized (void)
 struct dirent *
 readdir (DIR *dirp)
 {
-  struct dirent *(*real_readdir)(DIR *dirp) = dlsym (RTLD_NEXT, "readdir");
+  struct dirent *(*real_readdir)(DIR *dirp) = dlsym (RTLD_NEXT, READDIR);
   struct dirent *ret;
   gboolean cache_another = TRUE;
   
@@ -186,7 +197,7 @@ rewinddir (DIR *dirp)
 int
 readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
 {
-  int (*real_readdir_r)(DIR *dirp, struct dirent *entry, struct dirent **result) = dlsym (RTLD_NEXT, 
"readdir_r");
+  int (*real_readdir_r)(DIR *dirp, struct dirent *entry, struct dirent **result) = dlsym (RTLD_NEXT, 
READDIR_R);
 
   ensure_initialized ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]