Author: asomers
Date: Thu Jul 25 03:55:05 2019
New Revision: 350314
URL: https://svnweb.freebsd.org/changeset/base/350314

Log:
  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
  MFC after:    2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D21043

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

Modified: head/lib/libc/gen/getvfsbyname.c
==============================================================================
--- head/lib/libc/gen/getvfsbyname.c    Thu Jul 25 03:47:27 2019        
(r350313)
+++ head/lib/libc/gen/getvfsbyname.c    Thu Jul 25 03:55:05 2019        
(r350314)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to