[PATCH] D30261: [Support] Provide linux/magic.h fallback for older kernels

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 10:21:00 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL295854: [Support] Provide linux/magic.h fallback for older kernels (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D30261?vs=89371&id=89377#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30261

Files:
  llvm/trunk/cmake/config-ix.cmake
  llvm/trunk/lib/Support/Unix/Path.inc


Index: llvm/trunk/cmake/config-ix.cmake
===================================================================
--- llvm/trunk/cmake/config-ix.cmake
+++ llvm/trunk/cmake/config-ix.cmake
@@ -88,6 +88,15 @@
     HAVE_CRASHREPORTER_INFO)
 endif()
 
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+  check_include_file(linux/magic.h HAVE_LINUX_MAGIC_H)
+  if(NOT HAVE_LINUX_MAGIC_H)
+    # older kernels use split files
+    check_include_file(linux/nfs_fs.h HAVE_LINUX_NFS_FS_H)
+    check_include_file(linux/smb.h HAVE_LINUX_SMB_H)
+  endif()
+endif()
+
 # library checks
 if( NOT PURE_WINDOWS )
   check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
Index: llvm/trunk/lib/Support/Unix/Path.inc
===================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc
+++ llvm/trunk/lib/Support/Unix/Path.inc
@@ -76,7 +76,16 @@
 #include <sys/param.h>
 #include <sys/mount.h>
 #elif defined(__linux__)
+#if defined(HAVE_LINUX_MAGIC_H)
 #include <linux/magic.h>
+#else
+#if defined(HAVE_LINUX_NFS_FS_H)
+#include <linux/nfs_fs.h>
+#endif
+#if defined(HAVE_LINUX_SMB_H)
+#include <linux/smb.h>
+#endif
+#endif
 #include <sys/vfs.h>
 #else
 #include <sys/mount.h>
@@ -346,6 +355,12 @@
 
 static bool is_local_impl(struct STATVFS &Vfs) {
 #if defined(__linux__)
+#ifndef NFS_SUPER_MAGIC
+#define NFS_SUPER_MAGIC 0x6969
+#endif
+#ifndef SMB_SUPER_MAGIC
+#define SMB_SUPER_MAGIC 0x517B
+#endif
 #ifndef CIFS_MAGIC_NUMBER
 #define CIFS_MAGIC_NUMBER 0xFF534D42
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30261.89377.patch
Type: text/x-patch
Size: 1499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/c47892d2/attachment.bin>


More information about the llvm-commits mailing list