changeset 31597:2d501fb60b2d

osutil: report fstype for BSD and OSX
author Jun Wu <quark@fb.com>
date Thu, 23 Mar 2017 22:13:02 -0700
parents ab51a2b18f87
children 32f09ead059b
files mercurial/osutil.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/osutil.c	Thu Mar 23 22:15:36 2017 -0700
+++ b/mercurial/osutil.c	Thu Mar 23 22:13:02 2017 -0700
@@ -27,10 +27,8 @@
 #ifdef HAVE_LINUX_MAGIC_H
 #include <linux/magic.h>
 #endif
-#ifdef HAVE_SYS_MOUNT_H
+#ifdef HAVE_BSD_STATFS
 #include <sys/mount.h>
-#endif
-#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
 #ifdef HAVE_SYS_VFS_H
@@ -801,12 +799,21 @@
 #ifdef HAVE_STATFS
 /* given a directory path, return filesystem type (best-effort), or None */
 const char *getfstype(const char *path) {
+#ifdef HAVE_BSD_STATFS
+	/* need to return a string field */
+	static struct statfs buf;
+#else
 	struct statfs buf;
+#endif
 	int r;
 	memset(&buf, 0, sizeof(buf));
 	r = statfs(path, &buf);
 	if (r != 0)
 		return NULL;
+#ifdef HAVE_BSD_STATFS
+	/* BSD or OSX provides a f_fstypename field */
+	return buf.f_fstypename;
+#endif
 	/* Begin of Linux filesystems */
 #ifdef ADFS_SUPER_MAGIC
 	if (buf.f_type == ADFS_SUPER_MAGIC)