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

Yuya Nishihara yuya at tcha.org
Fri Mar 24 10:39:02 EDT 2017


On Thu, 23 Mar 2017 22:32:53 -0700, Jun Wu wrote:
> # 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

Nit: I prefer moving the stack allocation of struct statfs to caller. We might
blindly port getfstype() to cffi module and get in trouble due to the static
storage.


More information about the Mercurial-devel mailing list