Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Sep 2019 19:07:34 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r351955 - stable/12/lib/libc/gen
Message-ID:  <201909061907.x86J7YCv049662@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Fri Sep  6 19:07:34 2019
New Revision: 351955
URL: https://svnweb.freebsd.org/changeset/base/351955

Log:
  MFC r350314:
  
  special-case getvfsbyname(3) for fusefs(5)
  
  fusefs file systems may have a fsname subtype (set by mount_fusefs's "-o
  subtype" option) that gets appended to the fsname as returned by statfs(2).
  The subtype is set on a per-mount basis so it isn't part of the struct
  vfsconf. Special-case getvfsbyname to match either the full "fusefs.foobar"
  or short "fusefs" fsname.
  
  This is a merge of r348007, r348054, and r350093 from projects/fuse2
  
  Reviewed by:	kib
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21043

Modified:
  stable/12/lib/libc/gen/getvfsbyname.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/gen/getvfsbyname.c
==============================================================================
--- stable/12/lib/libc/gen/getvfsbyname.c	Fri Sep  6 19:05:01 2019	(r351954)
+++ stable/12/lib/libc/gen/getvfsbyname.c	Fri Sep  6 19:07:34 2019	(r351955)
@@ -37,10 +37,26 @@ __FBSDID("$FreeBSD$");
 #include <sys/mount.h>
 #include <sys/sysctl.h>
 #include <errno.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 
 /*
+ * fusefs(5) file systems may have a "subtype" which gets appended to
+ * statfs(2)'s f_fstypename field on a per-mount basis.  Allow getvfsbyname to
+ * match either the full "fusefs.foobar" or the more general "fusefs".
+ */
+static bool
+are_fusefs(const char *fsname, const char *vfc_name)
+{
+	const static char fusefs[] = "fusefs";
+	const static char fusefs_dot[] = "fusefs.";
+
+	return (strncmp(fsname, fusefs_dot, sizeof(fusefs_dot) - 1) == 0 &&
+	    strcmp(fusefs, vfc_name) == 0);
+}
+
+/*
  * Given a filesystem name, determine if it is resident in the kernel,
  * and if it is resident, return its xvfsconf structure.
  */
@@ -62,7 +78,8 @@ getvfsbyname(const char *fsname, struct xvfsconf *vfcp
 	}
 	cnt = buflen / sizeof(struct xvfsconf);
 	for (i = 0; i < cnt; i++) {
-		if (strcmp(fsname, xvfsp[i].vfc_name) == 0) {
+		if (strcmp(fsname, xvfsp[i].vfc_name) == 0 ||
+		    are_fusefs(fsname, xvfsp[i].vfc_name)) {
 			memcpy(vfcp, xvfsp + i, sizeof(struct xvfsconf));
 			free(xvfsp);
 			return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909061907.x86J7YCv049662>