</partintro>
</part>
+ <part>
+ <title>High-level API</title>
+ <xi:include href="xml/context.xml"/>
+ </part>
<part>
<title>Files parsing</title>
<xi:include href="xml/tab.xml"/>
<part>
<title>Mount options</title>
<xi:include href="xml/optstr.xml"/>
- <xi:include href="xml/optls.xml"/>
- <xi:include href="xml/optent.xml"/>
<xi:include href="xml/optmap.xml"/>
</part>
<part>
<title>Mtab management</title>
<xi:include href="xml/lock.xml"/>
+ <xi:include href="xml/update.xml"/>
</part>
<part>
<title>Misc</title>
<FILE>utils</FILE>
mnt_fstype_is_netfs
mnt_fstype_is_pseudofs
+mnt_get_fstab_path
+mnt_get_mtab_path
+mnt_has_regular_mtab
+mnt_mangle
mnt_match_fstype
mnt_match_options
+mnt_unmangle
</SECTION>
<SECTION>
<FILE>cache</FILE>
mnt_cache
-mnt_new_cache
-mnt_free_cache
-mnt_cache_find_path
-mnt_cache_find_tag
-mnt_cache_read_tags
mnt_cache_device_has_tag
mnt_cache_find_tag_value
+mnt_cache_read_tags
+mnt_free_cache
+mnt_get_fstype
+mnt_new_cache
mnt_resolve_path
-mnt_resolve_tag
mnt_resolve_spec
+mnt_resolve_tag
</SECTION>
<SECTION>
<FILE>optstr</FILE>
-mnt_optstr_next_option
mnt_optstr_append_option
+mnt_optstr_apply_flags
+mnt_optstr_get_flags
mnt_optstr_get_option
-mnt_optstr_set_option
+mnt_optstr_get_options
+mnt_optstr_next_option
+mnt_optstr_prepend_option
mnt_optstr_remove_option
+mnt_optstr_set_option
+mnt_split_optstr
</SECTION>
<SECTION>
<FILE>iter</FILE>
mnt_iter
-mnt_new_iter
mnt_free_iter
-mnt_reset_iter
mnt_iter_get_direction
+mnt_new_iter
+mnt_reset_iter
</SECTION>
<SECTION>
<FILE>optmap</FILE>
-mnt_optmap
+struct mnt_optmap
mnt_get_builtin_optmap
</SECTION>
-<SECTION>
-<FILE>optent</FILE>
-mnt_optent
-mnt_optent_get_map
-mnt_optent_get_mapent
-mnt_optent_get_type
-mnt_optent_set_value
-mnt_optent_has_value
-mnt_optent_require_value
-mnt_optent_is_inverted
-mnt_optent_strtoul_value
-mnt_optent_strtol_value
-mnt_optent_strtoull_value
-mnt_optent_get_value
-mnt_optent_strlen_value
-mnt_optent_snprintf_value
-mnt_optent_dup_value
-mnt_optent_get_name
-mnt_optent_get_mask
-mnt_optent_get_id
-mnt_optent_get_flag
-mnt_optent_is_unknown
-mnt_optent_print_debug
-</SECTION>
-
-<SECTION>
-<FILE>optls</FILE>
-mnt_optls
-mnt_new_optls
-mnt_free_optls
-mnt_optls_add_map
-mnt_optls_add_builtin_map
-mnt_optls_add_option
-mnt_optls_parse_optstr
-mnt_optls_remove_option
-mnt_optls_remove_option_by_flags
-mnt_optls_remove_option_by_iflags
-mnt_optls_next_option
-mnt_optls_get_option
-mnt_optls_get_ids
-mnt_optls_create_mountflags
-mnt_optls_create_mountdata
-mnt_optls_create_mtab_optstr
-mnt_optls_create_userspace_optstr
-mnt_optls_print_debug
-</SECTION>
-
-
<SECTION>
<FILE>lock</FILE>
mnt_lock
-mnt_new_lock
mnt_free_lock
-mnt_lock_get_lockfile
-mnt_lock_get_linkfile
-mnt_unlock_file
mnt_lock_file
+mnt_new_lock
+mnt_unlock_file
</SECTION>
-
<SECTION>
<FILE>fs</FILE>
mnt_fs
-mnt_new_fs
+mnt_copy_fs
mnt_free_fs
-mnt_fs_get_userdata
-mnt_fs_set_userdata
+mnt_free_mntent
+mnt_fs_append_attributes
+mnt_fs_append_fs_options
+mnt_fs_append_options
+mnt_fs_append_userspace_options
+mnt_fs_append_vfs_options
+mnt_fs_get_attribute
+mnt_fs_get_attributes
+mnt_fs_get_bindsrc
+mnt_fs_get_devno
+mnt_fs_get_freq
+mnt_fs_get_fs_options
+mnt_fs_get_fstype
+mnt_fs_get_id
+mnt_fs_get_option
+mnt_fs_get_parent_id
+mnt_fs_get_passno
+mnt_fs_get_root
mnt_fs_get_source
-mnt_fs_set_source
mnt_fs_get_srcpath
mnt_fs_get_tag
mnt_fs_get_target
-mnt_fs_set_target
-mnt_fs_get_fstype
-mnt_fs_set_fstype
-mnt_fs_get_optstr
-mnt_fs_set_optstr
-mnt_fs_get_fs_optstr
-mnt_fs_get_vfs_optstr
-mnt_fs_get_freq
-mnt_fs_set_freq
-mnt_fs_get_passno
-mnt_fs_set_passno
-mnt_fs_get_id
-mnt_fs_get_parent_id
-mnt_fs_get_devno
-mnt_fs_get_option
-mnt_fs_match_target
-mnt_fs_match_source
+mnt_fs_get_userdata
+mnt_fs_get_userspace_options
+mnt_fs_get_vfs_options
mnt_fs_match_fstype
mnt_fs_match_options
-mnt_fprintf_line
-mnt_fs_fprintf
+mnt_fs_match_source
+mnt_fs_match_target
+mnt_fs_prepend_attributes
+mnt_fs_prepend_fs_options
+mnt_fs_prepend_options
+mnt_fs_prepend_userspace_options
+mnt_fs_prepend_vfs_options
mnt_fs_print_debug
+mnt_fs_set_attributes
+mnt_fs_set_bindsrc
+mnt_fs_set_freq
+mnt_fs_set_fs_options
+mnt_fs_set_fstype
+mnt_fs_set_options
+mnt_fs_set_passno
+mnt_fs_set_root
+mnt_fs_set_source
+mnt_fs_set_target
+mnt_fs_set_userdata
+mnt_fs_set_userspace_options
+mnt_fs_set_vfs_options
+mnt_fs_strdup_options
+mnt_new_fs
+mnt_fs_to_mntent
</SECTION>
<SECTION>
<FILE>tab</FILE>
mnt_tab
-mnt_new_tab_from_file
-mnt_tab_parse_file
-mnt_tab_strerror
-mnt_tab_get_nerrs
-mnt_new_tab
mnt_free_tab
-mnt_tab_get_nents
-mnt_tab_set_cache
+mnt_new_tab
+mnt_new_tab_from_dir
+mnt_new_tab_from_file
+mnt_tab_add_fs
+mnt_tab_find_next_fs
+mnt_tab_find_pair
+mnt_tab_find_source
+mnt_tab_find_srcpath
+mnt_tab_find_tag
+mnt_tab_find_target
mnt_tab_get_cache
mnt_tab_get_name
-mnt_tab_add_fs
-mnt_tab_remove_fs
-mnt_tab_next_fs
-mnt_tab_next_child_fs
+mnt_tab_get_nents
mnt_tab_get_root_fs
+mnt_tab_next_child_fs
+mnt_tab_next_fs
+mnt_tab_parse_file
+mnt_tab_parse_fstab
+mnt_tab_parse_mtab
+mnt_tab_parse_stream
+mnt_tab_remove_fs
+mnt_tab_set_cache
mnt_tab_set_iter
-mnt_tab_find_target
-mnt_tab_find_srcpath
-mnt_tab_find_tag
-mnt_tab_find_source
-mnt_tab_find_next_fs
-mnt_tab_fprintf
-mnt_tab_update_file
+mnt_tab_set_parser_errcb
+</SECTION>
+
+<SECTION>
+<FILE>update</FILE>
+mnt_update
+mnt_free_update
+mnt_new_update
+mnt_update_force_rdonly
+mnt_update_get_filename
+mnt_update_get_fs
+mnt_update_get_mountflags
+mnt_update_is_ready
+mnt_update_set_fs
+mnt_update_tab
+</SECTION>
+
+<SECTION>
+<FILE>context</FILE>
+mnt_context
+mnt_context_append_options
+mnt_context_apply_fstab
+mnt_context_disable_canonicalize
+mnt_context_disable_helpers
+mnt_context_disable_mtab
+mnt_context_do_mount
+mnt_context_do_umount
+mnt_context_enable_fake
+mnt_context_enable_force
+mnt_context_enable_lazy
+mnt_context_enable_loopdel
+mnt_context_enable_rdonly_umount
+mnt_context_enable_sloppy
+mnt_context_enable_verbose
+mnt_context_get_cache
+mnt_context_get_fs
+mnt_context_get_fstab
+mnt_context_get_lock
+mnt_context_get_mountflags
+mnt_context_get_mtab
+mnt_context_get_status
+mnt_context_get_userspace_mountflags
+mnt_context_is_restricted
+mnt_context_set_cache
+mnt_context_set_fs
+mnt_context_set_fstab
+mnt_context_set_fstype
+mnt_context_set_fstype_pattern
+mnt_context_set_mountdata
+mnt_context_set_mountflags
+mnt_context_set_options
+mnt_context_set_options_pattern
+mnt_context_set_optsmode
+mnt_context_set_source
+mnt_context_set_target
+mnt_context_set_userspace_mountflags
+mnt_context_strerror
+mnt_free_context
+mnt_new_context
+mnt_reset_context
</SECTION>
+
* GNU Lesser General Public License.
*/
+/**
+ * SECTION: context
+ * @title: Mount/umount context
+ * @short_description: high-level API to mount/umount devices.
+ *
+ * <informalexample>
+ * <programlisting>
+ * mnt_context *cxt = mnt_new_context();
+ *
+ * mnt_context_set_options(cxt, "aaa,bbb,ccc=CCC");
+ * mnt_context_set_mountflags(cxt, MS_NOATIME|MS_NOEXEC);
+ * mnt_context_set_target(cxt, "/mnt/foo");
+ *
+ * if (!mnt_context_do_mount(cxt))
+ * printf("successfully mounted\n");
+ * mnt_free_context(cxt);
+ *
+ * </programlisting>
+ * </informalexample>
+ *
+ * This code is similar to:
+ *
+ * mount -o aaa,bbb,ccc=CCC,noatime,noexec /mnt/foo
+ *
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
* @cxt: mount context
* @enable: TRUE or FALSE
*
- * Enable/disable verbose output (see also mnt_context_mount_strerror()).
+ * Enable/disable verbose output (TODO: not implemented yet)
*
* Returns: 0 on success, negative number in case of error.
*/
* @fstype: filesystem type
*
* Note that the @fstype has to be the real FS type. For comma-separated list of
- * filesystems or for "no<fs>" notation use mnt_context_set_fstype_pattern().
+ * filesystems or for "nofs" notation use mnt_context_set_fstype_pattern().
*
* Returns: 0 on success, negative number in case of error.
*/
/**
* mnt_context_set_options:
* @cxt: mount context
- * @options: comma delimited mount options
+ * @optstr: comma delimited mount options
*
* Returns: 0 on success, negative number in case of error.
*/
* remove the lock file when interrupted by signal. It means that properly written
* mount(8)-like application has to call mnt_unlock_file() from a signal handler.
*
- * See also mnt_unlock_file(), mnt_context_disable_lock() and
- * mnt_context_disable_mtab().
- *
* This function returns NULL if mtab file is not writable or nolock or nomtab
* flags is enabled.
*
* mnt_context_get_status:
* @cxt: mount context
*
- * Returns: 1 if mount.<type> or mount(2) syscall was successfull or 0.
+ * Returns: 1 if /sbin/mount.type or mount(2) syscall was successfull or 0.
*/
int mnt_context_get_status(mnt_context *cxt)
{
* mnt_context_do_mount:
* @cxt: mount context
*
- * Mount filesystem by mount(2) or fork()+exec(/sbin/mount.<type>).
+ * Mount filesystem by mount(2) or fork()+exec(/sbin/mount.type).
*
* See also mnt_context_disable_helpers().
*
* Returns: 0 on success, and negative number in case of error. WARNING: error
- * does not mean that mount(2) syscall or mount.<type> helper wasn't
+ * does not mean that mount(2) syscall or mount.type helper wasn't
* sucessfully called. Check mnt_context_get_status() after error!
*/
int mnt_context_do_mount(mnt_context *cxt)
* mnt_context_do_umount:
* @cxt: mount context
*
- * Umount filesystem by umount(2) or fork()+exec(/sbin/umount.<type>).
+ * Umount filesystem by umount(2) or fork()+exec(/sbin/umount.type).
*
* See also mnt_context_disable_helpers().
*
return NULL;
}
-/**
- * mnt_copy_mtab_fs:
- * @fs: filesystem
- *
+/*
* This function copies all @fs description except information that does not
* belong to /etc/mtab (e.g. VFS and userspace mount options with MNT_NOMTAB
* mask).
/**
* mnt_fs_set_userdata:
* @fs: mnt_file instance
+ * @data: user data
*
* The "userdata" are library independent data.
*
/**
* mnt_fs_set_options:
* @fs: fstab/mtab/mountinfo entry pointer
+ * @optstr: options string
*
* Splits @optstr to VFS, FS and userspace mount options and update relevat
* parts of @fs.
/**
* mnt_new_lock:
- * @dataname: the file that should be covered by the lock
+ * @datafile: the file that should be covered by the lock
* @id: unique linkfile identifier or 0 (default is getpid())
*
* Returns: newly allocated lock handler or NULL on case of error.
free(ml);
}
-/**
- * mnt_lock_get_lockfile:
- * @ml: mnt_lock handler
- *
- * Returns: path to lockfile.
+/*
+ * Returns path to lockfile.
*/
-const char *mnt_lock_get_lockfile(mnt_lock *ml)
+static const char *mnt_lock_get_lockfile(mnt_lock *ml)
{
return ml ? ml->lockfile : NULL;
}
-/**
- * mnt_lock_get_linkfile:
- * @ml: mnt_lock handler
- *
+/*
* Note that the filename is generated by mnt_new_lock() and depends on
* getpid() or 'id' argument of the mnt_new_lock() function.
*
* Returns: unique (per process/thread) path to linkfile.
*/
-const char *mnt_lock_get_linkfile(mnt_lock *ml)
+static const char *mnt_lock_get_linkfile(mnt_lock *ml)
{
return ml ? ml->linkfile : NULL;
}
extern int mnt_match_options(const char *optstr, const char *pattern);
extern const char *mnt_get_fstab_path(void);
extern const char *mnt_get_mtab_path(void);
-
-extern int mnt_get_filesystems(char ***filesystems, const char *pattern);
-extern void mnt_free_filesystems(char **filesystems);
-
extern int mnt_has_regular_mtab(const char **mtab, int *writable);
/* cache.c */
extern int mnt_split_optstr(const char *optstr,
char **user, char **vfs, char **fs,
- int ifnore_user, int ignore_vfs);
+ int ignore_user, int ignore_vfs);
extern int mnt_optstr_get_options(const char *optstr, char **subset,
const struct mnt_optmap *map, int ignore);
MNT_ITER_BACKWARD
};
extern mnt_iter *mnt_new_iter(int direction);
-extern void mnt_free_iter(mnt_iter *mi);
-extern void mnt_reset_iter(mnt_iter *mi, int direction);
+extern void mnt_free_iter(mnt_iter *itr);
+extern void mnt_reset_iter(mnt_iter *itr, int direction);
extern int mnt_iter_get_direction(mnt_iter *itr);
/* optmap.c */
/* lock.c */
extern mnt_lock *mnt_new_lock(const char *datafile, pid_t id);
extern void mnt_free_lock(mnt_lock *ml);
-
-extern const char *mnt_lock_get_lockfile(mnt_lock *ml);
-extern const char *mnt_lock_get_linkfile(mnt_lock *ml);
-
extern void mnt_unlock_file(mnt_lock *ml);
extern int mnt_lock_file(mnt_lock *ml);
/* fs.c */
extern mnt_fs *mnt_new_fs(void);
-extern void mnt_free_fs(mnt_fs *ent);
+extern void mnt_free_fs(mnt_fs *fs);
extern mnt_fs *mnt_copy_fs(const mnt_fs *fs);
-extern mnt_fs *mnt_copy_mtab_fs(const mnt_fs *fs);
extern void *mnt_fs_get_userdata(mnt_fs *fs);
extern int mnt_fs_set_userdata(mnt_fs *fs, void *data);
-extern const char *mnt_fs_get_source(mnt_fs *ent);
-extern int mnt_fs_set_source(mnt_fs *ent, const char *source);
-extern const char *mnt_fs_get_srcpath(mnt_fs *ent);
-extern int mnt_fs_get_tag(mnt_fs *ent, const char **name, const char **value);
-extern const char *mnt_fs_get_target(mnt_fs *ent);
-extern int mnt_fs_set_target(mnt_fs *ent, const char *target);
-extern const char *mnt_fs_get_fstype(mnt_fs *ent);
-extern int mnt_fs_set_fstype(mnt_fs *ent, const char *fstype);
+extern const char *mnt_fs_get_source(mnt_fs *fs);
+extern int mnt_fs_set_source(mnt_fs *fs, const char *source);
+extern const char *mnt_fs_get_srcpath(mnt_fs *fs);
+extern int mnt_fs_get_tag(mnt_fs *fs, const char **name, const char **value);
+extern const char *mnt_fs_get_target(mnt_fs *fs);
+extern int mnt_fs_set_target(mnt_fs *fs, const char *target);
+extern const char *mnt_fs_get_fstype(mnt_fs *fs);
+extern int mnt_fs_set_fstype(mnt_fs *fs, const char *fstype);
extern char *mnt_fs_strdup_options(mnt_fs *fs);
extern int mnt_fs_set_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_get_option(mnt_fs *ent, const char *name,
+extern int mnt_fs_get_option(mnt_fs *fs, const char *name,
char **value, size_t *valsz);
extern int mnt_fs_append_options(mnt_fs *fs, const char *optstr);
extern int mnt_fs_append_attributes(mnt_fs *fs, const char *optstr);
extern int mnt_fs_prepend_attributes(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_get_freq(mnt_fs *ent);
-extern int mnt_fs_set_freq(mnt_fs *ent, int freq);
-extern int mnt_fs_get_passno(mnt_fs *ent);
-extern int mnt_fs_set_passno(mnt_fs *ent, int passno);
+extern int mnt_fs_get_freq(mnt_fs *fs);
+extern int mnt_fs_set_freq(mnt_fs *fs, int freq);
+extern int mnt_fs_get_passno(mnt_fs *fs);
+extern int mnt_fs_set_passno(mnt_fs *fs, int passno);
extern const char *mnt_fs_get_root(mnt_fs *fs);
extern int mnt_fs_set_root(mnt_fs *fs, const char *root);
extern const char *mnt_fs_get_bindsrc(mnt_fs *fs);
extern int mnt_fs_match_source(mnt_fs *fs, const char *source, mnt_cache *cache);
extern int mnt_fs_match_fstype(mnt_fs *fs, const char *types);
extern int mnt_fs_match_options(mnt_fs *fs, const char *options);
-extern int mnt_fs_print_debug(mnt_fs *ent, FILE *file);
+extern int mnt_fs_print_debug(mnt_fs *fs, FILE *file);
extern void mnt_free_mntent(struct mntent *mnt);
extern int mnt_fs_to_mntent(mnt_fs *fs, struct mntent **mnt);
mnt_context_set_userspace_mountflags;
mnt_context_strerror;
mnt_copy_fs;
- mnt_copy_mtab_fs;
mnt_free_cache;
mnt_free_context;
- mnt_free_filesystems;
mnt_free_fs;
mnt_free_iter;
mnt_free_lock;
mnt_fs_to_mntent;
mnt_fstype_is_netfs;
mnt_fstype_is_pseudofs;
- mnt_get_filesystems;
mnt_get_fstab_path;
mnt_get_fstype;
mnt_get_library_version;
mnt_init_debug;
mnt_iter_get_direction;
mnt_lock_file;
- mnt_lock_get_linkfile;
- mnt_lock_get_lockfile;
mnt_mangle;
mnt_match_fstype;
mnt_match_options;
extern int mnt_has_regular_utab(const char **utab, int *writable);
extern const char *mnt_get_utab_path(void);
+extern int mnt_get_filesystems(char ***filesystems, const char *pattern);
+extern void mnt_free_filesystems(char **filesystems);
+
/*
* Generic iterator
*/
extern const struct mnt_optmap *mnt_optmap_get_entry(struct mnt_optmap const **maps,
int nmaps, const char *name,
size_t namelen, const struct mnt_optmap **mapent);
-extern int mnt_optmap_enum_to_number(const struct mnt_optmap *mapent,
- const char *rawdata, size_t len);
-extern const char *mnt_optmap_get_type(const struct mnt_optmap *mapent);
-extern int mnt_optmap_require_value(const struct mnt_optmap *mapent);
/* optstr.c */
extern int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end);
extern int mnt_optstr_fix_user(char **optstr);
/* fs.c */
+extern mnt_fs *mnt_copy_mtab_fs(const mnt_fs *fs);
extern int __mnt_fs_set_source_ptr(mnt_fs *fs, char *source);
extern int __mnt_fs_set_fstype_ptr(mnt_fs *fs, char *fstype);
-extern int __mnt_fs_set_optstr_ptr(mnt_fs *fs, char *optstr, int split);
-extern int __mnt_fs_set_optstr(mnt_fs *fs, const char *optstr, int split);
/* context.c */
extern int mnt_context_prepare_srcpath(mnt_context *cxt);
*
* @mountdata: (usully a comma separated string of options)
*
- * The libmount uses options-map(s) to describe mount options. The number of
- * maps is unlimited. The libmount options parser could be easily extended
- * (e.g. by mnt_optls_add_map()) to work with new options.
+ * The libmount uses options-map(s) to describe mount options.
*
* The option description (map entry) includes:
*
- * @name: and argument type (e.g. "loop[=%s]")
+ * @name: and argument name
*
* @id: (in the map unique identifier or a mountflags, e.g MS_RDONLY)
*
* @mask: (MNT_INVERT, MNT_NOMTAB)
*
- * The option argument type is defined by:
+ * The option argument value is defined by:
*
- * "=type" -- required argument
+ * "=" -- required argument, e.g "comment="
*
- * "[=type]" -- optional argument
- *
- * where the 'type' is sscanf() format string or
- *
- * {item0,item1,...} -- enum (mnt_option_get_number() converts the value
- * to 0..N number)
- *
- * The options argument format is used for parsing only. The library internally
- * stores the option argument as a string. The conversion to the data type is
- * on-demant by mnt_option_get_value_*() functions.
- *
- * The library checks options argument according to 'type' format for simple
- * formats only:
- *
- * %s, %d, %ld, %lld, %u, %lu, %llu, %x, %o and {enum}
+ * "[=]" -- optional argument, e.g. "loop[=]"
*
* Example:
*
* mnt_optmap myoptions[] = {
* { "foo", MY_MS_FOO },
* { "nofoo", MY_MS_FOO | MNT_INVERT },
- * { "bar=%s",MY_MS_BAR },
+ * { "bar=", MY_MS_BAR },
* { NULL }
* };
* </programlisting>
{ "auto", MNT_MS_NOAUTO, MNT_INVERT | MNT_NOMTAB }, /* Can be mounted using -a */
{ "noauto", MNT_MS_NOAUTO, MNT_NOMTAB }, /* Can only be mounted explicitly */
- { "user[=%s]", MNT_MS_USER }, /* Allow ordinary user to mount (mtab) */
+ { "user[=]", MNT_MS_USER }, /* Allow ordinary user to mount (mtab) */
{ "nouser", MNT_MS_USER, MNT_INVERT | MNT_NOMTAB }, /* Forbid ordinary user to mount */
{ "users", MNT_MS_USERS, MNT_NOMTAB }, /* Allow ordinary users to mount */
{ "_netdev", MNT_MS_NETDEV }, /* Device requires network */
- { "comment=%s", MNT_MS_COMMENT, MNT_NOMTAB }, /* fstab comment only */
+ { "comment=", MNT_MS_COMMENT, MNT_NOMTAB }, /* fstab comment only */
- { "loop[=%s]", MNT_MS_LOOP }, /* use the loop device */
+ { "loop[=]", MNT_MS_LOOP }, /* use the loop device */
{ "nofail", MNT_MS_NOFAIL, MNT_NOMTAB }, /* Do not fail if ENOENT on dev */
- { "uhelper=%s", MNT_MS_UHELPER }, /* /sbin/umount.<helper> */
+ { "uhelper=", MNT_MS_UHELPER }, /* /sbin/umount.<helper> */
{ NULL, 0, 0 }
};
return NULL;
}
-
-/*
- * Converts @rawdata to number according to enum definition in the @mapent.
- */
-int mnt_optmap_enum_to_number(const struct mnt_optmap *mapent,
- const char *rawdata, size_t len)
-{
- const char *p, *end = NULL, *begin = NULL;
- int n = -1;
-
- if (!rawdata || !*rawdata || !mapent || !len)
- return -EINVAL;
-
- p = strrchr(mapent->name, '=');
- if (!p || *(p + 1) == '{')
- return -EINVAL; /* value unexpected or not "enum" */
- p += 2;
- if (!*p || *(p + 1) == '}')
- return -EINVAL; /* hmm... option <type> is "={" or "={}" */
-
- /* we cannot use strstr(), @rawdata is not terminated */
- for (; p && *p; p++) {
- if (!begin)
- begin = p; /* begin of the item */
- if (*p == ',')
- end = p; /* terminate the item */
- if (*(p + 1) == '}')
- end = p + 1; /* end of enum definition */
- if (!begin || !end)
- continue;
- if (end <= begin)
- return -EINVAL;
- n++;
- if (len == end - begin && strncasecmp(begin, rawdata, len) == 0)
- return n;
- p = end;
- }
-
- return -1;
-}
-
-/*
- * Returns data type defined in the @mapent.
- */
-const char *mnt_optmap_get_type(const struct mnt_optmap *mapent)
-{
- char *type;
-
- assert(mapent);
- assert(mapent->name);
-
- type = strrchr(mapent->name, '=');
- if (!type)
- return NULL; /* value is unexpected */
- if (type == mapent->name)
- return NULL; /* wrong format of type definition */
- type++;
- if (*type != '%' && *type != '{')
- return NULL; /* wrong format of type definition */
- return type ? : NULL;
-}
-
-/*
- * Does the option (that is described by @mntent) require any value? (e.g.
- * uid=<foo>)
- */
-int mnt_optmap_require_value(const struct mnt_optmap *mapent)
-{
- char *type;
-
- assert(mapent);
- assert(mapent->name);
-
- type = strchr(mapent->name, '=');
- if (!type)
- return 0; /* value is unexpected */
- if (type == mapent->name)
- return 0; /* wrong format of type definition */
- if (*(type - 1) == '[')
- return 0; /* optional */
- return 1;
-}
*
* Returns: 0 on success, or 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)
+int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs, int ignore_user, int ignore_vfs)
{
char *name, *val, *str = (char *) optstr;
size_t namesz, valsz;
* mnt_optstr_get_flags:
* @optstr: string with comma separated list of options
* @flags: returns mount flags
+ * @map: options map
*
* Returns in @flags IDs of options from @optstr as defined in the @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 mnt_optmap *map)
{
}
/**
- * mnt_optstr_apply_mountflags:
+ * mnt_optstr_apply_flags:
* @optstr: string with comma separated list of options
* @flags: returns mount flags
* @map: options map
p = strchr(ent->name, '=');
if (p) {
if (*(p - 1) == '[')
- p--; /* name[=%s] */
+ p--; /* name[=] */
else
- continue; /* name=%s */
+ continue; /* name= */
p = strndup(ent->name, p - ent->name);
if (!p) {
/**
* SECTION: tab
- * @title: FS container
+ * @title: Table of filesystems
* @short_description: container for entries from fstab/mtab/mountinfo
*
*
*
* Returns: 0 on success, negative number in case of error or 1 at end of list.
*
- * Example (list all mountpoints from fstab in backward order):
+ * Example:
* <informalexample>
* <programlisting>
* mnt_fs *fs;
* mnt_free_tab(fi);
* </programlisting>
* </informalexample>
+ *
+ * lists all mountpoints from fstab in backward order.
*/
int mnt_tab_next_fs(mnt_tab *tb, mnt_iter *itr, mnt_fs **fs)
{
/**
* mnt_tab_set_parser_errcb:
- * @tab: pointer to table
+ * @tb: pointer to table
* @cb: pointer to callback function
*
* The error callback function is called by table parser (mnt_tab_parse_file())
/**
* SECTION: update
- * @title: mtab (fstab) managment
- * @short_description: userspace mount information management
+ * @title: mtab managment
+ * @short_description: userspace mount information management.
+ *
+ * The mnt_update provides abstraction to manage mount options in userspace independently on
+ * system configuration. This low-level API works on system with and without /etc/mtab. On
+ * systems without the regular /etc/mtab file are userspace mount options (e.g. user=)
+ * stored to the /dev/.mount/utab file.
+ *
+ * It's recommended to use high-level mnt_context API.
*/
#include <stdio.h>
/**
* mnt_update_tab:
+ * @upd: update
* @lc: lock
*
* High-level API to update /etc/mtab (or private /dev/.mount/utab file).
* mnt_get_mtab_path:
*
* This function returns *default* location of the mtab file. The result does
- * not have to be writable. See also mnt_get_writable_mtab_path().
+ * not have to be writable. See also mnt_has_regular_mtab().
*
* Returns: path to /etc/mtab or $LIBMOUNT_MTAB.
*/