if (fuse_parse_cmdline(&args, &opts) != 0)
return 1;
- if (opts.show_help || opts.show_version) {
- ret = 1;
+ if (opts.show_help) {
+ printf("usage: %s [options] <mountpoint>\n\n", argv[0]);
+ fuse_cmdline_help();
+ fuse_lowlevel_help();
+ fuse_mount_help();
+ ret = 0;
+ goto err_out1;
+ } else if (opts.show_version) {
+ printf("FUSE library version %s\n", fuse_pkgversion());
+ fuse_lowlevel_version();
+ fuse_mount_version();
+ ret = 0;
goto err_out1;
}
+
lo.debug = opts.debug;
lo.root.next = lo.root.prev = &lo.root;
lo.root.fd = open("/", O_PATH);
if (fuse_parse_cmdline(&args, &opts) != 0)
return 1;
- if (opts.show_help || opts.show_version) {
- ret = 1;
+ if (opts.show_help) {
+ printf("usage: %s [options] <mountpoint>\n\n", argv[0]);
+ fuse_cmdline_help();
+ fuse_lowlevel_help();
+ fuse_mount_help();
+ ret = 0;
+ goto err_out1;
+ } else if (opts.show_version) {
+ printf("FUSE library version %s\n", fuse_pkgversion());
+ fuse_lowlevel_version();
+ fuse_mount_version();
+ ret = 0;
goto err_out1;
}
return NULL;
}
+static void show_help(const char *progname)
+{
+ printf("usage: %s [options] <mountpoint>\n\n", progname);
+ printf("File-system specific options:\n"
+ " --update-interval=<secs> Update-rate of file system contents\n"
+ " --no-notify Disable kernel notifications\n"
+ "\n");
+}
+
int main(int argc, char *argv[]) {
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
struct fuse_session *se;
opt_proc) == -1)
return 1;
- if (fuse_parse_cmdline(&args, &opts) != 0)
- return 1;
- if (opts.show_help || opts.show_version) {
+ if (fuse_parse_cmdline(&args, &opts) != 0) {
ret = 1;
goto err_out1;
}
+ if (opts.show_help) {
+ show_help(argv[0]);
+ fuse_cmdline_help();
+ fuse_lowlevel_help();
+ fuse_mount_help();
+ ret = 0;
+ goto err_out1;
+ } else if (opts.show_version) {
+ printf("FUSE library version %s\n", fuse_pkgversion());
+ fuse_lowlevel_version();
+ fuse_mount_version();
+ ret = 0;
+ goto err_out1;
+ }
+
se = fuse_session_new(&args, &tfs_oper,
sizeof(tfs_oper), NULL);
if (se == NULL)
err_out2:
fuse_session_destroy(se);
err_out1:
- free(opts.mountpoint);
fuse_opt_free_args(&args);
+ free(opts.mountpoint);
return ret ? 1 : 0;
}
return NULL;
}
+static void show_help(const char *progname)
+{
+ printf("usage: %s [options] <mountpoint>\n\n", progname);
+ printf("File-system specific options:\n"
+ " --update-interval=<secs> Update-rate of file system contents\n"
+ " --no-notify Disable kernel notifications\n"
+ "\n");
+}
+
int main(int argc, char *argv[]) {
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
struct fuse_session *se;
if (fuse_parse_cmdline(&args, &opts) != 0)
return 1;
- if (opts.show_help || opts.show_version) {
- ret = 1;
+ if (opts.show_help) {
+ show_help(argv[0]);
+ fuse_cmdline_help();
+ fuse_lowlevel_help();
+ fuse_mount_help();
+ ret = 0;
+ goto err_out1;
+ } else if (opts.show_version) {
+ printf("FUSE library version %s\n", fuse_pkgversion());
+ fuse_lowlevel_version();
+ fuse_mount_version();
+ ret = 0;
goto err_out1;
}
return NULL;
}
+static void show_help(const char *progname)
+{
+ printf("usage: %s [options] <mountpoint>\n\n", progname);
+ printf("File-system specific options:\n"
+ " --timeout=<secs> Timeout for kernel caches\n"
+ " --update-interval=<secs> Update-rate of file system contents\n"
+ " --no-notify Disable kernel notifications\n"
+ "\n");
+}
+
int main(int argc, char *argv[]) {
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
struct fuse_session *se;
if (fuse_parse_cmdline(&args, &opts) != 0)
return 1;
- if (opts.show_help || opts.show_version) {
- ret = 1;
+ if (opts.show_help) {
+ show_help(argv[0]);
+ fuse_cmdline_help();
+ fuse_lowlevel_help();
+ fuse_mount_help();
+ ret = 0;
+ goto err_out1;
+ } else if (opts.show_version) {
+ printf("FUSE library version %s\n", fuse_pkgversion());
+ fuse_lowlevel_version();
+ fuse_mount_version();
+ ret = 0;
goto err_out1;
}
*/
void fuse_mount_help(void);
+
+/**
+ * Print available options for `fuse_parse_cmdline()`.
+ */
+void fuse_cmdline_help(void);
+
/* ----------------------------------------------------------- *
* Filesystem setup & teardown *
* ----------------------------------------------------------- */
/**
* 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 returns -1.
- *
- * 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").
+ * using the low-level API. A help text that describes the available
+ * options can be printed with `fuse_cmdline_help`. A single
+ * non-option argument is treated as the mountpoint. Multiple
+ * non-option arguments will result in an error.
+ *
+ * If neither -o subtype= or -o fsname= options are given, a new
+ * subtype option will be added and set to the basename of the program
+ * (the fsname will remain unset, and then defaults to "fuse").
*
* @param args argument vector (input+output)
* @param opts output argument for parsed options
fuse_lowlevel_help;
fuse_lowlevel_version;
fuse_mount_help;
+ fuse_cmdline_help;
fuse_mount_version;
local:
FUSE_OPT_END
};
-static void usage(const char *progname)
-{
- printf("usage: %s mountpoint [options]\n\n", progname);
-}
-
-static void helper_help(void)
+void fuse_cmdline_help(void)
{
printf("General options:\n"
" -h --help print help\n"
"\n");
}
-static void helper_version(void)
-{
- printf("FUSE library version: %s\n", PACKAGE_VERSION);
-}
-
static int fuse_helper_opt_proc(void *data, const char *arg, int key,
struct fuse_args *outargs)
{
fuse_helper_opt_proc) == -1)
return -1;
- if (opts->show_version) {
- helper_version();
- fuse_lowlevel_version();
- fuse_mount_version();
- return -1;
- }
-
- if (opts->show_help) {
- usage(args->argv[0]);
- helper_help();
- fuse_lowlevel_help();
- fuse_mount_help();
- return -1;
- }
-
- if (!opts->mountpoint) {
- fprintf(stderr, "error: no mountpoint specified\n");
- usage(args->argv[0]);
- return -1;
- }
-
/* If neither -o subtype nor -o fsname are specified,
set subtype to program's basename */
if (!opts->nodefault_subtype)
return 1;
if (opts.show_version) {
- helper_version();
+ printf("FUSE library version %s\n", PACKAGE_VERSION);
fuse_lowlevel_version();
fuse_mount_version();
res = 0;
/* Re-add --help for later processing by fuse_new()
(that way we also get help for modules options) */
if (opts.show_help) {
- helper_help();
+ fuse_cmdline_help();
if (fuse_opt_add_arg(&args, "--help") == -1) {
res = 1;
goto out1;
if (!opts.show_help &&
!opts.mountpoint) {
fprintf(stderr, "error: no mountpoint specified\n");
- usage(args.argv[0]);
res = 1;
goto out1;
}