aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <miklos@szeredi.hu>2007-06-21 13:48:07 +0000
committerGravatar Miklos Szeredi <miklos@szeredi.hu>2007-06-21 13:48:07 +0000
commitfdd1b9b4ecaf53c5e393d1e445ed8d7af02d5a96 (patch)
tree2ee19a46a960e71cbe50de7ea44e80c3ecf87a38 /util
parent62c24a8e4b10d77e08ee4a40c6f6b6a8d1eafeab (diff)
Add fs subtype support to mount.fuse
Diffstat (limited to 'util')
-rw-r--r--util/mount.fuse.c70
1 files changed, 55 insertions, 15 deletions
diff --git a/util/mount.fuse.c b/util/mount.fuse.c
index d156009..4cc0394 100644
--- a/util/mount.fuse.c
+++ b/util/mount.fuse.c
@@ -6,7 +6,6 @@
static char *progname;
-
static char *xstrdup(const char *s)
{
char *t = strdup(s);
@@ -54,37 +53,66 @@ static void add_arg(char **cmdp, const char *opt)
int main(int argc, char *argv[])
{
- char *type;
+ char *type = NULL;
char *source;
const char *mountpoint;
+ char *basename;
char *options = NULL;
char *command = NULL;
char *setuid = NULL;
int i;
progname = argv[0];
+ basename = strrchr(argv[0], '/');
+ if (basename)
+ basename++;
+ else
+ basename = argv[0];
+
+ if (strncmp(basename, "mount.fuse.", 11) == 0)
+ type = basename + 11;
+ if (strncmp(basename, "mount.fuseblk.", 14) == 0)
+ type = basename + 14;
+
+ if (type && !type[0])
+ type = NULL;
+
if (argc < 3) {
- fprintf(stderr,
- "usage: %s type#[source] mountpoint [-o opt[,opts...]]\n",
- progname);
+ fprintf(stderr, "usage: %s %s destination [-t type] [-o opt[,opts...]]\n",
+ progname, type ? "source" : "type#[source]");
exit(1);
}
- type = xstrdup(argv[1]);
- source = strchr(type, '#');
- if (source)
- *source++ = '\0';
+ source = argv[1];
+ if (!source[0])
+ source = NULL;
- if (!type[0]) {
- fprintf(stderr, "%s: empty filesystem type\n", progname);
- exit(1);
- }
mountpoint = argv[2];
for (i = 3; i < argc; i++) {
- if (strcmp(argv[i], "-v") == 0)
+ if (strcmp(argv[i], "-v") == 0) {
continue;
- if (strcmp(argv[i], "-o") == 0) {
+ } else if (strcmp(argv[i], "-t") == 0) {
+ i++;
+
+ if (i == argc) {
+ fprintf(stderr,
+ "%s: missing argument to option '-t'\n", progname);
+ exit(1);
+ }
+ type = argv[i];
+ if (strncmp(type, "fuse.", 5) == 0)
+ type += 5;
+ else if (strncmp(type, "fuseblk.", 8) == 0)
+ type += 8;
+
+ if (!type[0]) {
+ fprintf(stderr,
+ "%s: empty type given as argument to option '-t'\n",
+ progname);
+ exit(1);
+ }
+ } else if (strcmp(argv[i], "-o") == 0) {
char *opts;
char *opt;
i++;
@@ -122,6 +150,18 @@ int main(int argc, char *argv[])
}
}
+ if (!type) {
+ type = xstrdup(source);
+ source = strchr(type, '#');
+ if (source)
+ *source++ = '\0';
+
+ if (!type[0]) {
+ fprintf(stderr, "%s: empty filesystem type\n", progname);
+ exit(1);
+ }
+ }
+
add_arg(&command, type);
if (source)
add_arg(&command, source);