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.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-05-20 19:36:36 +00:00
parent 2019f75c32
commit 7340012337
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=348007

View File

@ -37,9 +37,25 @@ __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 char fusefs[] = "fusefs";
const char fusefs_dot[] = "fusefs.";
return (strncmp(fsname, fusefs_dot, strlen(fusefs_dot)) == 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,9 @@ 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);