##// END OF EJS Templates
osutil: report fstype for BSD and OSX
Jun Wu -
r31597:2d501fb6 default
parent child Browse files
Show More
@@ -27,10 +27,8 b''
27 #ifdef HAVE_LINUX_MAGIC_H
27 #ifdef HAVE_LINUX_MAGIC_H
28 #include <linux/magic.h>
28 #include <linux/magic.h>
29 #endif
29 #endif
30 #ifdef HAVE_SYS_MOUNT_H
30 #ifdef HAVE_BSD_STATFS
31 #include <sys/mount.h>
31 #include <sys/mount.h>
32 #endif
33 #ifdef HAVE_SYS_PARAM_H
34 #include <sys/param.h>
32 #include <sys/param.h>
35 #endif
33 #endif
36 #ifdef HAVE_SYS_VFS_H
34 #ifdef HAVE_SYS_VFS_H
@@ -801,12 +799,21 b' static PyObject *setprocname(PyObject *s'
801 #ifdef HAVE_STATFS
799 #ifdef HAVE_STATFS
802 /* given a directory path, return filesystem type (best-effort), or None */
800 /* given a directory path, return filesystem type (best-effort), or None */
803 const char *getfstype(const char *path) {
801 const char *getfstype(const char *path) {
802 #ifdef HAVE_BSD_STATFS
803 /* need to return a string field */
804 static struct statfs buf;
805 #else
804 struct statfs buf;
806 struct statfs buf;
807 #endif
805 int r;
808 int r;
806 memset(&buf, 0, sizeof(buf));
809 memset(&buf, 0, sizeof(buf));
807 r = statfs(path, &buf);
810 r = statfs(path, &buf);
808 if (r != 0)
811 if (r != 0)
809 return NULL;
812 return NULL;
813 #ifdef HAVE_BSD_STATFS
814 /* BSD or OSX provides a f_fstypename field */
815 return buf.f_fstypename;
816 #endif
810 /* Begin of Linux filesystems */
817 /* Begin of Linux filesystems */
811 #ifdef ADFS_SUPER_MAGIC
818 #ifdef ADFS_SUPER_MAGIC
812 if (buf.f_type == ADFS_SUPER_MAGIC)
819 if (buf.f_type == ADFS_SUPER_MAGIC)
General Comments 0
You need to be logged in to leave comments. Login now