diff options
Diffstat (limited to 'lib/helper.c')
-rw-r--r-- | lib/helper.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/lib/helper.c b/lib/helper.c index 7cbb9eb..e06c01c 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -70,43 +70,51 @@ static void set_signal_handlers() void fuse_main(int argc, char *argv[], const struct fuse_operations *op) { - int argctr = 2; + int argctr; int flags; int multithreaded; int fuse_fd; char *fuse_mountpoint = NULL; - char umount_cmd[1024] = ""; char **fusermount_args = NULL; flags = 0; multithreaded = 1; - for(; argctr < argc && !fusermount_args; argctr ++) { - if(argv[argctr][0] == '-' && strlen(argv[argctr]) == 2) - switch(argv[argctr][1]) { - case 'd': - flags |= FUSE_DEBUG; - break; - - case 's': - multithreaded = 0; - break; - - case 'h': - usage(argv[0]); - break; - - case '-': - fusermount_args = &argv[argctr+1]; - break; - - default: + for(argctr = 1; argctr < argc && !fusermount_args; argctr ++) { + if(argv[argctr][0] == '-') { + if(strlen(argv[argctr]) == 2) + switch(argv[argctr][1]) { + case 'd': + flags |= FUSE_DEBUG; + break; + + case 's': + multithreaded = 0; + break; + + case 'h': + usage(argv[0]); + break; + + case '-': + fusermount_args = &argv[argctr+1]; + break; + + default: + invalid_option(argv, argctr); + } + else invalid_option(argv, argctr); - } - else + } else if(fuse_mountpoint == NULL) + fuse_mountpoint = strdup(argv[argctr]); + else invalid_option(argv, argctr); } - fuse_mountpoint = strdup(argv[1]); + if(fuse_mountpoint == NULL) { + fprintf(stderr, "missing mountpoint\n"); + usage(argv[0]); + } + fuse_fd = fuse_mount(fuse_mountpoint, (const char **) fusermount_args); if(fuse_fd == -1) exit(1); @@ -123,9 +131,6 @@ void fuse_main(int argc, char *argv[], const struct fuse_operations *op) fuse_loop(fuse); close(fuse_fd); - if(fuse_mountpoint != NULL) - fuse_unmount(fuse_mountpoint); - else if(umount_cmd[0] != '\0') - system(umount_cmd); + fuse_unmount(fuse_mountpoint); } |