]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid false failure on 32 bit in readdir() test
authorPádraig Brady <P@draigBrady.com>
Wed, 6 Jul 2016 17:08:32 +0000 (18:08 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 6 Jul 2016 17:13:08 +0000 (18:13 +0100)
* tests/rm/rm-readdir-fail.sh: Since we use the returned dirent
from the readdir wrapper it must be the correct type and not
just cast.  Therefore setup so that we only have to define a
wrapper for readdir(), which works appropriately on 32 and 64 bit.
Issue reported by Bernhard Voelker, where rm was seen to invoke
rmdir() on invalid file names.

tests/rm/rm-readdir-fail.sh

index 15ef1d6c44fcf536324102f8c87d078b6dbbde40..d9d8efdb4dea155a536b62ee15337c2701ac10bc 100755 (executable)
@@ -26,6 +26,12 @@ mkdir -p dir/notempty || framework_failure_
 # Simulate "readdir" failure.
 cat > k.c <<\EOF || framework_failure_
 #define _GNU_SOURCE
+
+/* Setup so we don't have to worry about readdir64.  */
+#ifndef __LP64__
+# define _FILE_OFFSET_BITS 64
+#endif
+
 #include <dlfcn.h>
 #include <dirent.h>
 #include <errno.h>
@@ -72,11 +78,6 @@ struct dirent *readdir (DIR *dirp)
   errno = ENOENT;
   return NULL;
 }
-
-struct dirent64 *readdir64 (DIR *dirp)
-{
-  return (struct dirent64 *) readdir (dirp);
-}
 EOF
 
 # Then compile/link it: