Patchwork statfs: detect more filesystems on Linux

login
register
mail settings
Submitter Jun Wu
Date March 25, 2017, 8:06 p.m.
Message ID <99337cfe021d5222a942.1490472413@localhost.localdomain>
Download mbox | patch
Permalink /patch/19672/
State Accepted
Headers show

Comments

Jun Wu - March 25, 2017, 8:06 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490471935 25200
#      Sat Mar 25 12:58:55 2017 -0700
# Node ID 99337cfe021d5222a9420ae0d7e9b29c2d03573b
# Parent  c60091fa1426892552dd6c0dd4b9c49e3c3da045
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 99337cfe021d
statfs: detect more filesystems on Linux

Previously, the code only has what manpager says. In <linux/magic.h>, there
are more defined. This patch adds filesystems that appear in the current
Arch Linux's /proc/filesystems (autofs, overlay, securityfs) and f2fs, which
was seen in news.
Yuya Nishihara - March 26, 2017, 11:29 a.m.
On Sat, 25 Mar 2017 13:06:53 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1490471935 25200
> #      Sat Mar 25 12:58:55 2017 -0700
> # Node ID 99337cfe021d5222a9420ae0d7e9b29c2d03573b
> # Parent  c60091fa1426892552dd6c0dd4b9c49e3c3da045
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 99337cfe021d
> statfs: detect more filesystems on Linux

Queued, thanks.

> +#ifdef OVERLAYFS_SUPER_MAGIC
> +	if (pbuf->f_type == OVERLAYFS_SUPER_MAGIC)
> +		return "overlay";
> +#endif

Confirmed this should have no "fs" suffix.

Patch

diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -816,4 +816,8 @@  const char *getfstype(const char *path, 
 		return "affs";
 #endif
+#ifdef AUTOFS_SUPER_MAGIC
+	if (pbuf->f_type == AUTOFS_SUPER_MAGIC)
+		return "autofs";
+#endif
 #ifdef BDEVFS_MAGIC
 	if (pbuf->f_type == BDEVFS_MAGIC)
@@ -896,4 +900,8 @@  const char *getfstype(const char *path, 
 		return "ext4";
 #endif
+#ifdef F2FS_SUPER_MAGIC
+	if (pbuf->f_type == F2FS_SUPER_MAGIC)
+		return "f2fs";
+#endif
 #ifdef FUSE_SUPER_MAGIC
 	if (pbuf->f_type == FUSE_SUPER_MAGIC)
@@ -976,4 +984,8 @@  const char *getfstype(const char *path, 
 		return "openprom";
 #endif
+#ifdef OVERLAYFS_SUPER_MAGIC
+	if (pbuf->f_type == OVERLAYFS_SUPER_MAGIC)
+		return "overlay";
+#endif
 #ifdef PIPEFS_MAGIC
 	if (pbuf->f_type == PIPEFS_MAGIC)
@@ -1008,4 +1020,8 @@  const char *getfstype(const char *path, 
 		return "romfs";
 #endif
+#ifdef SECURITYFS_MAGIC
+	if (pbuf->f_type == SECURITYFS_MAGIC)
+		return "securityfs";
+#endif
 #ifdef SELINUX_MAGIC
 	if (pbuf->f_type == SELINUX_MAGIC)