[PATCH 2 of 3] osutil: report fstype for BSD and OSX

Jun Wu quark at fb.com
Fri Mar 24 01:32:53 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1490332382 25200
#      Thu Mar 23 22:13:02 2017 -0700
# Node ID 825bb185512c66a43ae6927933196b8356c99798
# Parent  597a29c947fe2b9f9ac0a6a03cf710ab9f69757c
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 825bb185512c
osutil: report fstype for BSD and OSX

diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -28,8 +28,6 @@
 #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
@@ -802,5 +800,10 @@ static PyObject *setprocname(PyObject *s
 /* 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));
@@ -808,4 +811,8 @@ const char *getfstype(const char *path) 
 	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


More information about the Mercurial-devel mailing list