diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2016-10-02 20:52:33 -0700 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2016-10-02 21:09:37 -0700 |
commit | 425db842ff1155fcd3b40439fcd88248d45a5db7 (patch) | |
tree | 96615a1328c7a19b9c8c4c18d42fd6464cebe7f2 /lib/cuse_lowlevel.c | |
parent | a10ee045e76cec75f9d8c08f78f0acc994302305 (diff) |
Don't handle --help and --version in fuse_session_new().
Help and version messages can be generated using the new
fuse_lowlevel_help(), fuse_lowlevel_version(), fuse_mount_help(), and
fuse_mount_version() functions.
The fuse_parse_cmdline() function has been made more powerful
to do this automatically, and is now explicitly intended only
for low-level API users.
This is a code simplication patch. We don't have to parse for --help and
--version in quite as many places, and we no longer have a low-level
initialization function be responsible for the (super-high level) task
of printing a program usage message.
In the high-level API, we can now handle the command line parsing
earlier and avoid running other initialization code if we're just going
to abort later on.
Diffstat (limited to 'lib/cuse_lowlevel.c')
-rw-r--r-- | lib/cuse_lowlevel.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/cuse_lowlevel.c b/lib/cuse_lowlevel.c index 3dd79d8..8f596cb 100644 --- a/lib/cuse_lowlevel.c +++ b/lib/cuse_lowlevel.c @@ -276,21 +276,18 @@ struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], struct fuse_args args = FUSE_ARGS_INIT(argc, argv); struct fuse_session *se; struct fuse_chan *ch; + struct fuse_cmdline_opts opts; int fd; - int foreground; int res; - res = fuse_parse_cmdline(&args, NULL, multithreaded, &foreground); - if (res == -1) { - fuse_opt_free_args(&args); + if (fuse_parse_cmdline(&args, &opts) == -1) return NULL; - } + *multithreaded = !opts.singlethread; + /* Remove subtype= option */ res = fuse_opt_parse(&args, NULL, kill_subtype_opts, NULL); - if (res == -1) { - fuse_opt_free_args(&args); - return NULL; - } + if (res == -1) + goto out1; /* * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos @@ -303,9 +300,8 @@ struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], } while (fd >= 0 && fd <= 2); se = cuse_lowlevel_new(&args, ci, clop, userdata); - fuse_opt_free_args(&args); if (se == NULL) - return NULL; + goto out1; fd = open(devname, O_RDWR); if (fd == -1) { @@ -329,7 +325,7 @@ struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], if (res == -1) goto err_se; - res = fuse_daemonize(foreground); + res = fuse_daemonize(opts.foreground); if (res == -1) goto err_sig; @@ -339,6 +335,9 @@ err_sig: fuse_remove_signal_handlers(se); err_se: fuse_session_destroy(se); +out1: + free(opts.mountpoint); + fuse_opt_free_args(&args); return NULL; } |