/*
* findmnt(8)
*
- * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010,2011 Red Hat, Inc. All rights reserved.
* Written by Karel Zak <kzak@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
int ncolumns;
/* libmount cache */
-mnt_cache *cache;
+struct libmnt_cache *cache;
static int get_column_id(int num)
{
}
/* Returns LABEL or UUID */
-static const char *get_tag(mnt_fs *fs, const char *tagname)
+static const char *get_tag(struct libmnt_fs *fs, const char *tagname)
{
const char *t, *v, *res;
/* reads FS data from libmount
* TODO: add function that will deallocate data allocated by get_data()
*/
-static const char *get_data(mnt_fs *fs, int num)
+static const char *get_data(struct libmnt_fs *fs, int num)
{
const char *str = NULL;
char *tmp;
int rc = 0;
if (tt_flags & TT_FL_RAW)
- rc = asprintf(&tmp, "%u:%u", major(devno), minor(devno));
+ rc = asprintf(&tmp, "%u:%u",
+ major(devno), minor(devno));
else
- rc = asprintf(&tmp, "%3u:%-3u", major(devno), minor(devno));
+ rc = asprintf(&tmp, "%3u:%-3u",
+ major(devno), minor(devno));
if (rc)
str = tmp;
}
}
/* adds one line to the output @tab */
-static struct tt_line *add_line(struct tt *tt, mnt_fs *fs,
+static struct tt_line *add_line(struct tt *tt, struct libmnt_fs *fs,
struct tt_line *parent)
{
int i;
return line;
}
-static int has_line(struct tt *tt, mnt_fs *fs)
+static int has_line(struct tt *tt, struct libmnt_fs *fs)
{
struct list_head *p;
list_for_each(p, &tt->tb_lines) {
struct tt_line *ln = list_entry(p, struct tt_line, ln_lines);
- if ((mnt_fs *) ln->userdata == fs)
+ if ((struct libmnt_fs *) ln->userdata == fs)
return 1;
}
return 0;
}
/* reads filesystems from @tb (libmount) and fillin @tt (output table) */
-static int create_treenode(struct tt *tt, mnt_tab *tb,
- mnt_fs *fs, struct tt_line *parent_line)
+static int create_treenode(struct tt *tt, struct libmnt_table *tb,
+ struct libmnt_fs *fs, struct tt_line *parent_line)
{
- mnt_fs *chld = NULL;
- mnt_iter *itr = NULL;
+ struct libmnt_fs *chld = NULL;
+ struct libmnt_iter *itr = NULL;
struct tt_line *line;
int rc = -1;
if (!fs) {
/* first call, get root FS */
- if (mnt_tab_get_root_fs(tb, &fs))
+ if (mnt_table_get_root_fs(tb, &fs))
goto leave;
parent_line = NULL;
/*
* add all children to the output table
*/
- while(mnt_tab_next_child_fs(tb, itr, fs, &chld) == 0) {
+ while(mnt_table_next_child_fs(tb, itr, fs, &chld) == 0) {
if (create_treenode(tt, tb, chld, line))
goto leave;
}
}
/* error callback */
-static int parser_errcb(mnt_tab *tb, const char *filename, int line)
+static int parser_errcb(struct libmnt_table *tb, const char *filename, int line)
{
warn(_("%s: parse error at line %d"), filename, line);
return 0;
}
/* calls libmount fstab/mtab/mountinfo parser */
-static mnt_tab *parse_tabfile(const char *path)
+static struct libmnt_table *parse_tabfile(const char *path)
{
int rc;
- mnt_tab *tb = mnt_new_tab();
+ struct libmnt_table *tb = mnt_new_table();
if (!tb) {
warn(_("failed to initialize libmount tab"));
return NULL;
}
- mnt_tab_set_parser_errcb(tb, parser_errcb);
+ mnt_table_set_parser_errcb(tb, parser_errcb);
if (!strcmp(path, _PATH_MNTTAB))
- rc = mnt_tab_parse_fstab(tb, NULL);
+ rc = mnt_table_parse_fstab(tb, NULL);
else if (!strcmp(path, _PATH_MOUNTED))
- rc = mnt_tab_parse_mtab(tb, NULL);
+ rc = mnt_table_parse_mtab(tb, NULL);
else
- rc = mnt_tab_parse_file(tb, path);
+ rc = mnt_table_parse_file(tb, path);
if (rc) {
- mnt_free_tab(tb);
+ mnt_free_table(tb);
warn(_("can't read: %s"), path);
return NULL;
}
return tb;
}
-/* filter function for libmount (mnt_tab_find_next_fs()) */
-static int match_func(mnt_fs *fs, void *data)
+/* filter function for libmount (mnt_table_find_next_fs()) */
+static int match_func(struct libmnt_fs *fs, void *data)
{
int rc = flags & FL_INVERT ? 1 : 0;
const char *m;
}
/* iterate over filesystems in @tb */
-static mnt_fs *get_next_fs(mnt_tab *tb, mnt_iter *itr)
+static struct libmnt_fs *get_next_fs(struct libmnt_table *tb,
+ struct libmnt_iter *itr)
{
- mnt_fs *fs = NULL;
+ struct libmnt_fs *fs = NULL;
if (is_listall_mode()) {
/*
* Print whole file
*/
- mnt_tab_next_fs(tb, itr, &fs);
+ mnt_table_next_fs(tb, itr, &fs);
} else if (is_mount_compatible_mode()) {
/*
*
* findmnt -f <spec>
*/
- fs = mnt_tab_find_source(tb, get_match(COL_SOURCE),
+ fs = mnt_table_find_source(tb, get_match(COL_SOURCE),
mnt_iter_get_direction(itr));
if (!fs && !(flags & FL_NOSWAPMATCH))
- fs = mnt_tab_find_target(tb, get_match(COL_SOURCE),
+ fs = mnt_table_find_target(tb, get_match(COL_SOURCE),
mnt_iter_get_direction(itr));
} else {
/*
* findmnt [-l] <spec> [-O <options>] [-t <types>]
*/
again:
- mnt_tab_find_next_fs(tb, itr, match_func, NULL, &fs);
+ mnt_table_find_next_fs(tb, itr, match_func, NULL, &fs);
if (!fs &&
!(flags & FL_NOSWAPMATCH) &&
return fs;
}
-static int add_matching_lines(mnt_tab *tb, struct tt *tt, int direction)
+static int add_matching_lines(struct libmnt_table *tb,
+ struct tt *tt, int direction)
{
- mnt_iter *itr = NULL;
- mnt_fs *fs;
+ struct libmnt_iter *itr = NULL;
+ struct libmnt_fs *fs;
int nlines = 0, rc = -1;
itr = mnt_new_iter(direction);
int main(int argc, char *argv[])
{
/* libmount */
- mnt_tab *tb = NULL;
+ struct libmnt_table *tb = NULL;
char *tabfile = NULL;
int direction = MNT_ITER_FORWARD;
int i, c, rc = -1;
warn(_("failed to initialize libmount cache"));
goto leave;
}
- mnt_tab_set_cache(tb, cache);
+ mnt_table_set_cache(tb, cache);
/*
* initialize output formatting (tt.h)
leave:
tt_free_table(tt);
- mnt_free_tab(tb);
+ mnt_free_table(tb);
mnt_free_cache(cache);
return rc ? EXIT_FAILURE : EXIT_SUCCESS;
static void read_mounttable()
{
struct mntentchn *mc0 = &mounttable, *mc = mc0;
- mnt_tab *tb = mnt_new_tab();
- mnt_iter *itr = mnt_new_iter(MNT_ITER_FORWARD);
- mnt_fs *fs;
+ struct libmnt_table *tb = mnt_new_table();
+ struct libmnt_iter *itr = mnt_new_iter(MNT_ITER_FORWARD);
+ struct libmnt_fs *fs;
got_mtab = 1;
mc->nxt = mc->prev = NULL;
if (!tb || !itr)
goto err;
- if (mnt_tab_parse_mtab(tb, NULL))
+ if (mnt_table_parse_mtab(tb, NULL))
goto err;
- while(mnt_tab_next_fs(tb, itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, itr, &fs) == 0) {
const char *type = mnt_fs_get_fstype(fs);
struct my_mntent *mnt = NULL;
return;
err:
error(_("warning: failed to read mtab"));
- mnt_free_tab(tb);
+ mnt_free_table(tb);
mnt_free_iter(itr);
mc->nxt = mc->prev = NULL;
}
}
#ifdef HAVE_LIBMOUNT_MOUNT
-static mnt_lock *libmount_lock;
+static struct libmnt_lock *libmount_lock;
-mnt_lock *
+struct libmnt_lock *
init_libmount_lock(const char *filename)
{
if (filename)
#ifdef HAVE_LIBMOUNT_MOUNT
#define USE_UNSTABLE_LIBMOUNT_API
#include <libmount.h>
-extern mnt_lock *init_libmount_lock(const char *filename);
+extern struct libmnt_lock *init_libmount_lock(const char *filename);
#endif
int mtab_is_writable(void);
static int pfd = -1;
#ifdef HAVE_LIBMOUNT_MOUNT
-static mnt_update *mtab_update;
+static struct libmnt_update *mtab_update;
static char *mtab_opts;
static unsigned long mtab_flags;
prepare_mtab_entry(const char *spec, const char *node, const char *type,
const char *opts, unsigned long flags)
{
- mnt_fs *fs = mnt_new_fs();
+ struct libmnt_fs *fs = mnt_new_fs();
int rc = -1;
if (!mtab_update)
static void update_mtab_entry(int flags)
{
unsigned long fl;
- mnt_lock *lc;
+ struct libmnt_lock *lc;
if (!mtab_update)
return;
- fl = mnt_update_get_mountflags(mtab_update);
+ fl = mnt_update_get_mflags(mtab_update);
if ((flags & MS_RDONLY) != (fl & MS_RDONLY))
mnt_update_force_rdonly(mtab_update, flags & MS_RDONLY);
}
lc = init_libmount_lock( mnt_update_get_filename(mtab_update) );
- mnt_update_tab(mtab_update, lc);
+ mnt_update_table(mtab_update, lc);
init_libmount_lock(NULL);
}
if (!nomtab &&
(umnt_err == 0 || umnt_err == EINVAL || umnt_err == ENOENT)) {
#ifdef HAVE_LIBMOUNT_MOUNT
- mnt_update *upd = mnt_new_update();
+ struct libmnt_update *upd = mnt_new_update();
if (upd && !mnt_update_set_fs(upd, 0, node, NULL)) {
- mnt_lock *lc = init_libmount_lock(
+ struct libmnt_lock *lc = init_libmount_lock(
mnt_update_get_filename(upd));
- mnt_update_tab(upd, lc);
+ mnt_update_table(upd, lc);
init_libmount_lock(NULL);
}
mnt_free_update(upd);
<SECTION>
<FILE>cache</FILE>
-mnt_cache
mnt_cache_device_has_tag
mnt_cache_find_tag_value
mnt_cache_read_tags
<SECTION>
<FILE>iter</FILE>
-mnt_iter
mnt_free_iter
mnt_iter_get_direction
mnt_new_iter
<SECTION>
<FILE>optmap</FILE>
-struct mnt_optmap
mnt_get_builtin_optmap
</SECTION>
<SECTION>
<FILE>lock</FILE>
-mnt_lock
mnt_free_lock
mnt_lock_file
mnt_new_lock
<SECTION>
<FILE>fs</FILE>
-mnt_fs
mnt_copy_fs
mnt_free_fs
mnt_free_mntent
mnt_fs_append_attributes
mnt_fs_append_fs_options
mnt_fs_append_options
-mnt_fs_append_userspace_options
+mnt_fs_append_user_options
mnt_fs_append_vfs_options
mnt_fs_get_attribute
mnt_fs_get_attributes
mnt_fs_get_tag
mnt_fs_get_target
mnt_fs_get_userdata
-mnt_fs_get_userspace_options
+mnt_fs_get_user_options
mnt_fs_get_vfs_options
mnt_fs_match_fstype
mnt_fs_match_options
mnt_fs_prepend_attributes
mnt_fs_prepend_fs_options
mnt_fs_prepend_options
-mnt_fs_prepend_userspace_options
+mnt_fs_prepend_user_options
mnt_fs_prepend_vfs_options
mnt_fs_print_debug
mnt_fs_set_attributes
mnt_fs_set_source
mnt_fs_set_target
mnt_fs_set_userdata
-mnt_fs_set_userspace_options
+mnt_fs_set_user_options
mnt_fs_set_vfs_options
mnt_fs_strdup_options
mnt_new_fs
<SECTION>
<FILE>tab</FILE>
-mnt_tab
-mnt_free_tab
-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_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_set_parser_errcb
+mnt_free_table
+mnt_new_table
+mnt_new_table_from_dir
+mnt_new_table_from_file
+mnt_table_add_fs
+mnt_table_find_next_fs
+mnt_table_find_pair
+mnt_table_find_source
+mnt_table_find_srcpath
+mnt_table_find_tag
+mnt_table_find_target
+mnt_table_get_cache
+mnt_table_get_name
+mnt_table_get_nents
+mnt_table_get_root_fs
+mnt_table_next_child_fs
+mnt_table_next_fs
+mnt_table_parse_file
+mnt_table_parse_fstab
+mnt_table_parse_mtab
+mnt_table_parse_stream
+mnt_table_remove_fs
+mnt_table_set_cache
+mnt_table_set_iter
+mnt_table_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_get_mflags
mnt_update_is_ready
mnt_update_set_fs
-mnt_update_tab
+mnt_update_table
</SECTION>
<SECTION>
<FILE>context</FILE>
-mnt_context
mnt_context_append_options
mnt_context_apply_fstab
mnt_context_disable_canonicalize
mnt_context_get_fs
mnt_context_get_fstab
mnt_context_get_lock
-mnt_context_get_mountflags
+mnt_context_get_mflags
mnt_context_get_mtab
mnt_context_get_status
-mnt_context_get_userspace_mountflags
+mnt_context_get_user_mflags
mnt_context_is_restricted
mnt_context_set_cache
mnt_context_set_fs
mnt_context_set_fstype
mnt_context_set_fstype_pattern
mnt_context_set_mountdata
-mnt_context_set_mountflags
+mnt_context_set_mflags
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_set_user_mflags
mnt_context_strerror
mnt_free_context
mnt_new_context
#define EX_FAIL 32 /* mount failure */
#define EX_SOMEOK 64 /* some mount succeeded */
-static mnt_lock *lock;
+static struct libmnt_lock *lock;
static void lock_atexit_cleanup(void)
{
return NULL;
}
-static int print_all(mnt_context *cxt, char *pattern, int show_label)
+static int print_all(struct libmnt_context *cxt, char *pattern, int show_label)
{
int rc = 0;
- mnt_tab *tb;
- mnt_iter *itr;
- mnt_fs *fs;
- mnt_cache *cache = NULL;
+ struct libmnt_table *tb;
+ struct libmnt_iter *itr;
+ struct libmnt_fs *fs;
+ struct libmnt_cache *cache = NULL;
rc = mnt_context_get_mtab(cxt, &tb);
if (rc)
if (show_label)
cache = mnt_new_cache();
- while(mnt_tab_next_fs(tb, itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, itr, &fs) == 0) {
const char *type = mnt_fs_get_fstype(fs);
const char *src = mnt_fs_get_source(fs);
char *optstr = mnt_fs_strdup_options(fs);
int main(int argc, char **argv)
{
int c, rc = EXIT_FAILURE, all = 0, show_labels = 0;
- mnt_context *cxt;
+ struct libmnt_context *cxt;
char *source = NULL, *srcbuf = NULL;
char *types = NULL;
unsigned long oper = 0;
usage(stderr);
if (oper)
- mnt_context_set_mountflags(cxt, oper);
+ mnt_context_set_mflags(cxt, oper);
lock = mnt_context_get_lock(cxt);
if (lock)
int flag;
};
-struct _mnt_cache {
+struct libmnt_cache {
struct mnt_cache_entry *ents;
size_t nents;
size_t nallocs;
/**
* mnt_new_cache:
*
- * Returns: new mnt_cache instance or NULL in case of ENOMEM error.
+ * Returns: new struct libmnt_cache instance or NULL in case of ENOMEM error.
*/
-mnt_cache *mnt_new_cache(void)
+struct libmnt_cache *mnt_new_cache(void)
{
- mnt_cache *cache = calloc(1, sizeof(struct _mnt_cache));
+ struct libmnt_cache *cache = calloc(1, sizeof(*cache));
if (!cache)
return NULL;
DBG(CACHE, mnt_debug_h(cache, "alloc"));
/**
* mnt_free_cache:
- * @cache: pointer to mnt_cache instance
+ * @cache: pointer to struct libmnt_cache instance
*
* Deallocates the cache.
*/
-void mnt_free_cache(mnt_cache *cache)
+void mnt_free_cache(struct libmnt_cache *cache)
{
int i;
}
/* note that the @native could be tha same pointer as @real */
-static int mnt_cache_add_entry(mnt_cache *cache, char *native,
+static int mnt_cache_add_entry(struct libmnt_cache *cache, char *native,
char *real, int flag)
{
struct mnt_cache_entry *e;
}
/* add tag to the cache, @real has to be allocated string */
-static int mnt_cache_add_tag(mnt_cache *cache, const char *token,
+static int mnt_cache_add_tag(struct libmnt_cache *cache, const char *token,
const char *value, char *real, int flag)
{
size_t tksz, vlsz;
/*
* Returns cached canonicalized path or NULL.
*/
-static const char *mnt_cache_find_path(mnt_cache *cache, const char *path)
+static const char *mnt_cache_find_path(struct libmnt_cache *cache, const char *path)
{
int i;
/*
* Returns cached path or NULL.
*/
-static const char *mnt_cache_find_tag(mnt_cache *cache,
+static const char *mnt_cache_find_tag(struct libmnt_cache *cache,
const char *token, const char *value)
{
int i;
/*
* returns (in @res) blkid prober, the @cache argument is optional
*/
-static int mnt_cache_get_probe(mnt_cache *cache, const char *devname,
+static int mnt_cache_get_probe(struct libmnt_cache *cache, const char *devname,
blkid_probe *res)
{
blkid_probe pr = cache ? cache->pr : NULL;
/**
* mnt_cache_read_tags
- * @cache: pointer to mnt_cache instance
+ * @cache: pointer to struct libmnt_cache instance
* @devname: path device
*
* Reads @devname LABEL and UUID to the @cache.
* Returns: 0 if at least one tag was added, 1 if no tag was added or
* negative number in case of error.
*/
-int mnt_cache_read_tags(mnt_cache *cache, const char *devname)
+int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname)
{
int i, ntags = 0, rc;
blkid_probe pr;
*
* Returns: 1 on success or 0.
*/
-int mnt_cache_device_has_tag(mnt_cache *cache, const char *devname,
+int mnt_cache_device_has_tag(struct libmnt_cache *cache, const char *devname,
const char *token, const char *value)
{
const char *path = mnt_cache_find_tag(cache, token, value);
*
* Returns: LABEL or UUID for the @devname or NULL in case of error.
*/
-char *mnt_cache_find_tag_value(mnt_cache *cache,
+char *mnt_cache_find_tag_value(struct libmnt_cache *cache,
const char *devname, const char *token)
{
int i;
* Returns: filesystem type or NULL in case of error. The result has to be
* deallocated by free() if @cache is NULL.
*/
-char *mnt_get_fstype(const char *devname, int *ambi, mnt_cache *cache)
+char *mnt_get_fstype(const char *devname, int *ambi, struct libmnt_cache *cache)
{
blkid_probe pr;
const char *data;
* Returns: absolute path or NULL in case of error. The result has to be
* deallocated by free() if @cache is NULL.
*/
-char *mnt_resolve_path(const char *path, mnt_cache *cache)
+char *mnt_resolve_path(const char *path, struct libmnt_cache *cache)
{
char *p = NULL;
char *native = NULL;
* Returns: device name or NULL in case of error. The result has to be
* deallocated by free() if @cache is NULL.
*/
-char *mnt_resolve_tag(const char *token, const char *value, mnt_cache *cache)
+char *mnt_resolve_tag(const char *token, const char *value,
+ struct libmnt_cache *cache)
{
char *p = NULL;
* Returns: canonicalized path or NULL. The result has to be
* deallocated by free() if @cache is NULL.
*/
-char *mnt_resolve_spec(const char *spec, mnt_cache *cache)
+char *mnt_resolve_spec(const char *spec, struct libmnt_cache *cache)
{
char *cn = NULL;
#ifdef TEST_PROGRAM
-int test_resolve_path(struct mtest *ts, int argc, char *argv[])
+int test_resolve_path(struct libmnt_test *ts, int argc, char *argv[])
{
char line[BUFSIZ];
- mnt_cache *cache;
+ struct libmnt_cache *cache;
cache = mnt_new_cache();
if (!cache)
return 0;
}
-int test_resolve_spec(struct mtest *ts, int argc, char *argv[])
+int test_resolve_spec(struct libmnt_test *ts, int argc, char *argv[])
{
char line[BUFSIZ];
- mnt_cache *cache;
+ struct libmnt_cache *cache;
cache = mnt_new_cache();
if (!cache)
return 0;
}
-int test_read_tags(struct mtest *ts, int argc, char *argv[])
+int test_read_tags(struct libmnt_test *ts, int argc, char *argv[])
{
char line[BUFSIZ];
- mnt_cache *cache;
+ struct libmnt_cache *cache;
int i;
cache = mnt_new_cache();
int main(int argc, char *argv[])
{
- struct mtest ts[] = {
+ struct libmnt_test ts[] = {
{ "--resolve-path", test_resolve_path, " resolve paths from stdin" },
{ "--resolve-spec", test_resolve_spec, " evaluate specs from stdin" },
{ "--read-tags", test_read_tags, " read devname or TAG from stdin (\"quit\" to exit)" },
*
* <informalexample>
* <programlisting>
- * mnt_context *cxt = mnt_new_context();
+ * struct libmnt_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_mflags(cxt, MS_NOATIME|MS_NOEXEC);
* mnt_context_set_target(cxt, "/mnt/foo");
*
* if (!mnt_context_do_mount(cxt))
*
* Returns: newly allocated mount context
*/
-mnt_context *mnt_new_context(void)
+struct libmnt_context *mnt_new_context(void)
{
- mnt_context *cxt;
+ struct libmnt_context *cxt;
uid_t ruid, euid;
cxt = calloc(1, sizeof(*cxt));
*
* Deallocates context struct.
*/
-void mnt_free_context(mnt_context *cxt)
+void mnt_free_context(struct libmnt_context *cxt)
{
if (!cxt)
return;
free(cxt->optstr_pattern);
if (!(cxt->flags & MNT_FL_EXTERN_FSTAB))
- mnt_free_tab(cxt->fstab);
+ mnt_free_table(cxt->fstab);
if (!(cxt->flags & MNT_FL_EXTERN_CACHE))
mnt_free_cache(cxt->cache);
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_reset_context(mnt_context *cxt)
+int mnt_reset_context(struct libmnt_context *cxt)
{
int fl;
if (!(cxt->flags & MNT_FL_EXTERN_FS))
mnt_free_fs(cxt->fs);
- mnt_free_tab(cxt->mtab);
+ mnt_free_table(cxt->mtab);
free(cxt->helper);
free(cxt->orig_user);
return 0;
}
-static int set_flag(mnt_context *cxt, int flag, int enable)
+static int set_flag(struct libmnt_context *cxt, int flag, int enable)
{
if (!cxt)
return -EINVAL;
*
* Returns: 0 for unrestricted mount (user is root), or 1 for non-root mounts
*/
-int mnt_context_is_restricted(mnt_context *cxt)
+int mnt_context_is_restricted(struct libmnt_context *cxt)
{
assert(cxt);
return cxt->restricted;
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_optsmode(mnt_context *cxt, int mode)
+int mnt_context_set_optsmode(struct libmnt_context *cxt, int mode)
{
if (!cxt)
return -EINVAL;
* Returns: MNT_OMASK_* mask or zero.
*/
-int mnt_context_get_optsmode(mnt_context *cxt)
+int mnt_context_get_optsmode(struct libmnt_context *cxt)
{
return cxt ? cxt->optsmode : 0;
}
*
* This fuction has effect to the private fstab instance only (see
* mnt_context_set_fstab()). If you want to use an external fstab then you need
- * manage your private mnt_cache (see mnt_tab_set_cache(fstab, NULL).
+ * manage your private struct libmnt_cache (see mnt_table_set_cache(fstab, NULL).
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_disable_canonicalize(mnt_context *cxt, int disable)
+int mnt_context_disable_canonicalize(struct libmnt_context *cxt, int disable)
{
return set_flag(cxt, MNT_FL_NOCANONICALIZE, disable);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_lazy(mnt_context *cxt, int enable)
+int mnt_context_enable_lazy(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_LAZY, enable);
}
*
* Returns: 1 if lazy umount is enabled or 0
*/
-int mnt_context_is_lazy(mnt_context *cxt)
+int mnt_context_is_lazy(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_LAZY) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_rdonly_umount(mnt_context *cxt, int enable)
+int mnt_context_enable_rdonly_umount(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_RDONLY_UMOUNT, enable);
}
*
* Returns: 1 if read-only remount failed umount(2) is enables or 0
*/
-int mnt_context_is_rdonly_umount(mnt_context *cxt)
+int mnt_context_is_rdonly_umount(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_RDONLY_UMOUNT) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_disable_helpers(mnt_context *cxt, int disable)
+int mnt_context_disable_helpers(struct libmnt_context *cxt, int disable)
{
return set_flag(cxt, MNT_FL_NOHELPERS, disable);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_sloppy(mnt_context *cxt, int enable)
+int mnt_context_enable_sloppy(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_SLOPPY, enable);
}
*
* Returns: 1 if sloppy flag is enabled or 0
*/
-int mnt_context_is_sloppy(mnt_context *cxt)
+int mnt_context_is_sloppy(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_SLOPPY) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_fake(mnt_context *cxt, int enable)
+int mnt_context_enable_fake(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_FAKE, enable);
}
*
* Returns: 1 if fake flag is enabled or 0
*/
-int mnt_context_is_fake(mnt_context *cxt)
+int mnt_context_is_fake(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_FAKE) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_disable_mtab(mnt_context *cxt, int disable)
+int mnt_context_disable_mtab(struct libmnt_context *cxt, int disable)
{
return set_flag(cxt, MNT_FL_NOMTAB, disable);
}
*
* Returns: 1 if no-mtab is enabled or 0
*/
-int mnt_context_is_nomtab(mnt_context *cxt)
+int mnt_context_is_nomtab(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_NOMTAB) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_force(mnt_context *cxt, int enable)
+int mnt_context_enable_force(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_FORCE, enable);
}
*
* Returns: 1 if force umounting flag is enabled or 0
*/
-int mnt_context_is_force(mnt_context *cxt)
+int mnt_context_is_force(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_FORCE) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_verbose(mnt_context *cxt, int enable)
+int mnt_context_enable_verbose(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_VERBOSE, enable);
}
*
* Returns: 1 if verbose flag is enabled or 0
*/
-int mnt_context_is_verbose(mnt_context *cxt)
+int mnt_context_is_verbose(struct libmnt_context *cxt)
{
return cxt && (cxt->flags & MNT_FL_VERBOSE) ? 1 : 0;
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_enable_loopdel(mnt_context *cxt, int enable)
+int mnt_context_enable_loopdel(struct libmnt_context *cxt, int enable)
{
return set_flag(cxt, MNT_FL_LOOPDEL, enable);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_fs(mnt_context *cxt, mnt_fs *fs)
+int mnt_context_set_fs(struct libmnt_context *cxt, struct libmnt_fs *fs)
{
if (!cxt)
return -EINVAL;
*
* Returns: pointer to FS description or NULL in case of calloc() errrr.
*/
-mnt_fs *mnt_context_get_fs(mnt_context *cxt)
+struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt)
{
if (!cxt)
return NULL;
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_source(mnt_context *cxt, const char *source)
+int mnt_context_set_source(struct libmnt_context *cxt, const char *source)
{
return mnt_fs_set_source(mnt_context_get_fs(cxt), source);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_target(mnt_context *cxt, const char *target)
+int mnt_context_set_target(struct libmnt_context *cxt, const char *target)
{
return mnt_fs_set_target(mnt_context_get_fs(cxt), target);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_fstype(mnt_context *cxt, const char *fstype)
+int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype)
{
if (fstype && strchr(fstype, ','))
return -EINVAL;
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_options(mnt_context *cxt, const char *optstr)
+int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr)
{
return mnt_fs_set_options(mnt_context_get_fs(cxt), optstr);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_append_options(mnt_context *cxt, const char *optstr)
+int mnt_context_append_options(struct libmnt_context *cxt, const char *optstr)
{
return mnt_fs_append_options(mnt_context_get_fs(cxt), optstr);
}
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_fstype_pattern(mnt_context *cxt, const char *pattern)
+int mnt_context_set_fstype_pattern(struct libmnt_context *cxt, const char *pattern)
{
char *p = NULL;
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_options_pattern(mnt_context *cxt, const char *pattern)
+int mnt_context_set_options_pattern(struct libmnt_context *cxt, const char *pattern)
{
char *p = NULL;
* @cxt: mount context
* @tb: fstab
*
- * The mount context reads /etc/fstab to the the private mnt_tab by default.
+ * The mount context reads /etc/fstab to the the private struct libmnt_table by default.
* This function allows to overwrite the private fstab with an external
* instance. Note that the external instance is not deallocated by mnt_free_context().
*
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_fstab(mnt_context *cxt, mnt_tab *tb)
+int mnt_context_set_fstab(struct libmnt_context *cxt, struct libmnt_table *tb)
{
if (!cxt)
return -EINVAL;
if (!(cxt->flags & MNT_FL_EXTERN_FSTAB))
- mnt_free_tab(cxt->fstab);
+ mnt_free_table(cxt->fstab);
set_flag(cxt, MNT_FL_EXTERN_FSTAB, tb != NULL);
cxt->fstab = tb;
* @cxt: mount context
* @tb: returns fstab
*
- * See also mnt_tab_parse_fstab() for more details about fstab.
+ * See also mnt_table_parse_fstab() for more details about fstab.
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_get_fstab(mnt_context *cxt, mnt_tab **tb)
+int mnt_context_get_fstab(struct libmnt_context *cxt, struct libmnt_table **tb)
{
- mnt_cache *cache;
+ struct libmnt_cache *cache;
if (!cxt)
return -EINVAL;
if (!cxt->fstab) {
int rc;
- cxt->fstab = mnt_new_tab();
+ cxt->fstab = mnt_new_table();
if (!cxt->fstab)
return -ENOMEM;
cxt->flags &= ~MNT_FL_EXTERN_FSTAB;
- rc = mnt_tab_parse_fstab(cxt->fstab, NULL);
+ rc = mnt_table_parse_fstab(cxt->fstab, NULL);
if (rc)
return rc;
}
/* never touch an external fstab */
if (!(cxt->flags & MNT_FL_EXTERN_FSTAB))
- mnt_tab_set_cache(cxt->fstab, cache);
+ mnt_table_set_cache(cxt->fstab, cache);
if (tb)
*tb = cxt->fstab;
* @cxt: mount context
* @tb: returns mtab
*
- * See also mnt_tab_parse_mtab() for more details about mtab/mountinfo.
+ * See also mnt_table_parse_mtab() for more details about mtab/mountinfo.
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_get_mtab(mnt_context *cxt, mnt_tab **tb)
+int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
{
- mnt_cache *cache;
+ struct libmnt_cache *cache;
if (!cxt)
return -EINVAL;
if (!cxt->mtab) {
int rc;
- cxt->mtab = mnt_new_tab();
+ cxt->mtab = mnt_new_table();
if (!cxt->mtab)
return -ENOMEM;
- rc = mnt_tab_parse_mtab(cxt->mtab, cxt->mtab_path);
+ rc = mnt_table_parse_mtab(cxt->mtab, cxt->mtab_path);
if (rc)
return rc;
}
cache = mnt_context_get_cache(cxt);
- mnt_tab_set_cache(cxt->mtab, cache);
+ mnt_table_set_cache(cxt->mtab, cache);
if (tb)
*tb = cxt->mtab;
* @cxt: mount context
* @cache: cache instance or nULL
*
- * The mount context maintains a private mnt_cache by default. This function
+ * The mount context maintains a private struct libmnt_cache by default. This function
* allows to overwrite the private cache with an external instance. Note that
* the external instance is not deallocated by mnt_free_context().
*
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_cache(mnt_context *cxt, mnt_cache *cache)
+int mnt_context_set_cache(struct libmnt_context *cxt, struct libmnt_cache *cache)
{
if (!cxt)
return -EINVAL;
*
* Returns: pointer to cache or NULL if canonicalization is disabled.
*/
-mnt_cache *mnt_context_get_cache(mnt_context *cxt)
+struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt)
{
if (!cxt || (cxt->flags & MNT_FL_NOCANONICALIZE))
return NULL;
*
* Returns: pointer to lock struct or NULL.
*/
-mnt_lock *mnt_context_get_lock(mnt_context *cxt)
+struct libmnt_lock *mnt_context_get_lock(struct libmnt_context *cxt)
{
if (!cxt || (cxt->flags & MNT_FL_NOMTAB) || !cxt->mtab_writable)
return NULL;
}
/**
- * mnt_context_set_mountflags:
+ * mnt_context_set_mflags:
* @cxt: mount context
* @flags: mount(2) flags (MS_* flags)
*
+ * Sets mount flags (see mount(2) man page).
+ *
* Note that mount context allows to define mount options by mount flags. It
* means you can for example use
*
- * mnt_context_set_mountflags(cxt, MS_NOEXEC | MS_NOSUID);
+ * mnt_context_set_mflags(cxt, MS_NOEXEC | MS_NOSUID);
*
* rather than
*
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_mountflags(mnt_context *cxt, unsigned long flags)
+int mnt_context_set_mflags(struct libmnt_context *cxt, unsigned long flags)
{
if (!cxt)
return -EINVAL;
}
/**
- * mnt_context_get_mountflags:
+ * mnt_context_get_mflags:
* @cxt: mount context
- * @flags: returns mount flags
+ * @flags: returns MS_* mount flags
*
* Converts mount options string to MS_* flags and bitewise-OR the result with
- * already defined flags (see mnt_context_set_mountflags()).
+ * already defined flags (see mnt_context_set_mflags()).
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_get_mountflags(mnt_context *cxt, unsigned long *flags)
+int mnt_context_get_mflags(struct libmnt_context *cxt, unsigned long *flags)
{
int rc = 0;
if (!cxt || !flags)
}
/**
- * mnt_context_set_userspace_mountflags:
+ * mnt_context_set_user_mflags:
* @cxt: mount context
* @flags: mount(2) flags (MNT_MS_* flags, e.g. MNT_MS_LOOP)
*
- * See also notest for mnt_context_set_mountflags().
+ * Sets userspace mount flags.
+ *
+ * See also notest for mnt_context_set_mflags().
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_userspace_mountflags(mnt_context *cxt, unsigned long flags)
+int mnt_context_set_user_mflags(struct libmnt_context *cxt, unsigned long flags)
{
if (!cxt)
return -EINVAL;
}
/**
- * mnt_context_get_userspace_mountflags:
+ * mnt_context_get_user_mflags:
* @cxt: mount context
* @flags: returns mount flags
*
* Converts mount options string to MNT_MS_* flags and bitewise-OR the result
- * with already defined flags (see mnt_context_set_userspace_mountflags()).
+ * with already defined flags (see mnt_context_set_user_mflags()).
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_get_userspace_mountflags(mnt_context *cxt, unsigned long *flags)
+int mnt_context_get_user_mflags(struct libmnt_context *cxt, unsigned long *flags)
{
int rc = 0;
if (!cxt || !flags)
*flags = 0;
if (!(cxt->flags & MNT_FL_MOUNTFLAGS_MERGED) && cxt->fs) {
- const char *o = mnt_fs_get_userspace_options(cxt->fs);
+ const char *o = mnt_fs_get_user_options(cxt->fs);
if (o)
rc = mnt_optstr_get_flags(o, flags,
mnt_get_builtin_optmap(MNT_USERSPACE_MAP));
return rc;
}
-static int is_loop(mnt_context *cxt)
+static int is_loop(struct libmnt_context *cxt)
{
unsigned long fl = 0;
if (cxt->user_mountflags & MNT_MS_LOOP)
return 1;
- if (!mnt_context_get_mountflags(cxt, &fl) && (fl & MNT_MS_LOOP))
+ if (!mnt_context_get_mflags(cxt, &fl) && (fl & MNT_MS_LOOP))
return 1;
/* TODO:
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_set_mountdata(mnt_context *cxt, void *data)
+int mnt_context_set_mountdata(struct libmnt_context *cxt, void *data)
{
if (!cxt)
return -EINVAL;
/*
* Translates LABEL/UUID/path to mountable path
*/
-int mnt_context_prepare_srcpath(mnt_context *cxt)
+int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
{
const char *path = NULL;
- mnt_cache *cache;
+ struct libmnt_cache *cache;
const char *t, *v, *src;
int rc = 0;
return 0;
}
-int mnt_context_prepare_target(mnt_context *cxt)
+int mnt_context_prepare_target(struct libmnt_context *cxt)
{
const char *tgt;
- mnt_cache *cache;
+ struct libmnt_cache *cache;
int rc = 0;
assert(cxt);
return 0;
}
-int mnt_context_guess_fstype(mnt_context *cxt)
+int mnt_context_guess_fstype(struct libmnt_context *cxt)
{
char *type;
const char *dev;
goto err;
if (access(dev, F_OK) == 0) {
- mnt_cache *cache = mnt_context_get_cache(cxt);
+ struct libmnt_cache *cache = mnt_context_get_cache(cxt);
type = mnt_get_fstype(dev, &cxt->ambi, cache);
if (type) {
* Returns: 0 on success or negative number in case of error. Note that success
* does not mean that there is any usable helper, you have to check cxt->helper.
*/
-int mnt_context_prepare_helper(mnt_context *cxt, const char *name,
+int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
const char *type)
{
char search_path[] = FS_SEARCH_PATH; /* from config.h */
return 0;
}
-int mnt_context_merge_mountflags(mnt_context *cxt)
+int mnt_context_merge_mflags(struct libmnt_context *cxt)
{
unsigned long fl = 0;
int rc;
DBG(CXT, mnt_debug_h(cxt, "merging mount flags"));
- rc = mnt_context_get_mountflags(cxt, &fl);
+ rc = mnt_context_get_mflags(cxt, &fl);
if (rc)
return rc;
cxt->mountflags = fl;
*/
fl = 0;
- rc = mnt_context_get_userspace_mountflags(cxt, &fl);
+ rc = mnt_context_get_user_mflags(cxt, &fl);
if (rc)
return rc;
cxt->user_mountflags = fl;
- DBG(CXT, mnt_debug_h(cxt, "final flags: VFS=%08lx userspace=%08lx",
+ DBG(CXT, mnt_debug_h(cxt, "final flags: VFS=%08lx user=%08lx",
cxt->mountflags, cxt->user_mountflags));
cxt->flags |= MNT_FL_MOUNTFLAGS_MERGED;
/*
* Prepare /etc/mtab or /dev/.mount/utab
*/
-int mnt_context_prepare_update(mnt_context *cxt)
+int mnt_context_prepare_update(struct libmnt_context *cxt)
{
int rc;
const char *target;
return rc < 0 ? rc : 0;
}
-int mnt_context_update_tabs(mnt_context *cxt)
+int mnt_context_update_tabs(struct libmnt_context *cxt)
{
unsigned long fl;
return 0;
}
- fl = mnt_update_get_mountflags(cxt->update);
+ fl = mnt_update_get_mflags(cxt->update);
if ((cxt->mountflags & MS_RDONLY) != (fl & MS_RDONLY))
/*
* fix MS_RDONLY in options
mnt_update_force_rdonly(cxt->update,
cxt->mountflags & MS_RDONLY);
- return mnt_update_tab(cxt->update, mnt_context_get_lock(cxt));
+ return mnt_update_table(cxt->update, mnt_context_get_lock(cxt));
}
-static int apply_tab(mnt_context *cxt, mnt_tab *tb, int direction)
+static int apply_table(struct libmnt_context *cxt, struct libmnt_table *tb,
+ int direction)
{
- mnt_fs *fs = NULL;
+ struct libmnt_fs *fs = NULL;
const char *src = NULL, *tgt = NULL;
int rc;
tgt = mnt_fs_get_target(cxt->fs);
if (tgt && src)
- fs = mnt_tab_find_pair(tb, src, tgt, direction);
+ fs = mnt_table_find_pair(tb, src, tgt, direction);
else {
if (src)
- fs = mnt_tab_find_source(tb, src, direction);
+ fs = mnt_table_find_source(tb, src, direction);
else if (tgt)
- fs = mnt_tab_find_target(tb, tgt, direction);
+ fs = mnt_table_find_target(tb, tgt, direction);
if (!fs) {
/* swap source and target (if @src is not LABEL/UUID),
* example bind mount, symlink to device, ...).
*/
if (src && !mnt_fs_get_tag(cxt->fs, NULL, NULL))
- fs = mnt_tab_find_target(tb, src, direction);
+ fs = mnt_table_find_target(tb, src, direction);
if (!fs && tgt)
- fs = mnt_tab_find_source(tb, tgt, direction);
+ fs = mnt_table_find_source(tb, tgt, direction);
}
}
rc = mnt_fs_set_fs_options(cxt->fs,
mnt_fs_get_fs_options(fs));
if (!rc)
- rc = mnt_fs_set_userspace_options(cxt->fs,
- mnt_fs_get_userspace_options(fs));
+ rc = mnt_fs_set_user_options(cxt->fs,
+ mnt_fs_get_user_options(fs));
} else if (cxt->optsmode & MNT_OMODE_APPEND) {
rc = mnt_fs_append_vfs_options(cxt->fs,
rc = mnt_fs_append_fs_options(cxt->fs,
mnt_fs_get_fs_options(fs));
if (!rc)
- rc = mnt_fs_append_userspace_options(cxt->fs,
- mnt_fs_get_userspace_options(fs));
+ rc = mnt_fs_append_user_options(cxt->fs,
+ mnt_fs_get_user_options(fs));
} else if (cxt->optsmode & MNT_OMODE_PREPEND) {
rc = mnt_fs_prepend_vfs_options(cxt->fs,
rc = mnt_fs_prepend_fs_options(cxt->fs,
mnt_fs_get_fs_options(fs));
if (!rc)
- rc = mnt_fs_prepend_userspace_options(cxt->fs,
- mnt_fs_get_userspace_options(fs));
+ rc = mnt_fs_prepend_user_options(cxt->fs,
+ mnt_fs_get_user_options(fs));
}
if (!rc)
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_apply_fstab(mnt_context *cxt)
+int mnt_context_apply_fstab(struct libmnt_context *cxt)
{
int rc = -1;
- mnt_tab *tab = NULL;
+ struct libmnt_table *tab = NULL;
const char *src = NULL, *tgt = NULL;
assert(cxt);
if (cxt->optsmode & MNT_OMODE_FSTAB) {
rc = mnt_context_get_fstab(cxt, &tab);
if (!rc)
- rc = apply_tab(cxt, tab, MNT_ITER_FORWARD);
+ rc = apply_table(cxt, tab, MNT_ITER_FORWARD);
}
/* try mtab */
if (rc == -1 && (cxt->optsmode & MNT_OMODE_MTAB)) {
rc = mnt_context_get_mtab(cxt, &tab);
if (!rc)
- rc = apply_tab(cxt, tab, MNT_ITER_BACKWARD);
+ rc = apply_table(cxt, tab, MNT_ITER_BACKWARD);
}
if (rc)
DBG(CXT, mnt_debug_h(cxt, "failed to found entry in fstab/mtab"));
*
* Returns: 1 if /sbin/mount.type or mount(2) syscall was successfull or 0.
*/
-int mnt_context_get_status(mnt_context *cxt)
+int mnt_context_get_status(struct libmnt_context *cxt)
{
return cxt && (!cxt->syscall_status || !cxt->helper_exec_status);
}
*
* Returns: 0 or negative number in case of error.
*/
-int mnt_context_strerror(mnt_context *cxt, char *buf, size_t bufsiz)
+int mnt_context_strerror(struct libmnt_context *cxt, char *buf, size_t bufsiz)
{
/* TODO: based on cxt->syscall_errno or cxt->helper_status */
return 0;
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_context_init_helper(mnt_context *cxt, int flags)
+int mnt_context_init_helper(struct libmnt_context *cxt, int flags)
{
return set_flag(cxt, MNT_FL_HELPER, 1);
}
#ifdef TEST_PROGRAM
-mnt_lock *lock;
+struct libmnt_lock *lock;
static void lock_fallback(void)
{
mnt_unlock_file(lock);
}
-int test_mount(struct mtest *ts, int argc, char *argv[])
+int test_mount(struct libmnt_test *ts, int argc, char *argv[])
{
int idx = 1, rc = 0;
- mnt_context *cxt;
+ struct libmnt_context *cxt;
if (argc < 2)
return -EINVAL;
return rc;
}
-int test_umount(struct mtest *ts, int argc, char *argv[])
+int test_umount(struct libmnt_test *ts, int argc, char *argv[])
{
int idx = 1, rc = 0;
- mnt_context *cxt;
+ struct libmnt_context *cxt;
if (argc < 2)
return -EINVAL;
int main(int argc, char *argv[])
{
- struct mtest tss[] = {
+ struct libmnt_test tss[] = {
{ "--mount", test_mount, "[-o <opts>] [-t <type>] <spec>|<src> <target>" },
{ "--umount", test_umount, "[-t <type>] [-f][-l][-r] <src>|<target>" },
{ NULL }};
/*
* this has to be called after mnt_context_evaluate_permissions()
*/
-static int fix_optstr(mnt_context *cxt)
+static int fix_optstr(struct libmnt_context *cxt)
{
int rc = 0, rem_se = 0;
char *next;
char *name, *val;
size_t namesz, valsz;
- mnt_fs *fs;
+ struct libmnt_fs *fs;
assert(cxt);
assert(cxt->fs);
* Converts already evalulated and fixed options to the form that is compatible
* with /sbin/mount.<type> helpers.
*/
-static int generate_helper_optstr(mnt_context *cxt, char **optstr)
+static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
{
int rc = 0;
/*
* this has to be called before fix_optstr()
*/
-static int evaluate_permissions(mnt_context *cxt)
+static int evaluate_permissions(struct libmnt_context *cxt)
{
unsigned long u_flags = 0;
const char *srcpath;
DBG(CXT, mnt_debug_h(cxt, "mount: evaluating permissions"));
- mnt_context_get_userspace_mountflags(cxt, &u_flags);
+ mnt_context_get_user_mflags(cxt, &u_flags);
if (!mnt_context_is_restricted(cxt)) {
/*
*
* Returns: negative number on error, 1 if @c is unknown option, 0 on success.
*/
-int mnt_context_mounthelper_setopt(mnt_context *cxt, int c, char *arg)
+int mnt_context_mounthelper_setopt(struct libmnt_context *cxt, int c, char *arg)
{
int rc = -EINVAL;
return rc;
}
-static int exec_helper(mnt_context *cxt)
+static int exec_helper(struct libmnt_context *cxt)
{
char *o = NULL;
int rc;
* The default is to use fstype from cxt->fs, this could be overwritten by
* @try_type argument.
*/
-static int do_mount(mnt_context *cxt, const char *try_type)
+static int do_mount(struct libmnt_context *cxt, const char *try_type)
{
int rc = 0;
const char *src, *target, *type;
}
if (try_type && cxt->update) {
- mnt_fs *fs = mnt_update_get_fs(cxt->update);
+ struct libmnt_fs *fs = mnt_update_get_fs(cxt->update);
if (fs)
rc = mnt_fs_set_fstype(fs, try_type);
}
return rc;
}
-static int do_mount_by_pattern(mnt_context *cxt, const char *pattern)
+static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
{
int neg = pattern && strncmp(pattern, "no", 2) == 0;
int rc = -EINVAL;
*
* Returns: negative number on error, zero on success
*/
-int mnt_context_prepare_mount(mnt_context *cxt)
+int mnt_context_prepare_mount(struct libmnt_context *cxt)
{
int rc = -EINVAL;
/* TODO: fstab is unnecessary for MS_{MOVE,BIND,STARED,...} */
rc = mnt_context_apply_fstab(cxt);
if (!rc)
- rc = mnt_context_merge_mountflags(cxt);
+ rc = mnt_context_merge_mflags(cxt);
if (!rc)
rc = evaluate_permissions(cxt);
if (!rc)
*
* Returns: negative number on error, zero on success
*/
-int mnt_context_do_mount(mnt_context *cxt)
+int mnt_context_do_mount(struct libmnt_context *cxt)
{
const char *type;
* does not mean that mount(2) syscall or mount.type helper wasn't
* sucessfully called. Check mnt_context_get_status() after error!
*/
-int mnt_mount_context(mnt_context *cxt)
+int mnt_mount_context(struct libmnt_context *cxt)
{
int rc;
*
* Returns: negative number on error, 0 on success.
*/
-int mnt_context_finalize_mount(mnt_context *cxt)
+int mnt_context_finalize_mount(struct libmnt_context *cxt)
{
int rc;
#include "strutils.h"
#include "mountP.h"
-static int lookup_umount_fs(mnt_context *cxt)
+static int lookup_umount_fs(struct libmnt_context *cxt)
{
int rc;
const char *tgt;
- mnt_tab *mtab;
- mnt_fs *fs;
+ struct libmnt_table *mtab;
+ struct libmnt_fs *fs;
assert(cxt);
assert(cxt->fs);
DBG(CXT, mnt_debug_h(cxt, "umount: failed to read mtab"));
return rc;
}
- fs = mnt_tab_find_target(mtab, tgt, MNT_ITER_BACKWARD);
+ fs = mnt_table_find_target(mtab, tgt, MNT_ITER_BACKWARD);
if (!fs) {
/* maybe the option is source rather than target (mountpoint) */
- fs = mnt_tab_find_source(mtab, tgt, MNT_ITER_BACKWARD);
+ fs = mnt_table_find_source(mtab, tgt, MNT_ITER_BACKWARD);
if (fs) {
- mnt_fs *fs1 = mnt_tab_find_target(mtab,
+ struct libmnt_fs *fs1 = mnt_table_find_target(mtab,
mnt_fs_get_target(fs),
MNT_ITER_BACKWARD);
if (!fs1) {
if (!rc)
rc = mnt_fs_set_fs_options(cxt->fs, mnt_fs_get_fs_options(fs));
if (!rc)
- rc = mnt_fs_set_userspace_options(cxt->fs, mnt_fs_get_userspace_options(fs));
+ rc = mnt_fs_set_user_options(cxt->fs, mnt_fs_get_user_options(fs));
if (!rc && mnt_fs_get_bindsrc(fs))
rc = mnt_fs_set_bindsrc(cxt->fs, mnt_fs_get_bindsrc(fs));
*
* TODO : move this to loopdev.c
*/
-static int mnt_loopdev_associated_fs(const char *devname, mnt_fs *fs)
+static int mnt_loopdev_associated_fs(const char *devname, struct libmnt_fs *fs)
{
uintmax_t offset = 0;
const char *src;
return 0;
/* check for offset option in @fs */
- optstr = (char *) mnt_fs_get_userspace_options(fs);
+ optstr = (char *) mnt_fs_get_user_options(fs);
if (optstr && !mnt_optstr_get_option(optstr, "offset=", &val, &valsz)) {
int rc;
/*
* Note that cxt->fs contains relevant mtab entry!
*/
-static int evaluate_permissions(mnt_context *cxt)
+static int evaluate_permissions(struct libmnt_context *cxt)
{
- mnt_tab *fstab;
+ struct libmnt_table *fstab;
unsigned long u_flags = 0;
const char *tgt, *src, *optstr;
int rc, ok = 0;
- mnt_fs *fs;
+ struct libmnt_fs *fs;
assert(cxt);
assert(cxt->fs);
(cxt->user_mountflags & MNT_MS_UHELPER)) {
char *suffix = NULL;
- char *o = (char *) mnt_fs_get_userspace_options(cxt->fs);
+ char *o = (char *) mnt_fs_get_user_options(cxt->fs);
size_t valsz;
rc = mnt_optstr_get_option(o, "uhelper", &suffix, &valsz);
* then "mount /dev/sda4" followed by "umount /mnt/zip" used to fail.
* So, we must not look for file, but for the pair (dev,file) in fstab.
*/
- fs = mnt_tab_find_pair(fstab, src, tgt, MNT_ITER_FORWARD);
+ fs = mnt_table_find_pair(fstab, src, tgt, MNT_ITER_FORWARD);
if (!fs) {
/*
* It's possible that there is /path/file.img in fstab and
* /dev/loop0 in mtab -- then we have to check releation
* between loopdev and the file.
*/
- fs = mnt_tab_find_target(fstab, tgt, MNT_ITER_FORWARD);
+ fs = mnt_table_find_target(fstab, tgt, MNT_ITER_FORWARD);
if (fs) {
const char *dev = mnt_fs_get_srcpath(cxt->fs); /* devname from mtab */
* The options `user', `owner' and `group' only allow unmounting by the
* user that mounted (visible in mtab).
*/
- optstr = mnt_fs_get_userspace_options(fs); /* FSTAB mount options! */
+ optstr = mnt_fs_get_user_options(fs); /* FSTAB mount options! */
if (!optstr)
goto eperm;
}
/* get options from mtab */
- optstr = mnt_fs_get_userspace_options(cxt->fs);
+ optstr = mnt_fs_get_user_options(cxt->fs);
if (optstr && !mnt_optstr_get_option((char *) optstr,
"user", &mtab_user, &sz) && sz)
ok = !strncmp(curr_user, mtab_user, sz);
return -EPERM;
}
-static int exec_helper(mnt_context *cxt)
+static int exec_helper(struct libmnt_context *cxt)
{
int rc;
return rc;
}
-static int do_umount(mnt_context *cxt)
+static int do_umount(struct libmnt_context *cxt)
{
int rc = 0;
const char *src, *target;
*
* Returns: 0 on success, and negative number in case of error.
*/
-int mnt_context_do_umount(mnt_context *cxt)
+int mnt_context_do_umount(struct libmnt_context *cxt)
{
int rc;
rc = lookup_umount_fs(cxt);
if (!rc)
- rc = mnt_context_merge_mountflags(cxt);
+ rc = mnt_context_merge_mflags(cxt);
if (!rc)
rc = evaluate_permissions(cxt);
if (!rc)
/**
* SECTION: fs
* @title: Filesystem
- * @short_description: mnt_fs represents one entry in fstab/mtab/mountinfo
+ * @short_description: struct libmnt_fs represents one entry in fstab/mtab/mountinfo
*
*/
#include <stdio.h>
/**
* mnt_new_fs:
*
- * Returns: newly allocated mnt_file fs.
+ * Returns: newly allocated struct libmnt_fs.
*/
-mnt_fs *mnt_new_fs(void)
+struct libmnt_fs *mnt_new_fs(void)
{
- mnt_fs *fs = calloc(1, sizeof(struct _mnt_fs));
+ struct libmnt_fs *fs = calloc(1, sizeof(*fs));
if (!fs)
return NULL;
*
* Deallocates the fs.
*/
-void mnt_free_fs(mnt_fs *fs)
+void mnt_free_fs(struct libmnt_fs *fs)
{
if (!fs)
return;
*
* Returns: copy of @fs
*/
-mnt_fs *mnt_copy_fs(const mnt_fs *fs)
+struct libmnt_fs *mnt_copy_fs(const struct libmnt_fs *fs)
{
- mnt_fs *n = mnt_new_fs();
+ struct libmnt_fs *n = mnt_new_fs();
if (!n)
return NULL;
n->parent = fs->parent;
n->devno = fs->devno;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, source)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, source)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, tagname)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, tagname)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, tagval)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, tagval)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, root)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, root)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, target)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, target)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, fstype)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, fstype)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, vfs_optstr)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, vfs_optstr)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, fs_optstr)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, fs_optstr)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, user_optstr)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, user_optstr)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, attrs)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, attrs)))
goto err;
n->freq = fs->freq;
*
* Returns: copy of @fs.
*/
-mnt_fs *mnt_copy_mtab_fs(const mnt_fs *fs)
+struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs)
{
- mnt_fs *n = mnt_new_fs();
+ struct libmnt_fs *n = mnt_new_fs();
if (!n)
return NULL;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, source)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, source)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, target)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, target)))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, fstype)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, fstype)))
goto err;
if (fs->vfs_optstr) {
n->user_optstr = p;
}
- if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, fs_optstr)))
+ if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, fs_optstr)))
goto err;
n->freq = fs->freq;
/**
* mnt_fs_get_userdata:
- * @fs: mnt_file instance
+ * @fs: struct libmnt_file instance
*
* Returns: private data set by mnt_fs_set_userdata() or NULL.
*/
-void *mnt_fs_get_userdata(mnt_fs *fs)
+void *mnt_fs_get_userdata(struct libmnt_fs *fs)
{
return fs ? fs->userdata : NULL;
}
/**
* mnt_fs_set_userdata:
- * @fs: mnt_file instance
+ * @fs: struct libmnt_file instance
* @data: user data
*
* The "userdata" are library independent data.
*
* Returns: 0 or negative number in case of error (if @fs is NULL).
*/
-int mnt_fs_set_userdata(mnt_fs *fs, void *data)
+int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data)
{
if (!fs)
return -EINVAL;
/**
* mnt_fs_get_srcpath:
- * @fs: mnt_file (fstab/mtab/mountinfo) fs
+ * @fs: struct libmnt_file (fstab/mtab/mountinfo) fs
*
* The mount "source path" is:
* - a directory for 'bind' mounts (in fstab or mtab only)
* Returns: mount source path or NULL in case of error or when the path
* is not defined.
*/
-const char *mnt_fs_get_srcpath(mnt_fs *fs)
+const char *mnt_fs_get_srcpath(struct libmnt_fs *fs)
{
assert(fs);
if (!fs)
/**
* mnt_fs_get_source:
- * @fs: mnt_file (fstab/mtab/mountinfo) fs
+ * @fs: struct libmnt_file (fstab/mtab/mountinfo) fs
*
* Returns: mount source. Note that the source could be unparsed TAG
* (LABEL/UUID). See also mnt_fs_get_srcpath() and mnt_fs_get_tag().
*/
-const char *mnt_fs_get_source(mnt_fs *fs)
+const char *mnt_fs_get_source(struct libmnt_fs *fs)
{
return fs ? fs->source : NULL;
}
-/* Used by parser mnt_file ONLY (@source has to be allocated) */
-int __mnt_fs_set_source_ptr(mnt_fs *fs, char *source)
+/* Used by parser struct libmnt_file ONLY (@source has to be allocated) */
+int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source)
{
char *t = NULL, *v = NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_source(mnt_fs *fs, const char *source)
+int mnt_fs_set_source(struct libmnt_fs *fs, const char *source)
{
char *p;
int rc;
* <informalexample>
* <programlisting>
* char *src;
- * mnt_fs *fs = mnt_tab_find_target(tb, "/home", MNT_ITER_FORWARD);
+ * struct libmnt_fs *fs = mnt_table_find_target(tb, "/home", MNT_ITER_FORWARD);
*
* if (!fs)
* goto err;
*
* Returns: 0 on success or negative number in case that a TAG is not defined.
*/
-int mnt_fs_get_tag(mnt_fs *fs, const char **name, const char **value)
+int mnt_fs_get_tag(struct libmnt_fs *fs, const char **name, const char **value)
{
if (fs == NULL || !fs->tagname)
return -EINVAL;
*
* Returns: pointer to mountpoint path or NULL
*/
-const char *mnt_fs_get_target(mnt_fs *fs)
+const char *mnt_fs_get_target(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->target : NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_target(mnt_fs *fs, const char *target)
+int mnt_fs_set_target(struct libmnt_fs *fs, const char *target)
{
char *p;
*
* Returns: pointer to filesystem type.
*/
-const char *mnt_fs_get_fstype(mnt_fs *fs)
+const char *mnt_fs_get_fstype(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->fstype : NULL;
}
-/* Used by mnt_file parser only */
-int __mnt_fs_set_fstype_ptr(mnt_fs *fs, char *fstype)
+/* Used by struct libmnt_file parser only */
+int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype)
{
assert(fs);
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_fstype(mnt_fs *fs, const char *fstype)
+int mnt_fs_set_fstype(struct libmnt_fs *fs, const char *fstype)
{
char *p = NULL;
int rc;
*
* Returns: pointer to string (can be freed by free(3)) or NULL in case of error.
*/
-char *mnt_fs_strdup_options(mnt_fs *fs)
+char *mnt_fs_strdup_options(struct libmnt_fs *fs)
{
char *res;
*
* Returns: 0 on success, or negative number icase of error.
*/
-int mnt_fs_set_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr)
{
char *v = NULL, *f = NULL, *u = NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_append_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_append_options(struct libmnt_fs *fs, const char *optstr)
{
char *v = NULL, *f = NULL, *u = NULL;
int rc;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_prepend_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_prepend_options(struct libmnt_fs *fs, const char *optstr)
{
char *v = NULL, *f = NULL, *u = NULL;
int rc;
*
* Returns: pointer to superblock (fs-depend) mount option string or NULL.
*/
-const char *mnt_fs_get_fs_options(mnt_fs *fs)
+const char *mnt_fs_get_fs_options(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->fs_optstr : NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_fs_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_set_fs_options(struct libmnt_fs *fs, const char *optstr)
{
char *p = NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_append_fs_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_append_fs_options(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_prepend_fs_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_prepend_fs_options(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
*
* Returns: pointer to fs-independent (VFS) mount option string or NULL.
*/
-const char *mnt_fs_get_vfs_options(mnt_fs *fs)
+const char *mnt_fs_get_vfs_options(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->vfs_optstr : NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_vfs_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_set_vfs_options(struct libmnt_fs *fs, const char *optstr)
{
char *p = NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_append_vfs_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_append_vfs_options(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_prepend_vfs_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_prepend_vfs_options(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
}
/**
- * mnt_fs_get_userspace_options:
+ * mnt_fs_get_user_options:
* @fs: fstab/mtab entry pointer
*
* Returns: pointer to userspace mount option string or NULL.
*/
-const char *mnt_fs_get_userspace_options(mnt_fs *fs)
+const char *mnt_fs_get_user_options(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->user_optstr : NULL;
}
/**
- * mnt_fs_set_userspace_options:
+ * mnt_fs_set_user_options:
* @fs: fstab/mtab/mountinfo entry
* @optstr: options string
*
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_userspace_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_set_user_options(struct libmnt_fs *fs, const char *optstr)
{
char *p = NULL;
}
/**
- * mnt_fs_append_userspace_options:
+ * mnt_fs_append_user_options:
* @fs: fstab/mtab/mountinfo entry
* @optstr: options string
*
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_append_userspace_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_append_user_options(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
}
/**
- * mnt_fs_prepend_userspace_options:
+ * mnt_fs_prepend_user_options:
* @fs: fstab/mtab/mountinfo entry
* @optstr: options string
*
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_prepend_userspace_options(mnt_fs *fs, const char *optstr)
+int mnt_fs_prepend_user_options(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
*
* Returns: pointer to attributes string or NULL.
*/
-const char *mnt_fs_get_attributes(mnt_fs *fs)
+const char *mnt_fs_get_attributes(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->attrs : NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_attributes(mnt_fs *fs, const char *optstr)
+int mnt_fs_set_attributes(struct libmnt_fs *fs, const char *optstr)
{
char *p = NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_append_attributes(mnt_fs *fs, const char *optstr)
+int mnt_fs_append_attributes(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_prepend_attributes(mnt_fs *fs, const char *optstr)
+int mnt_fs_prepend_attributes(struct libmnt_fs *fs, const char *optstr)
{
if (!fs)
return -EINVAL;
*
* Returns: dump frequency in days.
*/
-int mnt_fs_get_freq(mnt_fs *fs)
+int mnt_fs_get_freq(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->freq : 0;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_freq(mnt_fs *fs, int freq)
+int mnt_fs_set_freq(struct libmnt_fs *fs, int freq)
{
assert(fs);
if (!fs)
*
* Returns: "pass number on parallel fsck".
*/
-int mnt_fs_get_passno(mnt_fs *fs)
+int mnt_fs_get_passno(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->passno: 0;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_passno(mnt_fs *fs, int passno)
+int mnt_fs_set_passno(struct libmnt_fs *fs, int passno)
{
assert(fs);
if (!fs)
*
* Returns: root of the mount within the filesystem or NULL
*/
-const char *mnt_fs_get_root(mnt_fs *fs)
+const char *mnt_fs_get_root(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->root : NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_root(mnt_fs *fs, const char *root)
+int mnt_fs_set_root(struct libmnt_fs *fs, const char *root)
{
char *p = NULL;
*
* Returns: full path that was used for mount(2) on MS_BIND
*/
-const char *mnt_fs_get_bindsrc(mnt_fs *fs)
+const char *mnt_fs_get_bindsrc(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->bindsrc : NULL;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_set_bindsrc(mnt_fs *fs, const char *src)
+int mnt_fs_set_bindsrc(struct libmnt_fs *fs, const char *src)
{
char *p = NULL;
*
* Returns: mount ID (unique identifier of the mount) or negative number in case of error.
*/
-int mnt_fs_get_id(mnt_fs *fs)
+int mnt_fs_get_id(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->id : -EINVAL;
*
* Returns: parent mount ID or negative number in case of error.
*/
-int mnt_fs_get_parent_id(mnt_fs *fs)
+int mnt_fs_get_parent_id(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->parent : -EINVAL;
*
* Returns: value of st_dev for files on filesystem or 0 in case of error.
*/
-dev_t mnt_fs_get_devno(mnt_fs *fs)
+dev_t mnt_fs_get_devno(struct libmnt_fs *fs)
{
assert(fs);
return fs ? fs->devno : 0;
*
* Returns: 0 on success, 1 when not found the @name or negative number in case of error.
*/
-int mnt_fs_get_option(mnt_fs *fs, const char *name,
+int mnt_fs_get_option(struct libmnt_fs *fs, const char *name,
char **value, size_t *valsz)
{
char rc = 1;
*
* Returns: 0 on success, 1 when not found the @name or negative number in case of error.
*/
-int mnt_fs_get_attribute(mnt_fs *fs, const char *name,
+int mnt_fs_get_attribute(struct libmnt_fs *fs, const char *name,
char **value, size_t *valsz)
{
char rc = 1;
*
* Returns: 1 if @fs target is equal to @target else 0.
*/
-int mnt_fs_match_target(mnt_fs *fs, const char *target, mnt_cache *cache)
+int mnt_fs_match_target(struct libmnt_fs *fs, const char *target, struct libmnt_cache *cache)
{
int rc = 0;
*
* Returns: 1 if @fs source is equal to @source else 0.
*/
-int mnt_fs_match_source(mnt_fs *fs, const char *source, mnt_cache *cache)
+int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, struct libmnt_cache *cache)
{
char *cn;
const char *src, *t, *v;
* Returns: 1 if @fs type is matching to @types else 0. The function returns
* 0 when types is NULL.
*/
-int mnt_fs_match_fstype(mnt_fs *fs, const char *types)
+int mnt_fs_match_fstype(struct libmnt_fs *fs, const char *types)
{
return mnt_match_fstype(fs->fstype, types);
}
* Returns: 1 if @fs type is matching to @options else 0. The function returns
* 0 when types is NULL.
*/
-int mnt_fs_match_options(mnt_fs *fs, const char *options)
+int mnt_fs_match_options(struct libmnt_fs *fs, const char *options)
{
char *o = mnt_fs_strdup_options(fs);
int rc = 0;
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_fs_print_debug(mnt_fs *fs, FILE *file)
+int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file)
{
if (!fs)
return -EINVAL;
fprintf(file, "VFS-optstr: %s\n", mnt_fs_get_vfs_options(fs));
if (mnt_fs_get_fs_options(fs))
fprintf(file, "FS-opstr: %s\n", mnt_fs_get_fs_options(fs));
- if (mnt_fs_get_userspace_options(fs))
- fprintf(file, "user-optstr: %s\n", mnt_fs_get_userspace_options(fs));
+ if (mnt_fs_get_user_options(fs))
+ fprintf(file, "user-optstr: %s\n", mnt_fs_get_user_options(fs));
if (mnt_fs_get_attributes(fs))
fprintf(file, "attributes: %s\n", mnt_fs_get_attributes(fs));
*
* Returns: 0 on success and negative number in case of error.
*/
-int mnt_fs_to_mntent(mnt_fs *fs, struct mntent **mnt)
+int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt)
{
int rc;
struct mntent *m;
*
* Returns: newly allocated generic libmount iterator.
*/
-mnt_iter *mnt_new_iter(int direction)
+struct libmnt_iter *mnt_new_iter(int direction)
{
- mnt_iter *itr = calloc(1, sizeof(struct _mnt_iter));
+ struct libmnt_iter *itr = calloc(1, sizeof(*itr));
if (!itr)
return NULL;
itr->direction = direction;
*
* Deallocates iterator.
*/
-void mnt_free_iter(mnt_iter *itr)
+void mnt_free_iter(struct libmnt_iter *itr)
{
free(itr);
}
*
* Resets iterator.
*/
-void mnt_reset_iter(mnt_iter *itr, int direction)
+void mnt_reset_iter(struct libmnt_iter *itr, int direction)
{
assert(itr);
direction = itr->direction;
if (itr) {
- memset(itr, 0, sizeof(struct _mnt_iter));
+ memset(itr, 0, sizeof(*itr));
itr->direction = direction;
}
}
*
* Returns: MNT_INTER_{FOR,BACK}WARD or negative number in case of error.
*/
-int mnt_iter_get_direction(mnt_iter *itr)
+int mnt_iter_get_direction(struct libmnt_iter *itr)
{
assert(itr);
return itr ? itr->direction : -EINVAL;
#define LIBMOUNT_VERSION "@LIBMOUNT_VERSION@"
/**
- * mnt_cache:
+ * libmnt_cache:
*
* Stores canonicalized paths and evaluated tags
*/
-typedef struct _mnt_cache mnt_cache;
+struct libmnt_cache;
/**
- * mnt_lock:
+ * libmnt_lock:
*
* Stores information about locked file (e.g. /etc/mtab)
*/
-typedef struct _mnt_lock mnt_lock;
+struct libmnt_lock;
/**
- * mnt_iter:
+ * libmnt_iter:
*
* Generic iterator (stores state about lists)
*/
-typedef struct _mnt_iter mnt_iter;
+struct libmnt_iter;
/**
- * mnt_optmap:
+ * libmnt_optmap:
*
* Mount options description (map)
*/
-struct mnt_optmap
+struct libmnt_optmap
{
const char *name; /* option name[=%<type>] (e.g. "loop[=%s]") */
int id; /* option ID or MS_* flags (e.g MS_RDONLY) */
#define MNT_NOMTAB (1 << 2) /* skip in the mtab option string */
/**
- * mnt_fs:
+ * libmnt_fs:
*
* Parsed fstab/mtab/mountinfo entry
*/
-typedef struct _mnt_fs mnt_fs;
+struct libmnt_fs;
/**
- * mnt_tab:
+ * libmnt_table:
*
- * List of mnt_fs entries (parsed fstab/mtab/mountinfo)
+ * List of struct libmnt_fs entries (parsed fstab/mtab/mountinfo)
*/
-typedef struct _mnt_tab mnt_tab;
+struct libmnt_table;
/**
- * mnt_update
+ * libmnt_update
*
* /etc/mtab or /dev/.mount/utab update description
*/
-typedef struct _mnt_update mnt_update;
+struct libmnt_update;
/**
- * mnt_context
+ * libmnt_context
*
* Mount/umount status
*/
-typedef struct _mnt_context mnt_context;
+struct libmnt_context;
/*
* Actions
extern int mnt_has_regular_mtab(const char **mtab, int *writable);
/* cache.c */
-extern mnt_cache *mnt_new_cache(void);
-extern void mnt_free_cache(mnt_cache *cache);
-extern int mnt_cache_read_tags(mnt_cache *cache, const char *devname);
-extern int mnt_cache_device_has_tag(mnt_cache *cache, const char *devname,
- const char *token, const char *value);
+extern struct libmnt_cache *mnt_new_cache(void);
+extern void mnt_free_cache(struct libmnt_cache *cache);
+extern int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname);
+extern int mnt_cache_device_has_tag(struct libmnt_cache *cache,
+ const char *devname,
+ const char *token,
+ const char *value);
-extern char *mnt_cache_find_tag_value(mnt_cache *cache,
+extern char *mnt_cache_find_tag_value(struct libmnt_cache *cache,
const char *devname, const char *token);
-extern char *mnt_get_fstype(const char *devname, int *ambi, mnt_cache *cache);
-extern char *mnt_resolve_path(const char *path, mnt_cache *cache);
-extern char *mnt_resolve_tag(const char *token, const char *value, mnt_cache *cache);
-extern char *mnt_resolve_spec(const char *spec, mnt_cache *cache);
+extern char *mnt_get_fstype(const char *devname, int *ambi,
+ struct libmnt_cache *cache);
+extern char *mnt_resolve_path(const char *path, struct libmnt_cache *cache);
+extern char *mnt_resolve_tag(const char *token, const char *value,
+ struct libmnt_cache *cache);
+extern char *mnt_resolve_spec(const char *spec, struct libmnt_cache *cache);
/* optstr.c */
extern int mnt_optstr_next_option(char **optstr, char **name, size_t *namesz,
int ignore_user, int ignore_vfs);
extern int mnt_optstr_get_options(const char *optstr, char **subset,
- const struct mnt_optmap *map, int ignore);
+ const struct libmnt_optmap *map, int ignore);
extern int mnt_optstr_get_flags(const char *optstr, unsigned long *flags,
- const struct mnt_optmap *map);
+ const struct libmnt_optmap *map);
extern int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
- const struct mnt_optmap *map);
+ const struct libmnt_optmap *map);
/* iter.c */
enum {
MNT_ITER_FORWARD = 0,
MNT_ITER_BACKWARD
};
-extern mnt_iter *mnt_new_iter(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);
+extern struct libmnt_iter *mnt_new_iter(int direction);
+extern void mnt_free_iter(struct libmnt_iter *itr);
+extern void mnt_reset_iter(struct libmnt_iter *itr, int direction);
+extern int mnt_iter_get_direction(struct libmnt_iter *itr);
/* optmap.c */
enum {
MNT_LINUX_MAP = 1,
MNT_USERSPACE_MAP
};
-extern const struct mnt_optmap *mnt_get_builtin_optmap(int id);
+extern const struct libmnt_optmap *mnt_get_builtin_optmap(int id);
/* lock.c */
-extern mnt_lock *mnt_new_lock(const char *datafile, pid_t id);
-extern void mnt_free_lock(mnt_lock *ml);
-extern void mnt_unlock_file(mnt_lock *ml);
-extern int mnt_lock_file(mnt_lock *ml);
+extern struct libmnt_lock *mnt_new_lock(const char *datafile, pid_t id);
+extern void mnt_free_lock(struct libmnt_lock *ml);
+extern void mnt_unlock_file(struct libmnt_lock *ml);
+extern int mnt_lock_file(struct libmnt_lock *ml);
/* fs.c */
-extern mnt_fs *mnt_new_fs(void);
-extern void mnt_free_fs(mnt_fs *fs);
-extern mnt_fs *mnt_copy_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 *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 *fs, const char *name,
+extern struct libmnt_fs *mnt_new_fs(void);
+extern void mnt_free_fs(struct libmnt_fs *fs);
+extern struct libmnt_fs *mnt_copy_fs(const struct libmnt_fs *fs);
+extern void *mnt_fs_get_userdata(struct libmnt_fs *fs);
+extern int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data);
+extern const char *mnt_fs_get_source(struct libmnt_fs *fs);
+extern int mnt_fs_set_source(struct libmnt_fs *fs, const char *source);
+extern const char *mnt_fs_get_srcpath(struct libmnt_fs *fs);
+extern int mnt_fs_get_tag(struct libmnt_fs *fs, const char **name,
+ const char **value);
+extern const char *mnt_fs_get_target(struct libmnt_fs *fs);
+extern int mnt_fs_set_target(struct libmnt_fs *fs, const char *target);
+extern const char *mnt_fs_get_fstype(struct libmnt_fs *fs);
+extern int mnt_fs_set_fstype(struct libmnt_fs *fs, const char *fstype);
+
+extern char *mnt_fs_strdup_options(struct libmnt_fs *fs);
+extern int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr);
+
+extern int mnt_fs_get_option(struct libmnt_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_prepend_options(mnt_fs *fs, const char *optstr);
+extern int mnt_fs_append_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_prepend_options(struct libmnt_fs *fs, const char *optstr);
-extern const char *mnt_fs_get_fs_options(mnt_fs *fs);
-extern int mnt_fs_set_fs_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_append_fs_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_prepend_fs_options(mnt_fs *fs, const char *optstr);
+extern const char *mnt_fs_get_fs_options(struct libmnt_fs *fs);
+extern int mnt_fs_set_fs_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_append_fs_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_prepend_fs_options(struct libmnt_fs *fs, const char *optstr);
-extern const char *mnt_fs_get_vfs_options(mnt_fs *fs);
-extern int mnt_fs_set_vfs_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_append_vfs_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_prepend_vfs_options(mnt_fs *fs, const char *optstr);
+extern const char *mnt_fs_get_vfs_options(struct libmnt_fs *fs);
+extern int mnt_fs_set_vfs_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_append_vfs_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_prepend_vfs_options(struct libmnt_fs *fs, const char *optstr);
-extern const char *mnt_fs_get_userspace_options(mnt_fs *fs);
-extern int mnt_fs_set_userspace_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_append_userspace_options(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_prepend_userspace_options(mnt_fs *fs, const char *optstr);
+extern const char *mnt_fs_get_user_options(struct libmnt_fs *fs);
+extern int mnt_fs_set_user_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_append_user_options(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_prepend_user_options(struct libmnt_fs *fs, const char *optstr);
-extern const char *mnt_fs_get_attributes(mnt_fs *fs);
-extern int mnt_fs_set_attributes(mnt_fs *fs, const char *optstr);
-extern int mnt_fs_get_attribute(mnt_fs *fs, const char *name,
+extern const char *mnt_fs_get_attributes(struct libmnt_fs *fs);
+extern int mnt_fs_set_attributes(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_get_attribute(struct libmnt_fs *fs, const char *name,
char **value, size_t *valsz);
-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 *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_set_bindsrc(mnt_fs *fs, const char *src);
-extern int mnt_fs_get_id(mnt_fs *fs);
-extern int mnt_fs_get_parent_id(mnt_fs *fs);
-extern dev_t mnt_fs_get_devno(mnt_fs *fs);
-
-extern int mnt_fs_match_target(mnt_fs *fs, const char *target, mnt_cache *cache);
-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 *fs, FILE *file);
+extern int mnt_fs_append_attributes(struct libmnt_fs *fs, const char *optstr);
+extern int mnt_fs_prepend_attributes(struct libmnt_fs *fs, const char *optstr);
+
+extern int mnt_fs_get_freq(struct libmnt_fs *fs);
+extern int mnt_fs_set_freq(struct libmnt_fs *fs, int freq);
+extern int mnt_fs_get_passno(struct libmnt_fs *fs);
+extern int mnt_fs_set_passno(struct libmnt_fs *fs, int passno);
+extern const char *mnt_fs_get_root(struct libmnt_fs *fs);
+extern int mnt_fs_set_root(struct libmnt_fs *fs, const char *root);
+extern const char *mnt_fs_get_bindsrc(struct libmnt_fs *fs);
+extern int mnt_fs_set_bindsrc(struct libmnt_fs *fs, const char *src);
+extern int mnt_fs_get_id(struct libmnt_fs *fs);
+extern int mnt_fs_get_parent_id(struct libmnt_fs *fs);
+extern dev_t mnt_fs_get_devno(struct libmnt_fs *fs);
+
+extern int mnt_fs_match_target(struct libmnt_fs *fs, const char *target,
+ struct libmnt_cache *cache);
+extern int mnt_fs_match_source(struct libmnt_fs *fs, const char *source,
+ struct libmnt_cache *cache);
+extern int mnt_fs_match_fstype(struct libmnt_fs *fs, const char *types);
+extern int mnt_fs_match_options(struct libmnt_fs *fs, const char *options);
+extern int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file);
extern void mnt_free_mntent(struct mntent *mnt);
-extern int mnt_fs_to_mntent(mnt_fs *fs, struct mntent **mnt);
+extern int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt);
/* tab-parse.c */
-extern mnt_tab *mnt_new_tab_from_file(const char *filename);
-extern mnt_tab *mnt_new_tab_from_dir(const char *dirname);
-extern int mnt_tab_parse_stream(mnt_tab *tb, FILE *f, const char *filename);
-extern int mnt_tab_parse_file(mnt_tab *tb, const char *filename);
-extern int mnt_tab_parse_fstab(mnt_tab *tb, const char *filename);
-extern int mnt_tab_parse_mtab(mnt_tab *tb, const char *filename);
-extern int mnt_tab_set_parser_errcb(mnt_tab *tb,
- int (*cb)(mnt_tab *tb, const char *filename, int line));
+extern struct libmnt_table *mnt_new_table_from_file(const char *filename);
+extern struct libmnt_table *mnt_new_table_from_dir(const char *dirname);
+extern int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f,
+ const char *filename);
+extern int mnt_table_parse_file(struct libmnt_table *tb, const char *filename);
+extern int mnt_table_parse_fstab(struct libmnt_table *tb, const char *filename);
+extern int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename);
+extern int mnt_table_set_parser_errcb(struct libmnt_table *tb,
+ int (*cb)(struct libmnt_table *tb, const char *filename, int line));
/* tab.c */
-extern mnt_tab *mnt_new_tab(void);
-extern void mnt_free_tab(mnt_tab *tb);
-extern int mnt_tab_get_nents(mnt_tab *tb);
-extern int mnt_tab_set_cache(mnt_tab *tb, mnt_cache *mpc);
-extern mnt_cache *mnt_tab_get_cache(mnt_tab *tb);
-extern const char *mnt_tab_get_name(mnt_tab *tb);
-extern int mnt_tab_add_fs(mnt_tab *tb, mnt_fs *fs);
-extern int mnt_tab_remove_fs(mnt_tab *tb, mnt_fs *fs);
-extern int mnt_tab_next_fs(mnt_tab *tb, mnt_iter *itr, mnt_fs **fs);
-extern int mnt_tab_next_child_fs(mnt_tab *tb, mnt_iter *itr,
- mnt_fs *parent, mnt_fs **chld);
-extern int mnt_tab_get_root_fs(mnt_tab *tb, mnt_fs **root);
-extern int mnt_tab_set_iter(mnt_tab *tb, mnt_iter *itr, mnt_fs *fs);
-
-extern mnt_fs *mnt_tab_find_target(mnt_tab *tb, const char *path, int direction);
-extern mnt_fs *mnt_tab_find_srcpath(mnt_tab *tb, const char *path, int direction);
-extern mnt_fs *mnt_tab_find_tag(mnt_tab *tb, const char *tag,
+extern struct libmnt_table *mnt_new_table(void);
+extern void mnt_free_table(struct libmnt_table *tb);
+extern int mnt_table_get_nents(struct libmnt_table *tb);
+extern int mnt_table_set_cache(struct libmnt_table *tb, struct libmnt_cache *mpc);
+extern struct libmnt_cache *mnt_table_get_cache(struct libmnt_table *tb);
+extern const char *mnt_table_get_name(struct libmnt_table *tb);
+extern int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs);
+extern int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs);
+extern int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
+ struct libmnt_fs **fs);
+extern int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
+ struct libmnt_fs *parent, struct libmnt_fs **chld);
+extern int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root);
+extern int mnt_table_set_iter(struct libmnt_table *tb, struct libmnt_iter *itr,
+ struct libmnt_fs *fs);
+
+extern struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb,
+ const char *path, int direction);
+extern struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb,
+ const char *path, int direction);
+extern struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag,
const char *val, int direction);
-extern mnt_fs *mnt_tab_find_source(mnt_tab *tb, const char *source, int direction);
-extern mnt_fs *mnt_tab_find_pair(mnt_tab *tb, const char *source,
+extern struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb,
+ const char *source, int direction);
+extern struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb,
+ const char *source,
const char *target, int direction);
-extern int mnt_tab_find_next_fs(mnt_tab *tb, mnt_iter *itr,
- int (*match_func)(mnt_fs *, void *), void *userdata,
- mnt_fs **fs);
+extern int mnt_table_find_next_fs(struct libmnt_table *tb,
+ struct libmnt_iter *itr,
+ int (*match_func)(struct libmnt_fs *, void *), void *userdata,
+ struct libmnt_fs **fs);
/* tab_update.c */
-extern mnt_update *mnt_new_update(void);
-extern void mnt_free_update(mnt_update *upd);
-extern int mnt_update_is_ready(mnt_update *upd);
-extern int mnt_update_set_fs(mnt_update *upd, unsigned long mountflags,
- const char *target, mnt_fs *fs);
-extern int mnt_update_tab(mnt_update *upd, mnt_lock *lc);
-extern unsigned long mnt_update_get_mountflags(mnt_update *upd);
-extern int mnt_update_force_rdonly(mnt_update *upd, int rdonly);
-extern const char *mnt_update_get_filename(mnt_update *upd);
-extern mnt_fs *mnt_update_get_fs(mnt_update *upd);
+extern struct libmnt_update *mnt_new_update(void);
+extern void mnt_free_update(struct libmnt_update *upd);
+extern int mnt_update_is_ready(struct libmnt_update *upd);
+extern int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mflags,
+ const char *target, struct libmnt_fs *fs);
+extern int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc);
+extern unsigned long mnt_update_get_mflags(struct libmnt_update *upd);
+extern int mnt_update_force_rdonly(struct libmnt_update *upd, int rdonly);
+extern const char *mnt_update_get_filename(struct libmnt_update *upd);
+extern struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd);
/* context.c */
MNT_OMODE_USER = (MNT_OMODE_REPLACE | MNT_OMODE_FORCE | MNT_OMODE_FSTAB)
};
-extern mnt_context *mnt_new_context(void);
-extern void mnt_free_context(mnt_context *cxt);
-extern int mnt_reset_context(mnt_context *cxt);
-extern int mnt_context_is_restricted(mnt_context *cxt);
-
-extern int mnt_context_init_helper(mnt_context *cxt, int flags)
-extern int mnt_context_mounthelper_setopt(mnt_context *cxt, int c, char *arg);
-
-extern int mnt_context_set_optsmode(mnt_context *cxt, int mode);
-extern int mnt_context_disable_canonicalize(mnt_context *cxt, int disable);
-extern int mnt_context_enable_lazy(mnt_context *cxt, int enable);
-extern int mnt_context_enable_rdonly_umount(mnt_context *cxt, int enable);
-extern int mnt_context_disable_helpers(mnt_context *cxt, int disable);
-extern int mnt_context_enable_sloppy(mnt_context *cxt, int enable);
-extern int mnt_context_enable_fake(mnt_context *cxt, int enable);
-extern int mnt_context_disable_mtab(mnt_context *cxt, int disable);
-extern int mnt_context_enable_force(mnt_context *cxt, int enable);
-extern int mnt_context_enable_verbose(mnt_context *cxt, int enable);
-extern int mnt_context_enable_loopdel(mnt_context *cxt, int enable);
-
-extern int mnt_context_get_optsmode(mnt_context *cxt);
-extern int mnt_context_is_lazy(mnt_context *cxt);
-extern int mnt_context_is_rdonly_umount(mnt_context *cxt);
-extern int mnt_context_is_sloppy(mnt_context *cxt);
-extern int mnt_context_is_fake(mnt_context *cxt);
-extern int mnt_context_is_nomtab(mnt_context *cxt);
-extern int mnt_context_is_force(mnt_context *cxt);
-extern int mnt_context_is_verbose(mnt_context *cxt);
-
-extern int mnt_context_set_fs(mnt_context *cxt, mnt_fs *fs);
-extern mnt_fs *mnt_context_get_fs(mnt_context *cxt);
-extern int mnt_context_set_source(mnt_context *cxt, const char *source);
-extern int mnt_context_set_target(mnt_context *cxt, const char *target);
-extern int mnt_context_set_fstype(mnt_context *cxt, const char *fstype);
-extern int mnt_context_set_options(mnt_context *cxt, const char *optstr);
-extern int mnt_context_append_options(mnt_context *cxt, const char *optstr);
-extern int mnt_context_set_fstype_pattern(mnt_context *cxt, const char *pattern);
-extern int mnt_context_set_options_pattern(mnt_context *cxt, const char *pattern);
-
-extern int mnt_context_set_fstab(mnt_context *cxt, mnt_tab *tb);
-extern int mnt_context_get_fstab(mnt_context *cxt, mnt_tab **tb);
-extern int mnt_context_get_mtab(mnt_context *cxt, mnt_tab **tb);
-extern int mnt_context_set_cache(mnt_context *cxt, mnt_cache *cache);
-extern mnt_cache *mnt_context_get_cache(mnt_context *cxt);
-extern mnt_lock *mnt_context_get_lock(mnt_context *cxt);
-
-extern int mnt_context_set_mountflags(mnt_context *cxt, unsigned long flags);
-extern int mnt_context_get_mountflags(mnt_context *cxt, unsigned long *flags);
-extern int mnt_context_set_userspace_mountflags(mnt_context *cxt, unsigned long flags);
-extern int mnt_context_get_userspace_mountflags(mnt_context *cxt, unsigned long *flags);
-
-extern int mnt_context_set_mountdata(mnt_context *cxt, void *data);
-extern int mnt_context_apply_fstab(mnt_context *cxt);
-extern int mnt_context_get_status(mnt_context *cxt);
-extern int mnt_context_strerror(mnt_context *cxt, char *buf, size_t bufsiz);
-
-extern int mnt_mount_context(mnt_context *cxt);
-
-extern int mnt_context_prepare_mount(mnt_context *cxt);
-extern int mnt_context_do_mount(mnt_context *cxt);
-extern int mnt_context_finalize_mount(mnt_context *cxt);
-
-extern int mnt_context_do_umount(mnt_context *cxt);
+extern struct libmnt_context *mnt_new_context(void);
+extern void mnt_free_context(struct libmnt_context *cxt);
+extern int mnt_reset_context(struct libmnt_context *cxt);
+extern int mnt_context_is_restricted(struct libmnt_context *cxt);
+
+extern int mnt_context_init_helper(struct libmnt_context *cxt, int flags);
+extern int mnt_context_mounthelper_setopt(struct libmnt_context *cxt, int c,
+ char *arg);
+
+extern int mnt_context_set_optsmode(struct libmnt_context *cxt, int mode);
+extern int mnt_context_disable_canonicalize(struct libmnt_context *cxt, int disable);
+extern int mnt_context_enable_lazy(struct libmnt_context *cxt, int enable);
+extern int mnt_context_enable_rdonly_umount(struct libmnt_context *cxt, int enable);
+extern int mnt_context_disable_helpers(struct libmnt_context *cxt, int disable);
+extern int mnt_context_enable_sloppy(struct libmnt_context *cxt, int enable);
+extern int mnt_context_enable_fake(struct libmnt_context *cxt, int enable);
+extern int mnt_context_disable_mtab(struct libmnt_context *cxt, int disable);
+extern int mnt_context_enable_force(struct libmnt_context *cxt, int enable);
+extern int mnt_context_enable_verbose(struct libmnt_context *cxt, int enable);
+extern int mnt_context_enable_loopdel(struct libmnt_context *cxt, int enable);
+
+extern int mnt_context_get_optsmode(struct libmnt_context *cxt);
+extern int mnt_context_is_lazy(struct libmnt_context *cxt);
+extern int mnt_context_is_rdonly_umount(struct libmnt_context *cxt);
+extern int mnt_context_is_sloppy(struct libmnt_context *cxt);
+extern int mnt_context_is_fake(struct libmnt_context *cxt);
+extern int mnt_context_is_nomtab(struct libmnt_context *cxt);
+extern int mnt_context_is_force(struct libmnt_context *cxt);
+extern int mnt_context_is_verbose(struct libmnt_context *cxt);
+
+extern int mnt_context_set_fs(struct libmnt_context *cxt, struct libmnt_fs *fs);
+extern struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt);
+extern int mnt_context_set_source(struct libmnt_context *cxt, const char *source);
+extern int mnt_context_set_target(struct libmnt_context *cxt, const char *target);
+extern int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype);
+extern int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr);
+extern int mnt_context_append_options(struct libmnt_context *cxt,
+ const char *optstr);
+extern int mnt_context_set_fstype_pattern(struct libmnt_context *cxt,
+ const char *pattern);
+extern int mnt_context_set_options_pattern(struct libmnt_context *cxt,
+ const char *pattern);
+
+extern int mnt_context_set_fstab(struct libmnt_context *cxt,
+ struct libmnt_table *tb);
+extern int mnt_context_get_fstab(struct libmnt_context *cxt,
+ struct libmnt_table **tb);
+extern int mnt_context_get_mtab(struct libmnt_context *cxt,
+ struct libmnt_table **tb);
+extern int mnt_context_set_cache(struct libmnt_context *cxt,
+ struct libmnt_cache *cache);
+extern struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt);
+extern struct libmnt_lock *mnt_context_get_lock(struct libmnt_context *cxt);
+
+extern int mnt_context_set_mflags(struct libmnt_context *cxt,
+ unsigned long flags);
+extern int mnt_context_get_mflags(struct libmnt_context *cxt,
+ unsigned long *flags);
+extern int mnt_context_set_user_mflags(struct libmnt_context *cxt,
+ unsigned long flags);
+extern int mnt_context_get_user_mflags(struct libmnt_context *cxt,
+ unsigned long *flags);
+
+extern int mnt_context_set_mountdata(struct libmnt_context *cxt, void *data);
+extern int mnt_context_apply_fstab(struct libmnt_context *cxt);
+extern int mnt_context_get_status(struct libmnt_context *cxt);
+extern int mnt_context_strerror(struct libmnt_context *cxt, char *buf,
+ size_t bufsiz);
+
+extern int mnt_mount_context(struct libmnt_context *cxt);
+
+extern int mnt_context_prepare_mount(struct libmnt_context *cxt);
+extern int mnt_context_do_mount(struct libmnt_context *cxt);
+extern int mnt_context_finalize_mount(struct libmnt_context *cxt);
+
+extern int mnt_context_do_umount(struct libmnt_context *cxt);
/*
* mount(8) userspace options masks (MNT_MAP_USERSPACE map)
/*
* lock handler
*/
-struct _mnt_lock {
+struct libmnt_lock {
char *lockfile; /* path to lock file (e.g. /etc/mtab~) */
char *linkfile; /* path to link file (e.g. /etc/mtab~.<id>) */
int lockfile_fd; /* lock file descriptor */
*
* Returns: newly allocated lock handler or NULL on case of error.
*/
-mnt_lock *mnt_new_lock(const char *datafile, pid_t id)
+struct libmnt_lock *mnt_new_lock(const char *datafile, pid_t id)
{
- mnt_lock *ml = NULL;
+ struct libmnt_lock *ml = NULL;
char *lo = NULL, *ln = NULL;
/* lockfile */
ln = NULL;
goto err;
}
- ml = calloc(1, sizeof(struct _mnt_lock) );
+ ml = calloc(1, sizeof(*ml) );
if (!ml)
goto err;
/**
* mnt_free_lock:
- * @ml: mnt_lock handler
+ * @ml: struct libmnt_lock handler
*
* Deallocates mnt_lock.
*/
-void mnt_free_lock(mnt_lock *ml)
+void mnt_free_lock(struct libmnt_lock *ml)
{
if (!ml)
return;
/*
* Returns path to lockfile.
*/
-static const char *mnt_lock_get_lockfile(mnt_lock *ml)
+static const char *mnt_lock_get_lockfile(struct libmnt_lock *ml)
{
return ml ? ml->lockfile : NULL;
}
*
* Returns: unique (per process/thread) path to linkfile.
*/
-static const char *mnt_lock_get_linkfile(mnt_lock *ml)
+static const char *mnt_lock_get_linkfile(struct libmnt_lock *ml)
{
return ml ? ml->linkfile : NULL;
}
*
* Returns: 0 on success, 1 on timeout, -errno on error.
*/
-static int mnt_wait_lock(mnt_lock *ml, struct flock *fl, time_t maxtime)
+static int mnt_wait_lock(struct libmnt_lock *ml, struct flock *fl, time_t maxtime)
{
struct timeval now;
struct sigaction sa, osa;
* Unlocks the file. The function could be called independently on the
* lock status (for example from exit(3)).
*/
-void mnt_unlock_file(mnt_lock *ml)
+void mnt_unlock_file(struct libmnt_lock *ml)
{
if (!ml)
return;
/**
* mnt_lock_file
- * @ml: pointer to mnt_lock instance
+ * @ml: pointer to struct libmnt_lock instance
*
* Creates lock file (e.g. /etc/mtab~). Note that this function uses
* alarm().
*
* <informalexample>
* <programlisting>
- * mnt_lock *ml;
+ * struct libmnt_lock *ml;
*
* void unlock_fallback(void)
* {
* Returns: 0 on success or negative number in case of error (-ETIMEOUT is case
* of stale lock file).
*/
-int mnt_lock_file(mnt_lock *ml)
+int mnt_lock_file(struct libmnt_lock *ml)
{
int i, rc = -1;
struct timespec waittime;
#ifdef TEST_PROGRAM
#include <err.h>
-mnt_lock *lock;
+struct libmnt_lock *lock;
/*
* read number from @filename, increment the number and
errx(EXIT_FAILURE, "\n%d: catch signal: %s\n", getpid(), strsignal(sig));
}
-int test_lock(struct mtest *ts, int argc, char *argv[])
+int test_lock(struct libmnt_test *ts, int argc, char *argv[])
{
time_t synctime = 0;
unsigned int usecs;
*/
int main(int argc, char *argv[])
{
- struct mtest tss[] = {
+ struct libmnt_test tss[] = {
{ "--lock", test_lock, " [--synctime <time_t>] [--verbose] <datafile> <loops> "
"increment a number in datafile" },
{ NULL }
mnt_context_get_fs;
mnt_context_get_fstab;
mnt_context_get_lock;
- mnt_context_get_mountflags;
+ mnt_context_get_mflags;
mnt_context_get_mtab;
mnt_context_get_optsmode;
mnt_context_get_status;
- mnt_context_get_userspace_mountflags;
+ mnt_context_get_user_mflags;
mnt_context_init_helper;
mnt_context_is_fake;
mnt_context_is_force;
mnt_context_set_fstype;
mnt_context_set_fstype_pattern;
mnt_context_set_mountdata;
- mnt_context_set_mountflags;
+ mnt_context_set_mflags;
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_set_user_mflags;
mnt_context_strerror;
mnt_copy_fs;
mnt_free_cache;
mnt_free_iter;
mnt_free_lock;
mnt_free_mntent;
- mnt_free_tab;
+ mnt_free_table;
mnt_free_update;
mnt_fs_append_attributes;
mnt_fs_append_fs_options;
mnt_fs_append_options;
- mnt_fs_append_userspace_options;
+ mnt_fs_append_user_options;
mnt_fs_append_vfs_options;
mnt_fs_get_attribute;
mnt_fs_get_attributes;
mnt_fs_get_tag;
mnt_fs_get_target;
mnt_fs_get_userdata;
- mnt_fs_get_userspace_options;
+ mnt_fs_get_user_options;
mnt_fs_get_vfs_options;
mnt_fs_match_fstype;
mnt_fs_match_options;
mnt_fs_prepend_attributes;
mnt_fs_prepend_fs_options;
mnt_fs_prepend_options;
- mnt_fs_prepend_userspace_options;
+ mnt_fs_prepend_user_options;
mnt_fs_prepend_vfs_options;
mnt_fs_print_debug;
mnt_fs_set_attributes;
mnt_fs_set_source;
mnt_fs_set_target;
mnt_fs_set_userdata;
- mnt_fs_set_userspace_options;
+ mnt_fs_set_user_options;
mnt_fs_set_vfs_options;
mnt_fs_strdup_options;
mnt_fs_to_mntent;
mnt_new_fs;
mnt_new_iter;
mnt_new_lock;
- mnt_new_tab;
- mnt_new_tab_from_dir;
- mnt_new_tab_from_file;
+ mnt_new_table;
+ mnt_new_table_from_dir;
+ mnt_new_table_from_file;
mnt_new_update;
mnt_optstr_append_option;
mnt_optstr_apply_flags;
mnt_resolve_spec;
mnt_resolve_tag;
mnt_split_optstr;
- 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_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_set_parser_errcb;
+ mnt_table_add_fs;
+ mnt_table_find_next_fs;
+ mnt_table_find_pair;
+ mnt_table_find_source;
+ mnt_table_find_srcpath;
+ mnt_table_find_tag;
+ mnt_table_find_target;
+ mnt_table_get_cache;
+ mnt_table_get_name;
+ mnt_table_get_nents;
+ mnt_table_get_root_fs;
+ mnt_table_next_child_fs;
+ mnt_table_next_fs;
+ mnt_table_parse_file;
+ mnt_table_parse_fstab;
+ mnt_table_parse_mtab;
+ mnt_table_parse_stream;
+ mnt_table_remove_fs;
+ mnt_table_set_cache;
+ mnt_table_set_iter;
+ mnt_table_set_parser_errcb;
mnt_unlock_file;
mnt_unmangle;
mnt_update_force_rdonly;
mnt_update_get_filename;
mnt_update_get_fs;
- mnt_update_get_mountflags;
+ mnt_update_get_mflags;
mnt_update_is_ready;
mnt_update_set_fs;
- mnt_update_tab;
+ mnt_update_table;
local:
*;
};
#define MNT_UTAB_HEADER "# libmount utab file\n"
#ifdef TEST_PROGRAM
-struct mtest {
+struct libmnt_test {
const char *name;
- int (*body)(struct mtest *ts, int argc, char *argv[]);
+ int (*body)(struct libmnt_test *ts, int argc, char *argv[]);
const char *usage;
};
/* test.c */
-extern int mnt_run_test(struct mtest *tests, int argc, char *argv[]);
+extern int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[]);
#endif
/* utils.c */
/*
* Generic iterator
*/
-struct _mnt_iter {
+struct libmnt_iter {
struct list_head *p; /* current position */
struct list_head *head; /* start position */
int direction; /* MNT_ITER_{FOR,BACK}WARD */
* This struct represents one entry in mtab/fstab/mountinfo file.
* (note that fstab[1] means the first column from fstab, and so on...)
*/
-struct _mnt_fs {
+struct libmnt_fs {
struct list_head ents;
int id; /* mountinfo[1]: ID */
/*
* mtab/fstab/mountinfo file
*/
-struct _mnt_tab {
+struct libmnt_table {
int fmt; /* MNT_FMT_* file format */
int nents; /* number of valid entries */
- mnt_cache *cache; /* canonicalized paths/tags cache */
+ struct libmnt_cache *cache; /* canonicalized paths/tags cache */
- int (*errcb)(mnt_tab *tb, const char *filename, int line);
+ int (*errcb)(struct libmnt_table *tb,
+ const char *filename, int line);
- struct list_head ents; /* list of entries (mentry) */
+ struct list_head ents; /* list of entries (libmnt_fs) */
};
-extern mnt_tab *__mnt_new_tab_from_file(const char *filename, int fmt);
+extern struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt);
/*
* Tab file format
/*
* Mount context -- high-level API
*/
-struct _mnt_context
+struct libmnt_context
{
int action; /* MNT_ACT_{MOUNT,UMOUNT} */
int restricted; /* root or not? */
char *fstype_pattern; /* for mnt_match_fstype() */
char *optstr_pattern; /* for mnt_match_options() */
- mnt_fs *fs; /* filesystem description (type, mountpopint, device, ...) */
+ struct libmnt_fs *fs; /* filesystem description (type, mountpopint, device, ...) */
+
+ struct libmnt_table *fstab; /* fstab (or mtab for some remounts) entires */
+ struct libmnt_table *mtab; /* mtab entries */
- mnt_tab *fstab; /* fstab (or mtab for some remounts) entires */
- mnt_tab *mtab; /* mtab entries */
int optsmode; /* fstab optstr mode MNT_OPTSMODE_{AUTO,FORCE,IGNORE} */
unsigned long mountflags; /* final mount(2) flags */
unsigned long user_mountflags; /* MNT_MS_* (loop=, user=, ...) */
- mnt_cache *cache; /* paths cache */
- mnt_lock *lock; /* mtab lock */
- mnt_update *update;/* mtab/utab update */
+ struct libmnt_cache *cache; /* paths cache */
+ struct libmnt_lock *lock; /* mtab lock */
+ struct libmnt_update *update;/* mtab/utab update */
const char *mtab_path; /* writable mtab */
int mtab_writable; /* ismtab writeable */
#define MNT_FL_DEFAULT 0
/* optmap.c */
-extern const struct mnt_optmap *mnt_optmap_get_entry(struct mnt_optmap const **maps,
+extern const struct libmnt_optmap *mnt_optmap_get_entry(
+ struct libmnt_optmap const **maps,
int nmaps, const char *name,
- size_t namelen, const struct mnt_optmap **mapent);
+ size_t namelen,
+ const struct libmnt_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 struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs);
+extern int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source);
+extern int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype);
/* context.c */
-extern int mnt_context_prepare_srcpath(mnt_context *cxt);
-extern int mnt_context_prepare_target(mnt_context *cxt);
-extern int mnt_context_guess_fstype(mnt_context *cxt);
-extern int mnt_context_prepare_helper(mnt_context *cxt, const char *name, const char *type);
-extern int mnt_context_prepare_update(mnt_context *cxt);
-extern mnt_fs *mnt_context_get_fs(mnt_context *cxt);
-extern int mnt_context_merge_mountflags(mnt_context *cxt);
-extern int mnt_context_update_tabs(mnt_context *cxt);
+extern int mnt_context_prepare_srcpath(struct libmnt_context *cxt);
+extern int mnt_context_prepare_target(struct libmnt_context *cxt);
+extern int mnt_context_guess_fstype(struct libmnt_context *cxt);
+extern int mnt_context_prepare_helper(struct libmnt_context *cxt,
+ const char *name, const char *type);
+extern int mnt_context_prepare_update(struct libmnt_context *cxt);
+extern struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt);
+extern int mnt_context_merge_mflags(struct libmnt_context *cxt);
+extern int mnt_context_update_tabs(struct libmnt_context *cxt);
/* tab_update.c */
-extern mnt_fs *mnt_update_get_fs(mnt_update *upd);
-extern int mnt_update_set_filename(mnt_update *upd, const char *filename, int userspace_only);
+extern struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd);
+extern int mnt_update_set_filename(struct libmnt_update *upd,
+ const char *filename, int userspace_only);
#endif /* _LIBMOUNT_PRIVATE_H */
* #define MY_MS_FOO (1 << 1)
* #define MY_MS_BAR (1 << 2)
*
- * mnt_optmap myoptions[] = {
+ * libmnt_optmap myoptions[] = {
* { "foo", MY_MS_FOO },
* { "nofoo", MY_MS_FOO | MNT_INVERT },
* { "bar=", MY_MS_BAR },
/*
* fs-independent mount flags (built-in MNT_LINUX_MAP)
*/
-static const struct mnt_optmap linux_flags_map[] =
+static const struct libmnt_optmap linux_flags_map[] =
{
{ "ro", MS_RDONLY }, /* read-only */
{ "rw", MS_RDONLY, MNT_INVERT }, /* read-write */
*
* TODO: offset=, sizelimit=, encryption=, vfs=
*/
-static const struct mnt_optmap userspace_opts_map[] =
+static const struct libmnt_optmap userspace_opts_map[] =
{
{ "defaults", 0, 0 }, /* default options */
*
* Returns: static built-in libmount map.
*/
-const struct mnt_optmap *mnt_get_builtin_optmap(int id)
+const struct libmnt_optmap *mnt_get_builtin_optmap(int id)
{
assert(id);
* Lookups for the @name in @maps and returns a map and in @mapent
* returns the map entry
*/
-const struct mnt_optmap *mnt_optmap_get_entry(
- struct mnt_optmap const **maps,
+const struct libmnt_optmap *mnt_optmap_get_entry(
+ struct libmnt_optmap const **maps,
int nmaps,
const char *name,
size_t namelen,
- const struct mnt_optmap **mapent)
+ const struct libmnt_optmap **mapent)
{
int i;
*mapent = NULL;
for (i = 0; i < nmaps; i++) {
- const struct mnt_optmap *map = maps[i];
- const struct mnt_optmap *ent;
+ const struct libmnt_optmap *map = maps[i];
+ const struct libmnt_optmap *ent;
const char *p;
for (ent = map; ent && ent->name; ent++) {
/*
* Option location
*/
-struct mnt_optloc {
+struct libmnt_optloc {
char *begin;
char *end;
char *value;
size_t namesz;
};
-#define mnt_init_optloc(_ol) (memset((_ol), 0, sizeof(struct mnt_optloc)))
+#define mnt_init_optloc(_ol) (memset((_ol), 0, sizeof(struct libmnt_optloc)))
/*
* Parses the first option from @optstr. The @optstr pointer is set to begin of
* Returns negative number on parse error, 1 when not found and 0 on success.
*/
static int mnt_optstr_locate_option(char *optstr, const char *name,
- struct mnt_optloc *ol)
+ struct libmnt_optloc *ol)
{
char *n;
size_t namesz, nsz;
int mnt_optstr_get_option(char *optstr, const char *name,
char **value, size_t *valsz)
{
- struct mnt_optloc ol;
+ struct libmnt_optloc ol;
int rc;
mnt_init_optloc(&ol);
*/
int mnt_optstr_set_option(char **optstr, const char *name, const char *value)
{
- struct mnt_optloc ol;
+ struct libmnt_optloc ol;
char *nameend;
int rc = 1;
*/
int mnt_optstr_remove_option(char **optstr, const char *name)
{
- struct mnt_optloc ol;
+ struct libmnt_optloc ol;
int rc;
mnt_init_optloc(&ol);
*
* 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;
- struct mnt_optmap const *maps[2];
+ struct libmnt_optmap const *maps[2];
assert(optstr);
while(!mnt_optstr_next_option(&str, &name, &namesz, &val, &valsz)) {
int rc = 0;
- const struct mnt_optmap *ent;
- const struct mnt_optmap *m =
+ const struct libmnt_optmap *ent;
+ const struct libmnt_optmap *m =
mnt_optmap_get_entry(maps, 2, name, namesz, &ent);
if (ent && !ent->id)
* Returns: 0 on success, or negative number in case of error.
*/
int mnt_optstr_get_options(const char *optstr, char **subset,
- const struct mnt_optmap *map, int ignore)
+ const struct libmnt_optmap *map, int ignore)
{
- struct mnt_optmap const *maps[1];
+ struct libmnt_optmap const *maps[1];
char *name, *val, *str = (char *) optstr;
size_t namesz, valsz;
while(!mnt_optstr_next_option(&str, &name, &namesz, &val, &valsz)) {
int rc = 0;
- const struct mnt_optmap *ent;
+ const struct libmnt_optmap *ent;
mnt_optmap_get_entry(maps, 1, name, namesz, &ent);
* 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)
+ const struct libmnt_optmap *map)
{
- struct mnt_optmap const *maps[1];
+ struct libmnt_optmap const *maps[1];
char *name, *str = (char *) optstr;
size_t namesz = 0;
maps[0] = map;
while(!mnt_optstr_next_option(&str, &name, &namesz, NULL, NULL)) {
- const struct mnt_optmap *ent;
+ const struct libmnt_optmap *ent;
if (mnt_optmap_get_entry(maps, 1, name, namesz, &ent)) {
if (!ent->id)
* Returns: 0 on success or negative number in case of error.
*/
int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
- const struct mnt_optmap *map)
+ const struct libmnt_optmap *map)
{
- struct mnt_optmap const *maps[1];
+ struct libmnt_optmap const *maps[1];
char *name, *next, *val;
size_t namesz = 0, valsz = 0;
unsigned long fl;
*/
while(!mnt_optstr_next_option(&next, &name, &namesz,
&val, &valsz)) {
- const struct mnt_optmap *ent;
+ const struct libmnt_optmap *ent;
if (mnt_optmap_get_entry(maps, 1, name, namesz, &ent)) {
/*
/* add missing options */
if (fl) {
- const struct mnt_optmap *ent;
+ const struct libmnt_optmap *ent;
char *p;
for (ent = map; ent && ent->name; ent++) {
int mnt_optstr_fix_user(char **optstr)
{
char *username;
- struct mnt_optloc ol;
+ struct libmnt_optloc ol;
int rc = 0;
DBG(CXT, mnt_debug("fixing user"));
#ifdef TEST_PROGRAM
-int test_append(struct mtest *ts, int argc, char *argv[])
+int test_append(struct libmnt_test *ts, int argc, char *argv[])
{
const char *value = NULL, *name;
char *optstr;
return rc;
}
-int test_prepend(struct mtest *ts, int argc, char *argv[])
+int test_prepend(struct libmnt_test *ts, int argc, char *argv[])
{
const char *value = NULL, *name;
char *optstr;
return rc;
}
-int test_split(struct mtest *ts, int argc, char *argv[])
+int test_split(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr, *user = NULL, *fs = NULL, *vfs = NULL;
int rc;
return rc;
}
-int test_flags(struct mtest *ts, int argc, char *argv[])
+int test_flags(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr;
int rc;
return rc;
}
-int test_apply(struct mtest *ts, int argc, char *argv[])
+int test_apply(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr;
int rc, map;
return rc;
}
-int test_set(struct mtest *ts, int argc, char *argv[])
+int test_set(struct libmnt_test *ts, int argc, char *argv[])
{
const char *value = NULL, *name;
char *optstr;
return rc;
}
-int test_get(struct mtest *ts, int argc, char *argv[])
+int test_get(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr;
const char *name;
return rc;
}
-int test_remove(struct mtest *ts, int argc, char *argv[])
+int test_remove(struct libmnt_test *ts, int argc, char *argv[])
{
const char *name;
char *optstr;
return rc;
}
-int test_fix(struct mtest *ts, int argc, char *argv[])
+int test_fix(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr;
int rc = 0;
int main(int argc, char *argv[])
{
- struct mtest tss[] = {
+ struct libmnt_test tss[] = {
{ "--append", test_append, "<optstr> <name> [<value>] append value to optstr" },
{ "--prepend",test_prepend,"<optstr> <name> [<value>] prepend value to optstr" },
{ "--set", test_set, "<optstr> <name> [<value>] (un)set value" },
* @short_description: container for entries from fstab/mtab/mountinfo
*
*
- * Note that mnt_tab_find_* functions are mount(8) compatible. These functions
+ * Note that mnt_table_find_* functions are mount(8) compatible. These functions
* try to found an entry in more iterations where the first attempt is always
* based on comparison with unmodified (non-canonicalized or un-evaluated)
* paths or tags. For example fstab with two entries:
* where both lines are used for the *same* device, then
* <informalexample>
* <programlisting>
- * mnt_tab_find_source(tb, "/dev/foo", &fs);
+ * mnt_table_find_source(tb, "/dev/foo", &fs);
* </programlisting>
* </informalexample>
* will returns the second line, and
* <informalexample>
* <programlisting>
- * mnt_tab_find_source(tb, "LABEL=foo", &fs);
+ * mnt_table_find_source(tb, "LABEL=foo", &fs);
* </programlisting>
* </informalexample>
* will returns the first entry, and
* <informalexample>
* <programlisting>
- * mnt_tab_find_source(tb, "UUID=anyuuid", &fs);
+ * mnt_table_find_source(tb, "UUID=anyuuid", &fs);
* </programlisting>
* </informalexample>
* will returns the first entry (if UUID matches with the device).
#include "c.h"
/**
- * mnt_new_tab:
+ * mnt_new_table:
*
- * The tab is a container for mnt_fs entries that usually represents a fstab,
+ * The tab is a container for struct libmnt_fs entries that usually represents a fstab,
* mtab or mountinfo file from your system.
*
- * See also mnt_tab_parse_file().
+ * See also mnt_table_parse_file().
*
* Returns: newly allocated tab struct.
*/
-mnt_tab *mnt_new_tab(void)
+struct libmnt_table *mnt_new_table(void)
{
- mnt_tab *tb = NULL;
+ struct libmnt_table *tb = NULL;
- tb = calloc(1, sizeof(struct _mnt_tab));
+ tb = calloc(1, sizeof(*tb));
if (!tb)
return NULL;
}
/**
- * mnt_free_tab:
+ * mnt_free_table:
* @tb: tab pointer
*
* Deallocates tab struct and all entries.
*/
-void mnt_free_tab(mnt_tab *tb)
+void mnt_free_table(struct libmnt_table *tb)
{
if (!tb)
return;
DBG(TAB, mnt_debug_h(tb, "free"));
while (!list_empty(&tb->ents)) {
- mnt_fs *fs = list_entry(tb->ents.next, mnt_fs, ents);
+ struct libmnt_fs *fs = list_entry(tb->ents.next,
+ struct libmnt_fs, ents);
mnt_free_fs(fs);
}
}
/**
- * mnt_tab_get_nents:
+ * mnt_table_get_nents:
* @tb: pointer to tab
*
* Returns: number of valid entries in tab.
*/
-int mnt_tab_get_nents(mnt_tab *tb)
+int mnt_table_get_nents(struct libmnt_table *tb)
{
assert(tb);
return tb ? tb->nents : 0;
}
/**
- * mnt_tab_set_cache:
+ * mnt_table_set_cache:
* @tb: pointer to tab
- * @mpc: pointer to mnt_cache instance
+ * @mpc: pointer to struct libmnt_cache instance
*
* Setups a cache for canonicalized paths and evaluated tags (LABEL/UUID). The
- * cache is recommended for mnt_tab_find_*() functions.
+ * cache is recommended for mnt_table_find_*() functions.
*
* The cache could be shared between more tabs. Be careful when you share the
* same cache between more threads -- currently the cache does not provide any
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_tab_set_cache(mnt_tab *tb, mnt_cache *mpc)
+int mnt_table_set_cache(struct libmnt_table *tb, struct libmnt_cache *mpc)
{
assert(tb);
if (!tb)
}
/**
- * mnt_tab_get_cache:
+ * mnt_table_get_cache:
* @tb: pointer to tab
*
- * Returns: pointer to mnt_cache instance or NULL.
+ * Returns: pointer to struct libmnt_cache instance or NULL.
*/
-mnt_cache *mnt_tab_get_cache(mnt_tab *tb)
+struct libmnt_cache *mnt_table_get_cache(struct libmnt_table *tb)
{
assert(tb);
return tb ? tb->cache : NULL;
}
/**
- * mnt_tab_add_fs:
+ * mnt_table_add_fs:
* @tb: tab pointer
* @fs: new entry
*
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_tab_add_fs(mnt_tab *tb, mnt_fs *fs)
+int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
{
assert(tb);
assert(fs);
}
/**
- * mnt_tab_remove_fs:
+ * mnt_table_remove_fs:
* @tb: tab pointer
* @fs: new entry
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_tab_remove_fs(mnt_tab *tb, mnt_fs *fs)
+int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
{
assert(tb);
assert(fs);
}
/**
- * mnt_tab_get_root_fs:
+ * mnt_table_get_root_fs:
* @tb: mountinfo file (/proc/self/mountinfo)
* @root: returns pointer to the root filesystem (/)
*
* Returns: 0 on success or -1 case of error.
*/
-int mnt_tab_get_root_fs(mnt_tab *tb, mnt_fs **root)
+int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
{
- mnt_iter itr;
- mnt_fs *fs;
+ struct libmnt_iter itr;
+ struct libmnt_fs *fs;
int root_id = 0;
assert(tb);
DBG(TAB, mnt_debug_h(tb, "lookup root fs"));
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
int id = mnt_fs_get_parent_id(fs);
if (!id)
break; /* @tab is not mountinfo file? */
}
/**
- * mnt_tab_next_child_fs:
+ * mnt_table_next_child_fs:
* @tb: mountinfo file (/proc/self/mountinfo)
* @itr: iterator
* @parent: parental FS
*
* Returns: 0 on success, negative number in case of error or 1 at end of list.
*/
-int mnt_tab_next_child_fs(mnt_tab *tb, mnt_iter *itr,
- mnt_fs *parent, mnt_fs **chld)
+int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
+ struct libmnt_fs *parent, struct libmnt_fs **chld)
{
- mnt_fs *fs;
+ struct libmnt_fs *fs;
int parent_id, lastchld_id = 0, chld_id = 0;
if (!tb || !itr || !parent)
/* get ID of the previously returned child */
if (itr->head && itr->p != itr->head) {
- MNT_ITER_ITERATE(itr, fs, struct _mnt_fs, ents);
+ MNT_ITER_ITERATE(itr, fs, struct libmnt_fs, ents);
lastchld_id = mnt_fs_get_id(fs);
}
*chld = NULL;
mnt_reset_iter(itr, MNT_ITER_FORWARD);
- while(mnt_tab_next_fs(tb, itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, itr, &fs) == 0) {
int id;
if (mnt_fs_get_parent_id(fs) != parent_id)
return 1; /* end of iterator */
/* set the iterator to the @chld for the next call */
- mnt_tab_set_iter(tb, itr, *chld);
+ mnt_table_set_iter(tb, itr, *chld);
return 0;
}
/**
- * mnt_tab_next_fs:
+ * mnt_table_next_fs:
* @tb: tab pointer
* @itr: iterator
* @fs: returns the next tab entry
* Example:
* <informalexample>
* <programlisting>
- * mnt_fs *fs;
- * mnt_tab *tb = mnt_new_tab("/etc/fstab");
- * mnt_iter *itr = mnt_new_iter(MNT_ITER_BACKWARD);
- *
- * mnt_tab_parse_file(tb);
- *
- * while(mnt_tab_next_fs(tb, itr, &fs) == 0) {
+ * while(mnt_table_next_fs(tb, itr, &fs) == 0) {
* const char *dir = mnt_fs_get_target(fs);
* printf("mount point: %s\n", dir);
* }
- * mnt_free_tab(fi);
+ * mnt_free_table(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)
+int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs **fs)
{
int rc = 1;
if (!itr->head)
MNT_ITER_INIT(itr, &tb->ents);
if (itr->p != itr->head) {
- MNT_ITER_ITERATE(itr, *fs, struct _mnt_fs, ents);
+ MNT_ITER_ITERATE(itr, *fs, struct libmnt_fs, ents);
rc = 0;
}
}
/**
- * mnt_tab_find_next_fs:
+ * mnt_table_find_next_fs:
* @tb: table
* @itr: iterator
* @match_func: function returns 1 or 0
*
* Returns: negative number in case of error, 1 at end of table or 0 o success.
*/
-int mnt_tab_find_next_fs(mnt_tab *tb, mnt_iter *itr,
- int (*match_func)(mnt_fs *, void *), void *userdata,
- mnt_fs **fs)
+int mnt_table_find_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
+ int (*match_func)(struct libmnt_fs *, void *), void *userdata,
+ struct libmnt_fs **fs)
{
if (!tb || !itr || !fs || !match_func)
return -EINVAL;
do {
if (itr->p != itr->head)
- MNT_ITER_ITERATE(itr, *fs, struct _mnt_fs, ents);
+ MNT_ITER_ITERATE(itr, *fs, struct libmnt_fs, ents);
else
break; /* end */
}
/**
- * mnt_tab_set_iter:
+ * mnt_table_set_iter:
* @tb: tab pointer
* @itr: iterator
* @fs: tab entry
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_tab_set_iter(mnt_tab *tb, mnt_iter *itr, mnt_fs *fs)
+int mnt_table_set_iter(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs *fs)
{
assert(tb);
assert(itr);
}
/**
- * mnt_tab_find_target:
+ * mnt_table_find_target:
* @tb: tab pointer
* @path: mountpoint directory
* @direction: MNT_ITER_{FORWARD,BACKWARD}
* Try to lookup an entry in given tab, possible are three iterations, first
* with @path, second with realpath(@path) and third with realpath(@path)
* against realpath(fs->target). The 2nd and 3rd iterations are not performed
- * when @tb cache is not set (see mnt_tab_set_cache()).
+ * when @tb cache is not set (see mnt_table_set_cache()).
*
* Returns: a tab entry or NULL.
*/
-mnt_fs *mnt_tab_find_target(mnt_tab *tb, const char *path, int direction)
+struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *path, int direction)
{
- mnt_iter itr;
- mnt_fs *fs = NULL;
+ struct libmnt_iter itr;
+ struct libmnt_fs *fs = NULL;
char *cn;
assert(tb);
/* native @target */
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0)
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0)
if (fs->target && strcmp(fs->target, path) == 0)
return fs;
if (!tb->cache || !(cn = mnt_resolve_path(path, tb->cache)))
return NULL;
- /* canonicalized paths in mnt_tab */
+ /* canonicalized paths in struct libmnt_table */
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
if (fs->target && strcmp(fs->target, cn) == 0)
return fs;
}
- /* non-canonicaled path in mnt_tab */
+ /* non-canonicaled path in struct libmnt_table */
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
char *p;
if (!fs->target || !(fs->flags & MNT_FS_SWAP) ||
}
/**
- * mnt_tab_find_srcpath:
+ * mnt_table_find_srcpath:
* @tb: tab pointer
* @path: source path (devname or dirname)
* @direction: MNT_ITER_{FORWARD,BACKWARD}
* from @path and fourth with realpath(@path) against realpath(entry->srcpath).
*
* The 2nd, 3rd and 4th iterations are not performed when @tb cache is not
- * set (see mnt_tab_set_cache()).
+ * set (see mnt_table_set_cache()).
*
* Returns: a tab entry or NULL.
*/
-mnt_fs *mnt_tab_find_srcpath(mnt_tab *tb, const char *path, int direction)
+struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *path, int direction)
{
- mnt_iter itr;
- mnt_fs *fs = NULL;
+ struct libmnt_iter itr;
+ struct libmnt_fs *fs = NULL;
int ntags = 0;
char *cn;
const char *p;
/* native paths */
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
p = mnt_fs_get_srcpath(fs);
if (p && strcmp(p, path) == 0)
return fs;
if (!tb->cache || !(cn = mnt_resolve_path(path, tb->cache)))
return NULL;
- /* canonicalized paths in mnt_tab */
- if (ntags < mnt_tab_get_nents(tb)) {
+ /* canonicalized paths in struct libmnt_table */
+ if (ntags < mnt_table_get_nents(tb)) {
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
p = mnt_fs_get_srcpath(fs);
if (p && strcmp(p, cn) == 0)
return fs;
if (rc == 0) {
/* @path's TAGs are in the cache */
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
const char *t, *v;
if (mnt_fs_get_tag(fs, &t, &v))
/* @path is unaccessible, try evaluate all TAGs in @tb
* by udev symlinks -- this could be expensive on systems
* with huge fstab/mtab */
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
const char *t, *v, *x;
if (mnt_fs_get_tag(fs, &t, &v))
continue;
}
}
- /* non-canonicalized paths in mnt_tab */
- if (ntags <= mnt_tab_get_nents(tb)) {
+ /* non-canonicalized paths in struct libmnt_table */
+ if (ntags <= mnt_table_get_nents(tb)) {
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
if (fs->flags & (MNT_FS_NET | MNT_FS_PSEUDO))
continue;
p = mnt_fs_get_srcpath(fs);
/**
- * mnt_tab_find_tag:
+ * mnt_table_find_tag:
* @tb: tab pointer
* @tag: tag name (e.g "LABEL", "UUID", ...)
* @val: tag value
*
* Try to lookup an entry in given tab, first attempt is lookup by @tag and
* @val, for the second attempt the tag is evaluated (converted to the device
- * name) and mnt_tab_find_srcpath() is preformed. The second attempt is not
- * performed when @tb cache is not set (see mnt_tab_set_cache()).
+ * name) and mnt_table_find_srcpath() is preformed. The second attempt is not
+ * performed when @tb cache is not set (see mnt_table_set_cache()).
* Returns: a tab entry or NULL.
*/
-mnt_fs *mnt_tab_find_tag(mnt_tab *tb, const char *tag,
+struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag,
const char *val, int direction)
{
- mnt_iter itr;
- mnt_fs *fs = NULL;
+ struct libmnt_iter itr;
+ struct libmnt_fs *fs = NULL;
assert(tb);
assert(tag);
/* look up by TAG */
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
if (fs->tagname && fs->tagval &&
strcmp(fs->tagname, tag) == 0 &&
strcmp(fs->tagval, val) == 0)
/* look up by device name */
char *cn = mnt_resolve_tag(tag, val, tb->cache);
if (cn)
- return mnt_tab_find_srcpath(tb, cn, direction);
+ return mnt_table_find_srcpath(tb, cn, direction);
}
return NULL;
}
/**
- * mnt_tab_find_source:
+ * mnt_table_find_source:
* @tb: tab pointer
* @source: TAG or path
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * This is high-level API for mnt_tab_find_{srcpath,tag}. You needn't to care
+ * This is high-level API for mnt_table_find_{srcpath,tag}. You needn't to care
* about @source format (device, LABEL, UUID, ...). This function parses @source
- * and calls mnt_tab_find_tag() or mnt_tab_find_srcpath().
+ * and calls mnt_table_find_tag() or mnt_table_find_srcpath().
*
* Returns: a tab entry or NULL.
*/
-mnt_fs *mnt_tab_find_source(mnt_tab *tb, const char *source, int direction)
+struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb, const char *source, int direction)
{
- mnt_fs *fs = NULL;
+ struct libmnt_fs *fs = NULL;
assert(tb);
assert(source);
if (blkid_parse_tag_string(source, &tag, &val) == 0) {
- fs = mnt_tab_find_tag(tb, tag, val, direction);
+ fs = mnt_table_find_tag(tb, tag, val, direction);
free(tag);
free(val);
}
} else
- fs = mnt_tab_find_srcpath(tb, source, direction);
+ fs = mnt_table_find_srcpath(tb, source, direction);
return fs;
}
/**
- * mnt_tab_find_pair
+ * mnt_table_find_pair
* @tb: tab pointer
* @source: TAG or path
* @target: mountpoint
*
* This function is implemented by mnt_fs_match_source() and
* mnt_fs_match_target() functions. It means that this is more expensive that
- * others mnt_tab_find_* function, because every @tab entry is fully evaluated.
+ * others mnt_table_find_* function, because every @tab entry is fully evaluated.
*
* Returns: a tab entry or NULL.
*/
-mnt_fs *mnt_tab_find_pair(mnt_tab *tb, const char *source,
+struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *source,
const char *target, int direction)
{
- mnt_fs *fs = NULL;
- mnt_iter itr;
+ struct libmnt_fs *fs = NULL;
+ struct libmnt_iter itr;
assert(tb);
assert(source);
DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s TARGET: %s", source, target));
mnt_reset_iter(&itr, direction);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
if (mnt_fs_match_target(fs, target, tb->cache) &&
mnt_fs_match_source(fs, source, tb->cache))
#ifdef TEST_PROGRAM
-static int parser_errcb(mnt_tab *tb, const char *filename, int line)
+static int parser_errcb(struct libmnt_table *tb, const char *filename, int line)
{
fprintf(stderr, "%s:%d: parse error\n", filename, line);
return 1; /* all errors are recoverable -- this is default */
}
-mnt_tab *create_tab(const char *file)
+struct libmnt_table *create_table(const char *file)
{
- mnt_tab *tb;
+ struct libmnt_table *tb;
if (!file)
return NULL;
- tb = mnt_new_tab();
+ tb = mnt_new_table();
if (!tb)
goto err;
- mnt_tab_set_parser_errcb(tb, parser_errcb);
+ mnt_table_set_parser_errcb(tb, parser_errcb);
- if (mnt_tab_parse_file(tb, file) != 0)
+ if (mnt_table_parse_file(tb, file) != 0)
goto err;
return tb;
err:
fprintf(stderr, "%s: parsing failed\n", file);
- mnt_free_tab(tb);
+ mnt_free_table(tb);
return NULL;
}
-int test_copy_fs(struct mtest *ts, int argc, char *argv[])
+int test_copy_fs(struct libmnt_test *ts, int argc, char *argv[])
{
- mnt_tab *tb;
- mnt_fs *fs;
+ struct libmnt_table *tb;
+ struct libmnt_fs *fs;
int rc = -1;
- tb = create_tab(argv[1]);
+ tb = create_table(argv[1]);
if (!tb)
return -1;
- fs = mnt_tab_find_target(tb, "/", MNT_ITER_FORWARD);
+ fs = mnt_table_find_target(tb, "/", MNT_ITER_FORWARD);
if (!fs)
goto done;
mnt_free_fs(fs);
rc = 0;
done:
- mnt_free_tab(tb);
+ mnt_free_table(tb);
return rc;
}
-int test_parse(struct mtest *ts, int argc, char *argv[])
+int test_parse(struct libmnt_test *ts, int argc, char *argv[])
{
- mnt_tab *tb = NULL;
- mnt_iter *itr = NULL;
- mnt_fs *fs;
+ struct libmnt_table *tb = NULL;
+ struct libmnt_iter *itr = NULL;
+ struct libmnt_fs *fs;
int rc = -1;
- tb = create_tab(argv[1]);
+ tb = create_table(argv[1]);
if (!tb)
return -1;
if (!itr)
goto done;
- while(mnt_tab_next_fs(tb, itr, &fs) == 0)
+ while(mnt_table_next_fs(tb, itr, &fs) == 0)
mnt_fs_print_debug(fs, stdout);
rc = 0;
done:
mnt_free_iter(itr);
- mnt_free_tab(tb);
+ mnt_free_table(tb);
return rc;
}
-int test_find(struct mtest *ts, int argc, char *argv[], int dr)
+int test_find(struct libmnt_test *ts, int argc, char *argv[], int dr)
{
- mnt_tab *tb;
- mnt_fs *fs = NULL;
- mnt_cache *mpc = NULL;
+ struct libmnt_table *tb;
+ struct libmnt_fs *fs = NULL;
+ struct libmnt_cache *mpc = NULL;
const char *file, *find, *what;
int rc = -1;
file = argv[1], find = argv[2], what = argv[3];
- tb = create_tab(file);
+ tb = create_table(file);
if (!tb)
goto done;
mpc = mnt_new_cache();
if (!mpc)
goto done;
- mnt_tab_set_cache(tb, mpc);
+ mnt_table_set_cache(tb, mpc);
if (strcasecmp(find, "source") == 0)
- fs = mnt_tab_find_source(tb, what, dr);
+ fs = mnt_table_find_source(tb, what, dr);
else if (strcasecmp(find, "target") == 0)
- fs = mnt_tab_find_target(tb, what, dr);
+ fs = mnt_table_find_target(tb, what, dr);
if (!fs)
fprintf(stderr, "%s: not found %s '%s'\n", file, find, what);
rc = 0;
}
done:
- mnt_free_tab(tb);
+ mnt_free_table(tb);
mnt_free_cache(mpc);
return rc;
}
-int test_find_bw(struct mtest *ts, int argc, char *argv[])
+int test_find_bw(struct libmnt_test *ts, int argc, char *argv[])
{
return test_find(ts, argc, argv, MNT_ITER_BACKWARD);
}
-int test_find_fw(struct mtest *ts, int argc, char *argv[])
+int test_find_fw(struct libmnt_test *ts, int argc, char *argv[])
{
return test_find(ts, argc, argv, MNT_ITER_FORWARD);
}
-int test_find_pair(struct mtest *ts, int argc, char *argv[])
+int test_find_pair(struct libmnt_test *ts, int argc, char *argv[])
{
- mnt_tab *tb;
- mnt_fs *fs;
+ struct libmnt_table *tb;
+ struct libmnt_fs *fs;
int rc = -1;
- tb = create_tab(argv[1]);
+ tb = create_table(argv[1]);
if (!tb)
return -1;
- fs = mnt_tab_find_pair(tb, argv[2], argv[3], MNT_ITER_FORWARD);
+ fs = mnt_table_find_pair(tb, argv[2], argv[3], MNT_ITER_FORWARD);
if (!fs)
goto done;
mnt_fs_print_debug(fs, stdout);
rc = 0;
done:
- mnt_free_tab(tb);
+ mnt_free_table(tb);
return rc;
}
int main(int argc, char *argv[])
{
- struct mtest tss[] = {
+ struct libmnt_test tss[] = {
{ "--parse", test_parse, "<file> parse and print tab" },
{ "--find-forward", test_find_fw, "<file> <source|target> <string>" },
{ "--find-backward", test_find_bw, "<file> <source|target> <string>" },
/*
* Parses one line from {fs,m}tab
*/
-static int mnt_parse_tab_line(mnt_fs *fs, char *s)
+static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
{
int rc, n = 0;
char *src, *fstype, *optstr;
/*
* Parses one line from mountinfo file
*/
-static int mnt_parse_mountinfo_line(mnt_fs *fs, char *s)
+static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
{
int rc;
unsigned int maj, min;
/*
* Parses one line from utab file
*/
-static int mnt_parse_utab_line(mnt_fs *fs, const char *s)
+static int mnt_parse_utab_line(struct libmnt_fs *fs, const char *s)
{
const char *p = s;
*
* mountinfo: "<number> <number> ... "
*/
-static int guess_tab_format(char *line)
+static int guess_table_format(char *line)
{
unsigned int a, b;
/*
* Read and parse the next line from {fs,m}tab or mountinfo
*/
-static int mnt_tab_parse_next(mnt_tab *tb, FILE *f, mnt_fs *fs,
+static int mnt_table_parse_next(struct libmnt_table *tb, FILE *f, struct libmnt_fs *fs,
const char *filename, int *nlines)
{
char buf[BUFSIZ];
} while (*s == '\0' || *s == '#');
if (tb->fmt == MNT_FMT_GUESS)
- tb->fmt = guess_tab_format(s);
+ tb->fmt = guess_table_format(s);
if (tb->fmt == MNT_FMT_FSTAB) {
- if (mnt_parse_tab_line(fs, s) != 0)
+ if (mnt_parse_table_line(fs, s) != 0)
goto err;
} else if (tb->fmt == MNT_FMT_MOUNTINFO) {
tb->fmt == MNT_FMT_FSTAB ? "fstab" : "utab"));
/* by default all errors are recoverable, otherwise behavior depends on
- * errcb() function. See mnt_tab_set_parser_errcb().
+ * errcb() function. See mnt_table_set_parser_errcb().
*/
return tb->errcb ? tb->errcb(tb, filename, *nlines) : 1;
}
/**
- * mnt_tab_parse_stream:
+ * mnt_table_parse_stream:
* @tb: tab pointer
* @f: file stream
* @filename: filename used for debug and error messages
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_tab_parse_stream(mnt_tab *tb, FILE *f, const char *filename)
+int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
{
int nlines = 0;
int rc = -1;
DBG(TAB, mnt_debug_h(tb, "%s: start parsing", filename));
while (!feof(f)) {
- mnt_fs *fs = mnt_new_fs();
+ struct libmnt_fs *fs = mnt_new_fs();
if (!fs)
goto err;
- rc = mnt_tab_parse_next(tb, f, fs, filename, &nlines);
+ rc = mnt_table_parse_next(tb, f, fs, filename, &nlines);
if (!rc)
- rc = mnt_tab_add_fs(tb, fs);
+ rc = mnt_table_add_fs(tb, fs);
if (rc) {
mnt_free_fs(fs);
if (rc == 1)
}
/**
- * mnt_tab_parse_file:
+ * mnt_table_parse_file:
* @tb: tab pointer
* @filename: file
*
* Parses whole table (e.g. /etc/mtab) and appends new records to the @tab.
*
* The libmount parser ignores broken (syntax error) lines, these lines are
- * reported to caller by errcb() function (see mnt_tab_set_parser_errcb()).
+ * reported to caller by errcb() function (see mnt_table_set_parser_errcb()).
*
* Returns: 0 on success, negative number in case of error.
*/
-int mnt_tab_parse_file(mnt_tab *tb, const char *filename)
+int mnt_table_parse_file(struct libmnt_table *tb, const char *filename)
{
FILE *f;
int rc;
f = fopen(filename, "r");
if (f) {
- rc = mnt_tab_parse_stream(tb, f, filename);
+ rc = mnt_table_parse_stream(tb, f, filename);
fclose(f);
} else
return -errno;
return rc;
}
-static int mnt_tab_parse_dir(mnt_tab *tb, const char *dirname)
+static int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname)
{
int n = 0, i;
DIR *dir = NULL;
f = fopen_at(dirfd(dir), _PATH_MNTTAB_DIR,
d->d_name, O_RDONLY, "r");
if (f) {
- mnt_tab_parse_stream(tb, f, d->d_name);
+ mnt_table_parse_stream(tb, f, d->d_name);
fclose(f);
}
}
return 0;
}
-mnt_tab *__mnt_new_tab_from_file(const char *filename, int fmt)
+struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt)
{
- mnt_tab *tb;
+ struct libmnt_table *tb;
struct stat st;
assert(filename);
return NULL;
if (stat(filename, &st))
return NULL;
- tb = mnt_new_tab();
+ tb = mnt_new_table();
if (tb) {
tb->fmt = fmt;
- if (mnt_tab_parse_file(tb, filename) != 0) {
- mnt_free_tab(tb);
+ if (mnt_table_parse_file(tb, filename) != 0) {
+ mnt_free_table(tb);
tb = NULL;
}
}
}
/**
- * mnt_new_tab_from_file:
+ * mnt_new_table_from_file:
* @filename: /etc/{m,fs}tab or /proc/self/mountinfo path
*
- * Same as mnt_new_tab() + mnt_tab_parse_file(). Use this function for private
+ * Same as mnt_new_table() + mnt_table_parse_file(). Use this function for private
* files only. This function does not allow to use error callback, so you
* cannot provide any feedback to end-users about broken records in files (e.g.
* fstab).
*
* Returns: newly allocated tab on success and NULL in case of error.
*/
-mnt_tab *mnt_new_tab_from_file(const char *filename)
+struct libmnt_table *mnt_new_table_from_file(const char *filename)
{
- return __mnt_new_tab_from_file(filename, MNT_FMT_GUESS);
+ return __mnt_new_table_from_file(filename, MNT_FMT_GUESS);
}
/**
- * mnt_new_tab_from_dir
+ * mnt_new_table_from_dir
* @dirname: for example /etc/fstab.d
*
* Returns: newly allocated tab on success and NULL in case of error.
*/
-mnt_tab *mnt_new_tab_from_dir(const char *dirname)
+struct libmnt_table *mnt_new_table_from_dir(const char *dirname)
{
- mnt_tab *tb;
+ struct libmnt_table *tb;
assert(dirname);
if (!dirname)
return NULL;
- tb = mnt_new_tab();
- if (tb && mnt_tab_parse_dir(tb, dirname) != 0) {
- mnt_free_tab(tb);
+ tb = mnt_new_table();
+ if (tb && mnt_table_parse_dir(tb, dirname) != 0) {
+ mnt_free_table(tb);
tb = NULL;
}
return tb;
}
/**
- * mnt_tab_set_parser_errcb:
+ * mnt_table_set_parser_errcb:
* @tb: pointer to table
* @cb: pointer to callback function
*
- * The error callback function is called by table parser (mnt_tab_parse_file())
+ * The error callback function is called by table parser (mnt_table_parse_file())
* in case of syntax error. The callback function could be used for errors
* evaluation, libmount will continue/stop parsing according to callback return
* codes:
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_tab_set_parser_errcb(mnt_tab *tb,
- int (*cb)(mnt_tab *tb, const char *filename, int line))
+int mnt_table_set_parser_errcb(struct libmnt_table *tb,
+ int (*cb)(struct libmnt_table *tb, const char *filename, int line))
{
assert(tb);
tb->errcb = cb;
}
/**
- * mnt_tab_parse_fstab:
+ * mnt_table_parse_fstab:
* @tb: table
* @filename: overwrites default (/etc/fstab or $LIBMOUNT_FSTAB) or NULL
*
* - files that starts with "." are ignored (e.g. ".10foo.fstab")
* - files without the ".fstab" extension are ignored
*
- * See also mnt_tab_set_parser_errcb().
+ * See also mnt_table_set_parser_errcb().
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_tab_parse_fstab(mnt_tab *tb, const char *filename)
+int mnt_table_parse_fstab(struct libmnt_table *tb, const char *filename)
{
FILE *f;
f = fopen(filename, "r");
if (f) {
- int rc = mnt_tab_parse_stream(tb, f, filename);
+ int rc = mnt_table_parse_stream(tb, f, filename);
fclose(f);
if (rc)
}
if (!access(_PATH_MNTTAB_DIR, R_OK))
- return mnt_tab_parse_dir(tb, _PATH_MNTTAB_DIR);
+ return mnt_table_parse_dir(tb, _PATH_MNTTAB_DIR);
return 0;
}
/*
* This function uses @uf to found corresponding record in @tb, then the record
- * from @tb is updated (userspace specific mount options are added).
+ * from @tb is updated (user specific mount options are added).
*
- * Note that @uf must contain only userspace specific mount options instead of
+ * Note that @uf must contain only user specific mount options instead of
* VFS options (note that FS options are ignored).
*
* Returns modified filesystem (from @tb) or NULL.
*/
-static mnt_fs *mnt_tab_merge_userspace_fs(mnt_tab *tb, mnt_fs *uf)
+static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct libmnt_fs *uf)
{
- mnt_fs *fs;
- mnt_iter itr;
+ struct libmnt_fs *fs;
+ struct libmnt_iter itr;
const char *optstr, *src, *target, *root, *attrs;
assert(tb);
if (!tb || !uf)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "merging userspace fs"));
+ DBG(TAB, mnt_debug_h(tb, "merging user fs"));
src = mnt_fs_get_srcpath(uf);
target = mnt_fs_get_target(uf);
- optstr = mnt_fs_get_userspace_options(uf);
+ optstr = mnt_fs_get_user_options(uf);
attrs = mnt_fs_get_attributes(uf);
root = mnt_fs_get_root(uf);
mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
const char *s = mnt_fs_get_srcpath(fs),
*t = mnt_fs_get_target(fs),
*r = mnt_fs_get_root(fs);
}
if (fs) {
- DBG(TAB, mnt_debug_h(tb, "found fs -- appending userspace optstr"));
- mnt_fs_append_userspace_options(fs, optstr);
+ DBG(TAB, mnt_debug_h(tb, "found fs -- appending user optstr"));
+ mnt_fs_append_user_options(fs, optstr);
mnt_fs_append_attributes(fs, attrs);
mnt_fs_set_bindsrc(fs, mnt_fs_get_bindsrc(uf));
}
/**
- * mnt_tab_parse_mtab:
+ * mnt_table_parse_mtab:
* @tb: table
* @filename: overwrites default (/etc/mtab or $LIBMOUNT_MTAB) or NULL
*
* This function parses /etc/mtab or /proc/self/mountinfo +
* /dev/.mount/utabs or /proc/mounts.
*
- * See also mnt_tab_set_parser_errcb().
+ * See also mnt_table_set_parser_errcb().
*
* Returns: 0 on success or negative number in case of error.
*/
-int mnt_tab_parse_mtab(mnt_tab *tb, const char *filename)
+int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename)
{
int rc;
const char *utab = NULL;
DBG(TAB, mnt_debug_h(tb, "force %s usage", filename));
- rc = mnt_tab_parse_file(tb, filename);
+ rc = mnt_table_parse_file(tb, filename);
if (!rc)
return 0;
filename = NULL; /* failed */
* -- read kernel information from /proc/self/mountinfo
*/
tb->fmt = MNT_FMT_MOUNTINFO;
- rc = mnt_tab_parse_file(tb, _PATH_PROC_MOUNTINFO);
+ rc = mnt_table_parse_file(tb, _PATH_PROC_MOUNTINFO);
if (rc) {
/* hmm, old kernel? ...try /proc/mounts */
tb->fmt = MNT_FMT_MTAB;
- return mnt_tab_parse_file(tb, _PATH_PROC_MOUNTS);
+ return mnt_table_parse_file(tb, _PATH_PROC_MOUNTS);
}
/*
- * try to read userspace specific information from /dev/.mount/utabs
+ * try to read user specific information from /dev/.mount/utabs
*/
utab = mnt_get_utab_path();
if (utab) {
- mnt_tab *u_tb = __mnt_new_tab_from_file(utab, MNT_FMT_UTAB);
+ struct libmnt_table *u_tb = __mnt_new_table_from_file(utab, MNT_FMT_UTAB);
if (u_tb) {
- mnt_fs *u_fs;
- mnt_iter itr;
+ struct libmnt_fs *u_fs;
+ struct libmnt_iter itr;
mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
- /* merge userspace options into mountinfo from kernel */
- while(mnt_tab_next_fs(u_tb, &itr, &u_fs) == 0)
- mnt_tab_merge_userspace_fs(tb, u_fs);
+ /* merge user options into mountinfo from kernel */
+ while(mnt_table_next_fs(u_tb, &itr, &u_fs) == 0)
+ mnt_table_merge_user_fs(tb, u_fs);
- mnt_free_tab(u_tb);
+ mnt_free_table(u_tb);
}
}
return 0;
* @title: mtab managment
* @short_description: userspace mount information management.
*
- * The mnt_update provides abstraction to manage mount options in userspace independently on
+ * The struct libmnt_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.
+ * It's recommended to use high-level struct libmnt_context API.
*/
#include <stdio.h>
#include "mangle.h"
#include "pathnames.h"
-struct _mnt_update {
+struct libmnt_update {
char *target;
- mnt_fs *fs;
+ struct libmnt_fs *fs;
char *filename;
unsigned long mountflags;
int userspace_only;
int ready;
};
-static int utab_new_entry(mnt_fs *fs, unsigned long mountflags, mnt_fs **ent);
-static int set_fs_root(mnt_fs *result, mnt_fs *fs, unsigned long mountflags);
+static int utab_new_entry(struct libmnt_fs *fs, unsigned long mountflags, struct libmnt_fs **ent);
+static int set_fs_root(struct libmnt_fs *result, struct libmnt_fs *fs, unsigned long mountflags);
/**
* mnt_new_update:
*
* Returns: newly allocated update handler
*/
-mnt_update *mnt_new_update(void)
+struct libmnt_update *mnt_new_update(void)
{
- mnt_update *upd;
+ struct libmnt_update *upd;
- upd = calloc(1, sizeof(struct _mnt_update));
+ upd = calloc(1, sizeof(*upd));
if (!upd)
return NULL;
* mnt_free_update:
* @upd: update
*
- * Deallocates mnt_update handler.
+ * Deallocates struct libmnt_update handler.
*/
-void mnt_free_update(mnt_update *upd)
+void mnt_free_update(struct libmnt_update *upd)
{
if (!upd)
return;
/*
* Returns 0 on success, 1 if not file available, -1 in case of error.
*/
-int mnt_update_set_filename(mnt_update *upd, const char *filename, int userspace_only)
+int mnt_update_set_filename(struct libmnt_update *upd, const char *filename, int userspace_only)
{
const char *path = NULL;
int rw = 0;
*
* Returns: pointer to filename that will be updated or NULL in case of error.
*/
-const char *mnt_update_get_filename(mnt_update *upd)
+const char *mnt_update_get_filename(struct libmnt_update *upd)
{
return upd && !upd->userspace_only ? upd->filename : NULL;
}
* Returns: 1 if entry described by @upd is successfully prepared and will be
* written to mtab/utab file.
*/
-int mnt_update_is_ready(mnt_update *upd)
+int mnt_update_is_ready(struct libmnt_update *upd)
{
return upd ? upd->ready : FALSE;
}
*
* Returns: -1 in case on error, 0 on success, 1 if update is unnecessary.
*/
-int mnt_update_set_fs(mnt_update *upd, unsigned long mountflags,
- const char *target, mnt_fs *fs)
+int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
+ const char *target, struct libmnt_fs *fs)
{
int rc;
*
* Returns: update filesystem entry or NULL
*/
-mnt_fs *mnt_update_get_fs(mnt_update *upd)
+struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd)
{
return upd ? upd->fs : NULL;
}
/**
- * mnt_update_get_mountflags:
+ * mnt_update_get_mflags:
* @upd: update
*
* Returns: mount flags as was set by mnt_update_set_fs()
*/
-unsigned long mnt_update_get_mountflags(mnt_update *upd)
+unsigned long mnt_update_get_mflags(struct libmnt_update *upd)
{
return upd ? upd->mountflags : 0;
}
*
* Returns: 0 on success and negative number in case of error.
*/
-int mnt_update_force_rdonly(mnt_update *upd, int rdonly)
+int mnt_update_force_rdonly(struct libmnt_update *upd, int rdonly)
{
int rc = 0;
* Returns: 0 on success, negative number on error, 1 if utabs update is
* unnecessary.
*/
-static int utab_new_entry(mnt_fs *fs, unsigned long mountflags, mnt_fs **ent)
+static int utab_new_entry(struct libmnt_fs *fs, unsigned long mountflags, struct libmnt_fs **ent)
{
int rc = 0;
const char *o = NULL, *a = NULL;
DBG(UPDATE, mnt_debug("prepare utab entry"));
- o = mnt_fs_get_userspace_options(fs);
+ o = mnt_fs_get_user_options(fs);
a = mnt_fs_get_attributes(fs);
if (o) {
goto err;
}
- rc = mnt_fs_set_userspace_options(*ent, u);
+ rc = mnt_fs_set_user_options(*ent, u);
if (rc)
goto err;
rc = mnt_fs_set_attributes(*ent, a);
return rc;
}
-static int set_fs_root(mnt_fs *result, mnt_fs *fs, unsigned long mountflags)
+static int set_fs_root(struct libmnt_fs *result, struct libmnt_fs *fs, unsigned long mountflags)
{
char *root = NULL, *mnt = NULL;
const char *fstype;
- mnt_tab *tb = NULL;
+ struct libmnt_table *tb = NULL;
int rc = -ENOMEM;
assert(fs);
*/
if (mountflags & MS_BIND) {
const char *src, *src_root;
- mnt_fs *src_fs;
+ struct libmnt_fs *src_fs;
DBG(UPDATE, mnt_debug("setting FS root: bind"));
}
root = mnt_get_fs_root(src, mnt);
- tb = __mnt_new_tab_from_file(_PATH_PROC_MOUNTINFO, MNT_FMT_MOUNTINFO);
+ tb = __mnt_new_table_from_file(_PATH_PROC_MOUNTINFO, MNT_FMT_MOUNTINFO);
if (!tb) {
DBG(UPDATE, mnt_debug("failed to parse mountinfo -- using default"));
goto dflt;
}
- src_fs = mnt_tab_find_target(tb, mnt, MNT_ITER_BACKWARD);
+ src_fs = mnt_table_find_target(tb, mnt, MNT_ITER_BACKWARD);
if (!src_fs) {
DBG(UPDATE, mnt_debug("not found '%s' in mountinfo -- using default", mnt));
goto dflt;
*(root + sz) = '\0';
}
dflt:
- mnt_free_tab(tb);
+ mnt_free_table(tb);
if (!root) {
root = strdup("/");
if (!root)
}
/* mtab and fstab update */
-static int fprintf_mtab_fs(FILE *f, mnt_fs *fs)
+static int fprintf_mtab_fs(FILE *f, struct libmnt_fs *fs)
{
char *o;
char *m1, *m2, *m3, *m4;
return rc;
}
-static int fprintf_utab_fs(FILE *f, mnt_fs *fs)
+static int fprintf_utab_fs(FILE *f, struct libmnt_fs *fs)
{
char *p;
fprintf(f, "ATTRS=%s ", p);
free(p);
}
- p = mangle(mnt_fs_get_userspace_options(fs));
+ p = mangle(mnt_fs_get_user_options(fs));
if (p) {
fprintf(f, "OPTS=%s", p);
free(p);
return 0;
}
-static int update_tab(mnt_update *upd, mnt_tab *tb)
+static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
{
FILE *f;
int rc, fd;
f = fdopen(fd, "w");
if (f) {
struct stat st;
- mnt_iter itr;
- mnt_fs *fs;
+ struct libmnt_iter itr;
+ struct libmnt_fs *fs;
int fd;
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
if (upd->userspace_only)
fprintf_utab_fs(f, fs);
else
}
}
-static int update_add_entry(mnt_update *upd, mnt_lock *lc)
+static int update_add_entry(struct libmnt_update *upd, struct libmnt_lock *lc)
{
FILE *f;
int rc = 0, u_lc = -1;
return rc;
}
-static int update_remove_entry(mnt_update *upd, mnt_lock *lc)
+static int update_remove_entry(struct libmnt_update *upd, struct libmnt_lock *lc)
{
- mnt_tab *tb;
+ struct libmnt_table *tb;
int rc = 0, u_lc = -1;
assert(upd);
else if (upd->userspace_only)
u_lc = utab_lock(upd->filename);
- tb = __mnt_new_tab_from_file(upd->filename,
+ tb = __mnt_new_table_from_file(upd->filename,
upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
if (tb) {
- mnt_fs *rem = mnt_tab_find_target(tb, upd->target, MNT_ITER_BACKWARD);
+ struct libmnt_fs *rem = mnt_table_find_target(tb, upd->target, MNT_ITER_BACKWARD);
if (rem) {
- mnt_tab_remove_fs(tb, rem);
- rc = update_tab(upd, tb);
+ mnt_table_remove_fs(tb, rem);
+ rc = update_table(upd, tb);
mnt_free_fs(rem);
}
- mnt_free_tab(tb);
+ mnt_free_table(tb);
}
if (lc)
mnt_unlock_file(lc);
return rc;
}
-static int update_modify_target(mnt_update *upd, mnt_lock *lc)
+static int update_modify_target(struct libmnt_update *upd, struct libmnt_lock *lc)
{
- mnt_tab *tb = NULL;
+ struct libmnt_table *tb = NULL;
int rc = 0, u_lc = -1;
DBG(UPDATE, mnt_debug_h(upd, "%s: modify target", upd->filename));
else if (upd->userspace_only)
u_lc = utab_lock(upd->filename);
- tb = __mnt_new_tab_from_file(upd->filename,
+ tb = __mnt_new_table_from_file(upd->filename,
upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
if (tb) {
- mnt_fs *cur = mnt_tab_find_target(tb,
+ struct libmnt_fs *cur = mnt_table_find_target(tb,
mnt_fs_get_srcpath(upd->fs), MNT_ITER_BACKWARD);
if (cur) {
rc = mnt_fs_set_target(cur, mnt_fs_get_target(upd->fs));
if (!rc)
- rc = update_tab(upd, tb);
+ rc = update_table(upd, tb);
}
- mnt_free_tab(tb);
+ mnt_free_table(tb);
}
if (lc)
mnt_unlock_file(lc);
return rc;
}
-static int update_modify_options(mnt_update *upd, mnt_lock *lc)
+static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock *lc)
{
- mnt_tab *tb = NULL;
+ struct libmnt_table *tb = NULL;
int rc = 0, u_lc = -1;
- mnt_fs *fs;
+ struct libmnt_fs *fs;
assert(upd);
assert(upd->fs);
else if (upd->userspace_only)
u_lc = utab_lock(upd->filename);
- tb = __mnt_new_tab_from_file(upd->filename,
+ tb = __mnt_new_table_from_file(upd->filename,
upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
if (tb) {
- mnt_fs *cur = mnt_tab_find_target(tb,
+ struct libmnt_fs *cur = mnt_table_find_target(tb,
mnt_fs_get_target(fs),
MNT_ITER_BACKWARD);
if (cur) {
if (!rc && !upd->userspace_only)
rc = mnt_fs_set_fs_options(cur, mnt_fs_get_fs_options(fs));
if (!rc)
- rc = mnt_fs_set_userspace_options(cur,
- mnt_fs_get_userspace_options(fs));
+ rc = mnt_fs_set_user_options(cur,
+ mnt_fs_get_user_options(fs));
if (!rc)
- rc = update_tab(upd, tb);
+ rc = update_table(upd, tb);
}
- mnt_free_tab(tb);
+ mnt_free_table(tb);
}
if (lc)
}
/**
- * mnt_update_tab:
+ * mnt_update_table:
* @upd: update
* @lc: lock
*
*
* Returns: 0 on success, negative number on error.
*/
-int mnt_update_tab(mnt_update *upd, mnt_lock *lc)
+int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc)
{
int rc = -EINVAL;
#ifdef TEST_PROGRAM
-mnt_lock *lock;
+struct libmnt_lock *lock;
static void lock_fallback(void)
{
mnt_unlock_file(lock);
}
-static int update(const char *target, mnt_fs *fs, unsigned long mountflags)
+static int update(const char *target, struct libmnt_fs *fs, unsigned long mountflags)
{
int rc;
- mnt_update *upd;
+ struct libmnt_update *upd;
const char *filename;
DBG(UPDATE, mnt_debug("update test"));
if (lock)
atexit(lock_fallback);
}
- rc = mnt_update_tab(upd, lock);
+ rc = mnt_update_table(upd, lock);
done:
return rc;
}
-static int test_add(struct mtest *ts, int argc, char *argv[])
+static int test_add(struct libmnt_test *ts, int argc, char *argv[])
{
- mnt_fs *fs = mnt_new_fs();
+ struct libmnt_fs *fs = mnt_new_fs();
int rc;
if (argc < 5 || !fs)
return rc;
}
-static int test_remove(struct mtest *ts, int argc, char *argv[])
+static int test_remove(struct libmnt_test *ts, int argc, char *argv[])
{
if (argc < 2)
return -1;
return update(argv[1], NULL, 0);
}
-static int test_move(struct mtest *ts, int argc, char *argv[])
+static int test_move(struct libmnt_test *ts, int argc, char *argv[])
{
- mnt_fs *fs = mnt_new_fs();
+ struct libmnt_fs *fs = mnt_new_fs();
int rc;
if (argc < 3)
return rc;
}
-static int test_remount(struct mtest *ts, int argc, char *argv[])
+static int test_remount(struct libmnt_test *ts, int argc, char *argv[])
{
- mnt_fs *fs = mnt_new_fs();
+ struct libmnt_fs *fs = mnt_new_fs();
int rc;
if (argc < 3)
int main(int argc, char *argv[])
{
- struct mtest tss[] = {
+ struct libmnt_test tss[] = {
{ "--add", test_add, "<src> <target> <type> <options> add line to mtab" },
{ "--remove", test_remove, "<target> MS_REMOUNT mtab change" },
{ "--move", test_move, "<old_target> <target> MS_MOVE mtab change" },
#include "mountP.h"
-int mnt_run_test(struct mtest *tests, int argc, char *argv[])
+int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[])
{
int rc = -1;
- struct mtest *ts;
+ struct libmnt_test *ts;
assert(tests);
assert(argc);
}
#ifdef TEST_PROGRAM
-int test_match_fstype(struct mtest *ts, int argc, char *argv[])
+int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[])
{
char *type = argv[1];
char *pattern = argv[2];
return 0;
}
-int test_match_options(struct mtest *ts, int argc, char *argv[])
+int test_match_options(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr = argv[1];
char *pattern = argv[2];
return 0;
}
-int test_startswith(struct mtest *ts, int argc, char *argv[])
+int test_startswith(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr = argv[1];
char *pattern = argv[2];
return 0;
}
-int test_endswith(struct mtest *ts, int argc, char *argv[])
+int test_endswith(struct libmnt_test *ts, int argc, char *argv[])
{
char *optstr = argv[1];
char *pattern = argv[2];
return 0;
}
-int test_mountpoint(struct mtest *ts, int argc, char *argv[])
+int test_mountpoint(struct libmnt_test *ts, int argc, char *argv[])
{
char *path = canonicalize_path(argv[1]),
*mnt = path ? mnt_get_mountpoint(path) : NULL;
return 0;
}
-int test_fsroot(struct mtest *ts, int argc, char *argv[])
+int test_fsroot(struct libmnt_test *ts, int argc, char *argv[])
{
char *path = canonicalize_path(argv[1]),
*mnt = path ? mnt_get_fs_root(path, NULL) : NULL;
return 0;
}
-int test_filesystems(struct mtest *ts, int argc, char *argv[])
+int test_filesystems(struct libmnt_test *ts, int argc, char *argv[])
{
char **filesystems = NULL;
int rc;
int main(int argc, char *argv[])
{
- struct mtest tss[] = {
+ struct libmnt_test tss[] = {
{ "--match-fstype", test_match_fstype, "<type> <pattern> FS types matching" },
{ "--match-options", test_match_options, "<options> <pattern> options matching" },
{ "--filesystems", test_filesystems, "[<pattern>] list /{etc,proc}/filesystems" },
}
#ifdef TEST_PROGRAM
-int test_version(struct mtest *ts, int argc, char *argv[])
+int test_version(struct libmnt_test *ts, int argc, char *argv[])
{
const char *ver;
int main(int argc, char *argv[])
{
- struct mtest ts[] = {
+ struct libmnt_test ts[] = {
{ "--print", test_version, "print versions" },
{ NULL }
};