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
This commit is contained in:
commit
ab8cabb1ca
@ -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 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user