Improve documentation of argument parsing.

This commit is contained in:
Nikolaus Rath 2016-10-01 11:24:46 -07:00
parent 944d1e1521
commit e20e5c9ae5
8 changed files with 38 additions and 3 deletions

View File

@ -640,6 +640,13 @@ struct fuse_context {
/**
* Create a new FUSE filesystem.
*
* Known parameters in `args` are removed. If there are any unknown
* arguments, an error is printed to stderr and the function returns
* NULL.
*
* If the --help or --version parameters are specified, the function
* prints the requested information to stdout and returns NULL.
*
* @param ch the communication channel
* @param args argument vector
* @param op the filesystem operations

View File

@ -213,7 +213,13 @@ struct fuse_pollhandle;
* Create a FUSE mountpoint
*
* Returns a control file descriptor suitable for passing to
* fuse_new()
* fuse_new(). Unknown parameters in `args` are passed through
* unchanged. Known parameters (with the exception of --help and
* --version) are removed from `args`.
*
* If the --help or --version parameters are specified, the function
* prints the requested information to stdout and returns a valid
* pointer. However, it does not actually perform the mount.
*
* @param mountpoint the mount point path
* @param args argument vector
@ -230,7 +236,7 @@ struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
/**
* Parse common options
* Utility functions for simple file systems to parse common options.
*
* The following options are parsed:
*
@ -242,7 +248,11 @@ void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
* '-ofsname=..' file system name, if not present, then set to the program
* name
*
* All parameters may be NULL
* Unknown parameters in `args` are passed through unchanged. Known
* parameters (with the exception of --help and --version) are removed.
*
* All parameters may be NULL (in which case they may still
* be specified on the command line, but will not be set).
*
* @param args argument vector
* @param mountpoint the returned mountpoint, should be freed after use

View File

@ -1575,6 +1575,13 @@ int fuse_req_interrupted(fuse_req_t req);
/**
* Create a low level session
*
* Known parameters in `args` are removed. If there are any unknown
* arguments, an error is printed 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)

View File

@ -4684,6 +4684,9 @@ struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
init_list_head(&f->full_slabs);
init_list_head(&f->lru_table);
/* When --help or --version are specified, we print messages
to stderr but continue for now (and keep the arguments in
`args` for use below */
if (fuse_opt_parse(args, &f->conf, fuse_lib_opts,
fuse_lib_opt_proc) == -1)
goto out_free_fs;
@ -4714,6 +4717,8 @@ struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
f->conf.readdir_ino = 1;
#endif
/* This function will return NULL if there is an --help
or --version argument in `args` */
f->se = fuse_lowlevel_new(args, &llop, sizeof(llop), f);
if (f->se == NULL) {
if (f->conf.help)

View File

@ -2674,6 +2674,7 @@ static int fuse_ll_opt_proc(void *data, const char *arg, int key,
fprintf(stderr, "fuse: unknown option `%s'\n", arg);
}
/* Fail */
return -1;
}

View File

@ -114,6 +114,7 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
}
default:
/* Pass through unknown options */
return 1;
}
}

View File

@ -241,6 +241,8 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
mo->ishelp = 1;
break;
}
/* Pass through unknown options */
return 1;
}

View File

@ -141,6 +141,8 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
mo->ishelp = 1;
break;
}
/* Pass through unknown options */
return 1;
}