Mercurial > hg
diff mercurial/osutil.c @ 31622:2243ba216f66
statfs: change Linux feature detection
Previously we check three things: "statfs" function, "linux/magic.h" and
"sys/vfs.h" headers. But we didn't check "struct statfs" or the "f_type"
field. That means if a system has "statfs" but "struct statfs" is not
defined in the two header files we check, or defined without the "f_type"
field, the compilation will fail.
This patch combines the checks (2 headers + 1 function + 1 field) together
and sets "HAVE_LINUX_STATFS". It makes setup.py faster (less checks), and
more reliable (immutable to the issue above).
author | Jun Wu <quark@fb.com> |
---|---|
date | Fri, 24 Mar 2017 14:59:19 -0700 |
parents | 2d501fb60b2d |
children | a01e1132f6fa |
line wrap: on
line diff
--- a/mercurial/osutil.c Fri Mar 24 16:20:10 2017 -0700 +++ b/mercurial/osutil.c Fri Mar 24 14:59:19 2017 -0700 @@ -24,16 +24,14 @@ #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> -#ifdef HAVE_LINUX_MAGIC_H +#ifdef HAVE_LINUX_STATFS #include <linux/magic.h> +#include <sys/vfs.h> #endif #ifdef HAVE_BSD_STATFS #include <sys/mount.h> #include <sys/param.h> #endif -#ifdef HAVE_SYS_VFS_H -#include <sys/vfs.h> -#endif #endif #ifdef __APPLE__ @@ -796,7 +794,7 @@ } #endif /* ndef SETPROCNAME_USE_NONE */ -#ifdef HAVE_STATFS +#if defined(HAVE_BSD_STATFS) || defined(HAVE_LINUX_STATFS) /* given a directory path, return filesystem type (best-effort), or None */ const char *getfstype(const char *path) { #ifdef HAVE_BSD_STATFS @@ -810,10 +808,10 @@ r = statfs(path, &buf); if (r != 0) return NULL; -#ifdef HAVE_BSD_STATFS +#if defined(HAVE_BSD_STATFS) /* BSD or OSX provides a f_fstypename field */ return buf.f_fstypename; -#endif +#elif defined(HAVE_LINUX_STATFS) /* Begin of Linux filesystems */ #ifdef ADFS_SUPER_MAGIC if (buf.f_type == ADFS_SUPER_MAGIC) @@ -1084,6 +1082,7 @@ return "xfs"; #endif /* End of Linux filesystems */ +#endif /* def HAVE_LINUX_STATFS */ return NULL; } @@ -1100,7 +1099,7 @@ PyObject *result = Py_BuildValue("s", type); return result; } -#endif /* def HAVE_STATFS */ +#endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */ #endif /* ndef _WIN32 */ @@ -1278,7 +1277,7 @@ {"setprocname", (PyCFunction)setprocname, METH_VARARGS, "set process title (best-effort)\n"}, #endif -#ifdef HAVE_STATFS +#if defined(HAVE_BSD_STATFS) || defined(HAVE_LINUX_STATFS) {"getfstype", (PyCFunction)pygetfstype, METH_VARARGS, "get filesystem type (best-effort)\n"}, #endif