|  |  |  | libmount Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
int mnt_optstr_append_option (char **optstr,const char *name,const char *value); int mnt_optstr_apply_flags (char **optstr,unsigned long flags,const struct libmnt_optmap *map); int mnt_optstr_get_flags (const char *optstr,unsigned long *flags,const struct libmnt_optmap *map); int mnt_optstr_get_option (const char *optstr,const char *name,char **value,size_t *valsz); int mnt_optstr_get_options (const char *optstr,char **subset,const struct libmnt_optmap *map,int ignore); int mnt_optstr_next_option (char **optstr,char **name,size_t *namesz,char **value,size_t *valuesz); int mnt_optstr_prepend_option (char **optstr,const char *name,const char *value); int mnt_optstr_remove_option (char **optstr,const char *name); int mnt_optstr_set_option (char **optstr,const char *name,const char *value); int mnt_split_optstr (const char *optstr,char **user,char **vfs,char **fs,int ignore_user,int ignore_vfs);
int mnt_optstr_append_option (char **optstr,const char *name,const char *value);
| 
 | option string or NULL, returns reallocated string | 
| 
 | value name | 
| 
 | value | 
| Returns : | 0 on success or -1 in case of error. After error the optstrshould
be unmodified. | 
int mnt_optstr_apply_flags (char **optstr,unsigned long flags,const struct libmnt_optmap *map);
Removes/adds options to the optstr according to flags. For example:
MS_NOATIME and "foo,bar,noexec" --returns-> "foo,bar,noatime"
| 
 | string with comma separated list of options | 
| 
 | returns mount flags | 
| 
 | options map | 
| Returns : | 0 on success or negative number in case of error. | 
int mnt_optstr_get_flags (const char *optstr,unsigned long *flags,const struct libmnt_optmap *map);
Returns in flags IDs of options from optstr as defined in the map.
For example:
"bind,exec,foo,bar" --returns-> MS_BIND
"bind,noexec,foo,bar" --returns-> MS_BIND|MS_NOEXEC
Note that flags are not zeroized by this function! This function set/unset
bites in the flags only.
| 
 | string with comma separated list of options | 
| 
 | returns mount flags | 
| 
 | options map | 
| Returns : | 0 on success or negative number in case of error | 
int mnt_optstr_get_option (const char *optstr,const char *name,char **value,size_t *valsz);
| 
 | string with comma separated list of options | 
| 
 | requested option name | 
| 
 | returns pointer to the begin of the value (e.g. name=VALUE) or NULL | 
| 
 | returns size of the value or 0 | 
| Returns : | 0 on success, 1 when not found the nameor negative number in case
of error. | 
int mnt_optstr_get_options (const char *optstr,char **subset,const struct libmnt_optmap *map,int ignore);
Extracts options from optstr that belongs to the map, for example:
mnt_optstr_get_options(optstr, &p, mnt_get_builtin_optmap(MNT_LINUX_MAP), MNT_NOMTAB);
the 'p' returns all VFS options, the options that does not belong to mtab are ignored.
| 
 | string with comma separated list of options | 
| 
 | returns newly allocated string with options | 
| 
 | options map | 
| 
 | mask of the options that should be ignored | 
| Returns : | 0 on success, or negative number in case of error. | 
int mnt_optstr_next_option (char **optstr,char **name,size_t *namesz,char **value,size_t *valuesz);
Parses the first option in optstr.
| 
 | option string, returns position to next option | 
| 
 | returns option name | 
| 
 | returns option name length | 
| 
 | returns option value or NULL | 
| 
 | returns option value length or zero | 
| Returns : | 0 on success, 1 at the end of optstror negative number in case of
error. | 
int mnt_optstr_prepend_option (char **optstr,const char *name,const char *value);
| 
 | option string or NULL, returns reallocated string | 
| 
 | value name | 
| 
 | value | 
| Returns : | 0 on success or -1 in case of error. After error the optstrshould
be unmodified. | 
int mnt_optstr_remove_option (char **optstr,const char *name);
| 
 | string with comma separated list of options | 
| 
 | requested option name | 
| Returns : | 0 on success, 1 when not found the nameor negative number in case
of error. | 
int mnt_optstr_set_option (char **optstr,const char *name,const char *value);
Set or unset option value.
| 
 | string with comma separated list of options | 
| 
 | requested option | 
| 
 | new value or NULL | 
| Returns : | 0 on success, 1 when not found the nameor negative number in case
of error. | 
int mnt_split_optstr (const char *optstr,char **user,char **vfs,char **fs,int ignore_user,int ignore_vfs);
For example:
mnt_split_optstr(optstr, &u, NULL, NULL, MNT_NOMTAB, 0);
returns all userspace options, the options that does not belong to mtab are ignored.
Note that FS options are all options that are undefined in MNT_USERSPACE_MAP or MNT_LINUX_MAP.
| 
 | string with comma separated list of options | 
| 
 | returns newly allocated string with userspace options | 
| 
 | returns newly allocated string with VFS options | 
| 
 | returns newly allocated string with FS options | 
| 
 | option mask for options that should be ignored | 
| 
 | option mask for options that should be ignored | 
| Returns : | 0 on success, or negative number in case of error. |