llvm.org GIT mirror llvm / 39b10e9
[Support] Provide linux/magic.h fallback for older kernels The function for distinguishing local and remote files added in r295768 unconditionally uses linux/magic.h header to provide necessary filesystem magic numbers. However, in kernel headers predating 2.6.18 the magic numbers are spread throughout multiple include files. Furthermore, LLVM did not require kernel headers being installed so far. To increase the portability across different versions of Linux kernel and different Linux systems, add CMake header checks for linux/magic.h and -- if it is missing -- the linux/nfs_fs.h and linux/smb.h headers which contained the numbers previously. Furthermore, since the numbers are static and the feature does not seem critical enough to make LLVM require kernel headers at all, add fallback constants for the case when none of the necessary headers is available. Differential Revision: https://reviews.llvm.org/D30261 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295854 91177308-0d34-0410-b5e6-96231b3b80d8 Michal Gorny 3 years ago
2 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8585 asm(\".desc ___crashreporter_info__, 0x10\");
8686 int main() { return 0; }"
8787 HAVE_CRASHREPORTER_INFO)
88 endif()
89
90 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
91 check_include_file(linux/magic.h HAVE_LINUX_MAGIC_H)
92 if(NOT HAVE_LINUX_MAGIC_H)
93 # older kernels use split files
94 check_include_file(linux/nfs_fs.h HAVE_LINUX_NFS_FS_H)
95 check_include_file(linux/smb.h HAVE_LINUX_SMB_H)
96 endif()
8897 endif()
8998
9099 # library checks
7575 #include
7676 #include
7777 #elif defined(__linux__)
78 #if defined(HAVE_LINUX_MAGIC_H)
7879 #include
80 #else
81 #if defined(HAVE_LINUX_NFS_FS_H)
82 #include
83 #endif
84 #if defined(HAVE_LINUX_SMB_H)
85 #include
86 #endif
87 #endif
7988 #include
8089 #else
8190 #include
345354
346355 static bool is_local_impl(struct STATVFS &Vfs) {
347356 #if defined(__linux__)
357 #ifndef NFS_SUPER_MAGIC
358 #define NFS_SUPER_MAGIC 0x6969
359 #endif
360 #ifndef SMB_SUPER_MAGIC
361 #define SMB_SUPER_MAGIC 0x517B
362 #endif
348363 #ifndef CIFS_MAGIC_NUMBER
349364 #define CIFS_MAGIC_NUMBER 0xFF534D42
350365 #endif