Blame SOURCES/coreutils-8.22-xfsbuildfailure.patch

f180de
From eafaa2e88f7af16756142a31ab63d032b31395e3 Mon Sep 17 00:00:00 2001
f180de
From: Pádraig Brady <P@draigBrady.com>
f180de
Date: Fri, 06 Nov 2015 16:31:22 +0000
f180de
Subject: tests: fix dirent d_type support verification
f180de
f180de
* tests/d_type-check: Check also the d_type of files,
f180de
which excludes XFS appropriately.  Specify all argument
f180de
and return types to avoid truncated pointers being passed,
f180de
which skipped the test due to crashes on x86_64 at least.
f180de
Simplify the C library lookup by reusing the interpreter's.
f180de
f180de
chroot issue reported at https://bugzilla.redhat.com/1263341
f180de
---
f180de
diff --git a/tests/d_type-check b/tests/d_type-check
f180de
index ff1eb60..1a2f76f 100644
f180de
--- a/tests/d_type-check
f180de
+++ b/tests/d_type-check
f180de
@@ -1,13 +1,17 @@
f180de
 #!/usr/bin/python
f180de
-# Exit 0 if "." has useful d_type information, else 1.
f180de
+# Exit 0 if "." and "./tempfile" have useful d_type information, else 1.
f180de
 # Intended to exit 0 only on Linux/GNU systems.
f180de
+import os
f180de
 import sys
f180de
+import tempfile
f180de
 
f180de
 fail = 1
f180de
+fname = None
f180de
+
f180de
 try:
f180de
   import ctypes
f180de
 
f180de
-  (DT_UNKNOWN, DT_DIR,) = (0, 4,)
f180de
+  (DT_UNKNOWN, DT_DIR, DT_REG) = (0, 4, 8)
f180de
 
f180de
   class dirent(ctypes.Structure):
f180de
     _fields_ = [
f180de
@@ -17,20 +21,48 @@ try:
f180de
       ("d_type", ctypes.c_ubyte),
f180de
       ("d_name", ctypes.c_char*256)]
f180de
 
f180de
+  # Pass NULL to dlopen, assuming the python
f180de
+  # interpreter is linked with the C runtime
f180de
+  libc = ctypes.CDLL(None)
f180de
+
f180de
+  # Setup correct types for all args and returns
f180de
+  # even if only passing, to avoid truncation etc.
f180de
+  dirp = ctypes.c_void_p
f180de
   direntp = ctypes.POINTER(dirent)
f180de
 
f180de
-  # FIXME: find a way to avoid hard-coding libc's so-name.
f180de
-  libc = ctypes.cdll.LoadLibrary("libc.so.6")
f180de
+  libc.readdir.argtypes = [dirp]
f180de
   libc.readdir.restype = direntp
f180de
 
f180de
+  libc.opendir.restype = dirp
f180de
+
f180de
+  # Ensure a file is present
f180de
+  f, fname = tempfile.mkstemp(dir='.')
f180de
+  fname = os.path.basename(fname)
f180de
+
f180de
   dirp = libc.opendir(".")
f180de
   if dirp:
f180de
-    ep = libc.readdir(dirp)
f180de
-    if ep:
f180de
+    while True:
f180de
+      ep = libc.readdir(dirp)
f180de
+      if not ep: break
f180de
+      d_type = ep.contents.d_type
f180de
       name = ep.contents.d_name
f180de
-      if (name == "." or name == "..") and ep.contents.d_type == DT_DIR:
f180de
+      if name == "." or name == "..":
f180de
+        if d_type != DT_DIR: break
f180de
+      # Check files too since on XFS, only dirs have DT_DIR
f180de
+      # while everything else has DT_UNKNOWN
f180de
+      elif name == fname:
f180de
+        if d_type == DT_REG:
f180de
+          fail = 0
f180de
+        break
f180de
+      elif d_type != DT_DIR and d_type != DT_UNKNOWN:
f180de
         fail = 0
f180de
+        break
f180de
+except:
f180de
+  pass
f180de
 
f180de
+try:
f180de
+  if fname:
f180de
+    os.unlink(fname);
f180de
 except:
f180de
   pass
f180de
 
f180de
--
f180de
cgit v0.9.0.2