##// END OF EJS Templates
statfs: change Linux feature detection...
Jun Wu -
r31622:2243ba21 default
parent child Browse files
Show More
@@ -24,16 +24,14 b''
24 24 #include <sys/stat.h>
25 25 #include <sys/types.h>
26 26 #include <unistd.h>
27 #ifdef HAVE_LINUX_MAGIC_H
27 #ifdef HAVE_LINUX_STATFS
28 28 #include <linux/magic.h>
29 #include <sys/vfs.h>
29 30 #endif
30 31 #ifdef HAVE_BSD_STATFS
31 32 #include <sys/mount.h>
32 33 #include <sys/param.h>
33 34 #endif
34 #ifdef HAVE_SYS_VFS_H
35 #include <sys/vfs.h>
36 #endif
37 35 #endif
38 36
39 37 #ifdef __APPLE__
@@ -796,7 +794,7 b' static PyObject *setprocname(PyObject *s'
796 794 }
797 795 #endif /* ndef SETPROCNAME_USE_NONE */
798 796
799 #ifdef HAVE_STATFS
797 #if defined(HAVE_BSD_STATFS) || defined(HAVE_LINUX_STATFS)
800 798 /* given a directory path, return filesystem type (best-effort), or None */
801 799 const char *getfstype(const char *path) {
802 800 #ifdef HAVE_BSD_STATFS
@@ -810,10 +808,10 b' const char *getfstype(const char *path) '
810 808 r = statfs(path, &buf);
811 809 if (r != 0)
812 810 return NULL;
813 #ifdef HAVE_BSD_STATFS
811 #if defined(HAVE_BSD_STATFS)
814 812 /* BSD or OSX provides a f_fstypename field */
815 813 return buf.f_fstypename;
816 #endif
814 #elif defined(HAVE_LINUX_STATFS)
817 815 /* Begin of Linux filesystems */
818 816 #ifdef ADFS_SUPER_MAGIC
819 817 if (buf.f_type == ADFS_SUPER_MAGIC)
@@ -1084,6 +1082,7 b' const char *getfstype(const char *path) '
1084 1082 return "xfs";
1085 1083 #endif
1086 1084 /* End of Linux filesystems */
1085 #endif /* def HAVE_LINUX_STATFS */
1087 1086 return NULL;
1088 1087 }
1089 1088
@@ -1100,7 +1099,7 b' static PyObject *pygetfstype(PyObject *s'
1100 1099 PyObject *result = Py_BuildValue("s", type);
1101 1100 return result;
1102 1101 }
1103 #endif /* def HAVE_STATFS */
1102 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */
1104 1103
1105 1104 #endif /* ndef _WIN32 */
1106 1105
@@ -1278,7 +1277,7 b' static PyMethodDef methods[] = {'
1278 1277 {"setprocname", (PyCFunction)setprocname, METH_VARARGS,
1279 1278 "set process title (best-effort)\n"},
1280 1279 #endif
1281 #ifdef HAVE_STATFS
1280 #if defined(HAVE_BSD_STATFS) || defined(HAVE_LINUX_STATFS)
1282 1281 {"getfstype", (PyCFunction)pygetfstype, METH_VARARGS,
1283 1282 "get filesystem type (best-effort)\n"},
1284 1283 #endif
@@ -591,24 +591,21 b' osutil_cflags = []'
591 591 osutil_ldflags = []
592 592
593 593 # platform specific macros
594 for plat, func in [('bsd', 'setproctitle'), ('bsd|darwin|linux', 'statfs')]:
594 for plat, func in [('bsd', 'setproctitle')]:
595 595 if re.search(plat, sys.platform) and hasfunction(new_compiler(), func):
596 596 osutil_cflags.append('-DHAVE_%s' % func.upper())
597 597
598 for plat, header in [
599 ('linux', 'linux/magic.h'),
600 ('linux', 'sys/vfs.h'),
601 ]:
602 if re.search(plat, sys.platform) and hasheader(new_compiler(), header):
603 macro = header.replace('/', '_').replace('.', '_').upper()
604 osutil_cflags.append('-DHAVE_%s' % macro)
605
606 598 for plat, macro, code in [
607 599 ('bsd|darwin', 'BSD_STATFS', '''
608 600 #include <sys/param.h>
609 601 #include <sys/mount.h>
610 602 int main() { struct statfs s; return sizeof(s.f_fstypename); }
611 603 '''),
604 ('linux', 'LINUX_STATFS', '''
605 #include <linux/magic.h>
606 #include <sys/vfs.h>
607 int main() { struct statfs s; return sizeof(s.f_type); }
608 '''),
612 609 ]:
613 610 if re.search(plat, sys.platform) and cancompile(new_compiler(), code):
614 611 osutil_cflags.append('-DHAVE_%s' % macro)
General Comments 0
You need to be logged in to leave comments. Login now