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 /include/fuse_lowlevel.h | |
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 'include/fuse_lowlevel.h')
-rw-r--r-- | include/fuse_lowlevel.h | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index f90a052..0822e51 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -1560,10 +1560,72 @@ void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func, */ int fuse_req_interrupted(fuse_req_t req); + +/* ----------------------------------------------------------- * + * Inquiry functions * + * ----------------------------------------------------------- */ + +/** + * Print FUSE library version to stdout. + */ +void fuse_lowlevel_version(void); + +/** + * Print FUSE mount (fusermount) version stdout. + */ +void fuse_mount_version(void); + +/** + * Print available low-level options to stdout. + * These options may be passed to `fuse_session_new()` + */ +void fuse_lowlevel_help(void); + +/** + * Print available mount options to stdout. + * These options may be passed to `fuse_session_new()` + */ +void fuse_mount_help(void); + /* ----------------------------------------------------------- * * Filesystem setup & teardown * * ----------------------------------------------------------- */ +struct fuse_cmdline_opts { + int singlethread; + int foreground; + int debug; + int nodefault_subtype; + char *mountpoint; + int show_version; + int show_help; +}; + +/** + * Utility function to parse common options for simple file systems + * using the low-level API. Available options are listed in `struct + * fuse_opt fuse_helper_opts[]`. A single non-option argument is + * treated as the mountpoint. Multiple (or no) non-option arguments + * will result in an error. + * + * Unknown options are passed through unchanged. Known options (other + * than --debug, which is preserved) and the mountpoint argument are + * removed from *args*. + * + * If --help or --version is specified, the appropriate information is + * printed to stdout and the function proceeds normally. + * + * If neither -o subtype= or -o fsname= options are given, the subtype + * is set to the basename of the program (the fsname defaults to + * "fuse"). + * + * @param args argument vector (input+output) + * @param opts output argument for parsed options + * @return 0 on success, -1 on failure + */ +int fuse_parse_cmdline(struct fuse_args *args, + struct fuse_cmdline_opts *opts); + /** * Create a low level session. * @@ -1574,9 +1636,6 @@ int fuse_req_interrupted(fuse_req_t req); * `struct fuse_opt fuse_mount_opts[]`. If not all options are known, * an error message is written to stderr and the function returns NULL. * - * If the --help or --version parameters are specified, the function - * prints the requsted information to stdout and returns NULL. - * * @param args argument vector * @param op the (low-level) filesystem operations * @param op_size sizeof(struct fuse_lowlevel_ops) |