OpenBSD manual page server

Manual Page Search Parameters

FUSE_OPT(3) Library Functions Manual FUSE_OPT(3)

FUSE_ARGS_INIT, FUSE_OPT_IS_OPT_KEY, FUSE_OPT_KEY, fuse_opt_add_arg, fuse_opt_insert_arg, fuse_opt_add_opt, fuse_opt_add_opt_escaped, fuse_opt_free_args, fuse_opt_match, fuse_opt_parseFUSE argument and option parser

#include <fuse_opt.h>

struct fuse_args
FUSE_ARGS_INIT(int argc, char argv**);

FUSE_OPT_IS_OPT_KEY(fuse_opt *t);

struct fuse_opt
FUSE_OPT_KEY(const char *templ, int key);

fuse_opt_add_arg(struct fuse_args *args, const char *arg);

fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *opt);

fuse_opt_add_opt(char **opts, const char *opt);

fuse_opt_add_opt_escaped(char **opts, const char *opt);

fuse_opt_free_args(struct fuse_args *args);

fuse_opt_match(const struct fuse_opt *opts, const char *opt);

fuse_opt_parse(struct fuse_args *args, void *data, const struct fuse_opt *opts, fuse_opt_proc_t proc);

These FUSE library functions and macros provide support for complex argument and option parsing. These are typically entered on the command line but may also be passed by file systems to the fuse_mount(3) and fuse_new(3) functions. struct fuse_args holds string options in an array:

struct fuse_args {
        int argc;	/* argument count */
        char **argv;	/* NULL-terminated array of arguments */
        int allocated;	/* argv was allocated and must be freed */

(templ, key)
returns a struct fuse_opt template that matches an argument or option templ with option key key. This macro is used as an element in struct fuse_opt arrays to create a template that is processed by a fuse_opt_proc_t. The special constants FUSE_OPT_KEEP and FUSE_OPT_DISCARD can be specified if proc does not need to handle this option or argument; proc is not called in this case.

checks if templ is an option key.

The last element of the opts struct fuse_opt option array must be FUSE_OPT_END.

proc points to a function with the following signature: int (*fuse_opt_proc_t) (void *data, const char *arg, int key, struct fuse_args *outargs);

Special key values:

FUSE_OPT_KEY_OPT	/* no match */
FUSE_OPT_KEY_NONOPT	/* non-option */
FUSE_OPT_KEY_KEEP	/* don't process; return 1 */
FUSE_OPT_KEY_DISCARD	/* don't process; return 0 */

initializes a struct fuse_args with argc and argv, which are usually obtained from (). argv is NULL-terminated, and is suitable for use with execvp(3). argv is used directly and allocated is set to 0.

adds a single option to the end of args. If args->allocated is 0, args->argv is copied to the heap and args->allocated is set to a non-zero value.

inserts a single argument at position pos into args, shifting args->argv as needed.

adds an option opt to a comma-separated string of options opts. *opts can be NULL, which is typically used when adding the first option.

escapes any ‘,’ and ‘�’ characters in opt before adding it to opts.

frees args->argv if it was allocated args and initializes everything to 0.

tests if the argument or option opt appears in the list of templates opts. If opt is an option then it must not include the -o prefix.

parses options, setting any members of data automatically depending on the format of the template. If proc is not NULL, then this is called for any argument that matches a template that has val = FUSE_OPT_KEY. opts is an array of struct fuse_opt, each of which describes actions for each option:
struct fuse_opt {
        const char *templ;	/* template for option */
        unsigned long off;	/* data offset */
        int val;		/* key value */

The following templates are supported. foo=

foo=%u %u can be any format that can be parsed by (3). If this is %s then a copy of the string is allocated. foo=bar matches the option exactly (treated the same as if it didn't have an =).

foo matches exactly

-b or --bar matches the argument "-b " or "--bar " (trailing space) argument expects a value, that is passed to proc

-b %u or:w
--bar %u Treated the same as foo=%u above

Each argument or option is matched against every template. This allows more than one member of data to be set by a single argument or option (see example for gid below).

fuse_opt_add_arg(), fuse_opt_insert_arg(), fuse_opt_add_opt(), fuse_opt_add_opt_escaped(), and fuse_opt_parse() return 0 on success, -1 on error.

fuse_opt_match() returns 1 on match, 0 if no match.

fuse_opt_add_arg(), fuse_opt_insert_arg(), fuse_opt_add_opt(), and fuse_opt_add_opt_escaped() can run out of memory and set errno.


These library functions conform to FUSE 2.6.

These functions first appeared in OpenBSD 5.4.

Sylvestre Gallon <>
Helg Bredow <>

This manual was written by
Ray Lai <> and updated by
Helg Bredow <>

November 30, 2018 OpenBSD-current