remove unused fuse subtype support
parent
434ae034a0
commit
f56ee252c7
|
@ -375,7 +375,6 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
|
|||
const char *s;
|
||||
char *d;
|
||||
char *fsname = NULL;
|
||||
char *subtype = NULL;
|
||||
char *source = NULL;
|
||||
char *type = NULL;
|
||||
int blkdev = 0;
|
||||
|
@ -389,14 +388,10 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
|
|||
for (s = opts, d = optbuf; *s;) {
|
||||
unsigned len;
|
||||
const char *fsname_str = "fsname=";
|
||||
const char *subtype_str = "subtype=";
|
||||
for (len = 0; s[len] && s[len] != ','; len++);
|
||||
if (begins_with(s, fsname_str)) {
|
||||
if (!get_string_opt(s, len, fsname_str, &fsname))
|
||||
goto err;
|
||||
} else if (begins_with(s, subtype_str)) {
|
||||
if (!get_string_opt(s, len, subtype_str, &subtype))
|
||||
goto err;
|
||||
} else if (opt_eq(s, len, "blkdev")) {
|
||||
blkdev = 1;
|
||||
} else if (!begins_with(s, "fd=") &&
|
||||
|
@ -448,38 +443,22 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
|
|||
sprintf(d, "fd=%i,rootmode=%o,user_id=%i,group_id=%i",
|
||||
fd, rootmode, getuid(), getgid());
|
||||
|
||||
source = malloc((fsname ? strlen(fsname) : 0) +
|
||||
(subtype ? strlen(subtype) : 0) + strlen(dev) + 32);
|
||||
source = malloc((fsname ? strlen(fsname) : 0) + strlen(dev) + 32);
|
||||
|
||||
type = malloc((subtype ? strlen(subtype) : 0) + 32);
|
||||
type = malloc(32);
|
||||
if (!type || !source) {
|
||||
fprintf(stderr, "%s: failed to allocate memory\n", progname);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (subtype)
|
||||
sprintf(type, "%s.%s", blkdev ? "fuseblk" : "fuse", subtype);
|
||||
else
|
||||
strcpy(type, blkdev ? "fuseblk" : "fuse");
|
||||
strcpy(type, blkdev ? "fuseblk" : "fuse");
|
||||
|
||||
if (fsname)
|
||||
strcpy(source, fsname);
|
||||
else
|
||||
strcpy(source, subtype ? subtype : dev);
|
||||
strcpy(source, dev);
|
||||
|
||||
res = mount(source, mnt, type, flags, optbuf);
|
||||
if (res == -1 && errno == ENODEV && subtype) {
|
||||
/* Probably missing subtype support */
|
||||
strcpy(type, blkdev ? "fuseblk" : "fuse");
|
||||
if (fsname) {
|
||||
if (!blkdev)
|
||||
sprintf(source, "%s#%s", subtype, fsname);
|
||||
} else {
|
||||
strcpy(source, type);
|
||||
}
|
||||
|
||||
res = mount(source, mnt, type, flags, optbuf);
|
||||
}
|
||||
if (res == -1 && errno == EINVAL) {
|
||||
/* It could be an old version not supporting group_id */
|
||||
sprintf(d, "fd=%i,rootmode=%o,user_id=%i", fd, rootmode, getuid());
|
||||
|
@ -507,7 +486,6 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
|
|||
|
||||
err:
|
||||
free(fsname);
|
||||
free(subtype);
|
||||
free(source);
|
||||
free(type);
|
||||
free(mnt_opts);
|
||||
|
|
|
@ -40,7 +40,6 @@ static const struct fuse_opt fuse_helper_opts[] = {
|
|||
FUSE_HELPER_OPT("-f", foreground),
|
||||
FUSE_HELPER_OPT("-s", singlethread),
|
||||
FUSE_HELPER_OPT("fsname=", nodefault_subtype),
|
||||
FUSE_HELPER_OPT("subtype=", nodefault_subtype),
|
||||
|
||||
FUSE_OPT_KEY("-h", KEY_HELP),
|
||||
FUSE_OPT_KEY("--help", KEY_HELP),
|
||||
|
@ -50,7 +49,6 @@ static const struct fuse_opt fuse_helper_opts[] = {
|
|||
FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_END
|
||||
};
|
||||
|
||||
|
@ -118,27 +116,6 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
|
|||
}
|
||||
}
|
||||
|
||||
static int add_default_subtype(const char *progname, struct fuse_args *args)
|
||||
{
|
||||
int res;
|
||||
char *subtype_opt;
|
||||
const char *prog_basename = strrchr(progname, '/');
|
||||
if (prog_basename == NULL)
|
||||
prog_basename = progname;
|
||||
else if (prog_basename[1] != '\0')
|
||||
prog_basename++;
|
||||
|
||||
subtype_opt = (char *) malloc(strlen(prog_basename) + 64);
|
||||
if (subtype_opt == NULL) {
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
sprintf(subtype_opt, "-osubtype=%s", prog_basename);
|
||||
res = fuse_opt_add_arg(args, subtype_opt);
|
||||
free(subtype_opt);
|
||||
return res;
|
||||
}
|
||||
|
||||
int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
|
||||
int *multithreaded, int *foreground)
|
||||
{
|
||||
|
@ -150,11 +127,6 @@ int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
|
|||
if (res == -1)
|
||||
return -1;
|
||||
|
||||
if (!hopts.nodefault_subtype) {
|
||||
res = add_default_subtype(args->argv[0], args);
|
||||
if (res == -1)
|
||||
goto err;
|
||||
}
|
||||
if (mountpoint)
|
||||
*mountpoint = hopts.mountpoint;
|
||||
else
|
||||
|
@ -165,10 +137,6 @@ int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
|
|||
if (foreground)
|
||||
*foreground = hopts.foreground;
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free(hopts.mountpoint);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fuse_daemonize(int foreground)
|
||||
|
|
|
@ -46,8 +46,6 @@ struct mount_opts {
|
|||
int flags;
|
||||
int blkdev;
|
||||
char *fsname;
|
||||
char *subtype;
|
||||
char *subtype_opt;
|
||||
char *mtab_opts;
|
||||
char *fusermount_opts;
|
||||
char *kernel_opts;
|
||||
|
@ -60,12 +58,10 @@ static const struct fuse_opt fuse_mount_opts[] = {
|
|||
FUSE_MOUNT_OPT("allow_root", allow_root),
|
||||
FUSE_MOUNT_OPT("blkdev", blkdev),
|
||||
FUSE_MOUNT_OPT("fsname=%s", fsname),
|
||||
FUSE_MOUNT_OPT("subtype=%s", subtype),
|
||||
FUSE_OPT_KEY("allow_other", KEY_KERN_OPT),
|
||||
FUSE_OPT_KEY("allow_root", KEY_ALLOW_ROOT),
|
||||
FUSE_OPT_KEY("blkdev", KEY_FUSERMOUNT_OPT),
|
||||
FUSE_OPT_KEY("fsname=", KEY_FUSERMOUNT_OPT),
|
||||
FUSE_OPT_KEY("subtype=", KEY_SUBTYPE_OPT),
|
||||
FUSE_OPT_KEY("large_read", KEY_KERN_OPT),
|
||||
FUSE_OPT_KEY("blksize=", KEY_KERN_OPT),
|
||||
FUSE_OPT_KEY("default_permissions", KEY_KERN_OPT),
|
||||
|
@ -159,9 +155,6 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
|
|||
case KEY_FUSERMOUNT_OPT:
|
||||
return fuse_opt_add_opt(&mo->fusermount_opts, arg);
|
||||
|
||||
case KEY_SUBTYPE_OPT:
|
||||
return fuse_opt_add_opt(&mo->subtype_opt, arg);
|
||||
|
||||
case KEY_MTAB_OPT:
|
||||
return fuse_opt_add_opt(&mo->mtab_opts, arg);
|
||||
|
||||
|
@ -260,35 +253,18 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,
|
|||
goto out_close;
|
||||
|
||||
source = malloc((mo->fsname ? strlen(mo->fsname) : 0) +
|
||||
(mo->subtype ? strlen(mo->subtype) : 0) +
|
||||
strlen(devname) + 32);
|
||||
|
||||
type = malloc((mo->subtype ? strlen(mo->subtype) : 0) + 32);
|
||||
type = malloc(32);
|
||||
if (!type || !source) {
|
||||
fprintf(stderr, "fuse: failed to allocate memory\n");
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
strcpy(type, mo->blkdev ? "fuseblk" : "fuse");
|
||||
if (mo->subtype) {
|
||||
strcat(type, ".");
|
||||
strcat(type, mo->subtype);
|
||||
}
|
||||
strcpy(source,
|
||||
mo->fsname ? mo->fsname : (mo->subtype ? mo->subtype : devname));
|
||||
strcpy(type, mo->blkdev ? "fuseblk" : "fuse");
|
||||
strcpy(source, mo->fsname ? mo->fsname : devname);
|
||||
|
||||
res = mount(source, mnt, type, mo->flags, mo->kernel_opts);
|
||||
if (res == -1 && errno == ENODEV && mo->subtype) {
|
||||
/* Probably missing subtype support */
|
||||
strcpy(type, mo->blkdev ? "fuseblk" : "fuse");
|
||||
if (mo->fsname) {
|
||||
if (!mo->blkdev)
|
||||
sprintf(source, "%s#%s", mo->subtype, mo->fsname);
|
||||
} else {
|
||||
strcpy(source, type);
|
||||
}
|
||||
res = mount(source, mnt, type, mo->flags, mo->kernel_opts);
|
||||
}
|
||||
if (res == -1) {
|
||||
/*
|
||||
* Maybe kernel doesn't support unprivileged mounts, in this
|
||||
|
@ -381,30 +357,12 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args)
|
|||
fuse_opt_add_opt(&mnt_opts, mo.fusermount_opts) == -1)
|
||||
goto out;
|
||||
|
||||
if (mo.subtype) {
|
||||
char *tmp_opts = NULL;
|
||||
|
||||
res = -1;
|
||||
if (fuse_opt_add_opt(&tmp_opts, mnt_opts) == -1 ||
|
||||
fuse_opt_add_opt(&tmp_opts, mo.subtype_opt) == -1) {
|
||||
free(tmp_opts);
|
||||
goto out;
|
||||
}
|
||||
|
||||
res = fuse_mount_fusermount(mountpoint, tmp_opts);
|
||||
free(tmp_opts);
|
||||
if (res == -1)
|
||||
res = fuse_mount_fusermount(mountpoint, mnt_opts);
|
||||
} else {
|
||||
res = fuse_mount_fusermount(mountpoint, mnt_opts);
|
||||
}
|
||||
res = fuse_mount_fusermount(mountpoint, mnt_opts);
|
||||
}
|
||||
out:
|
||||
free(mnt_opts);
|
||||
free(mo.fsname);
|
||||
free(mo.subtype);
|
||||
free(mo.fusermount_opts);
|
||||
free(mo.subtype_opt);
|
||||
free(mo.kernel_opts);
|
||||
free(mo.mtab_opts);
|
||||
return res;
|
||||
|
|
Loading…
Reference in New Issue