*/
blkid_cache bc;
- struct libmnt_table *mtab;
+ struct libmnt_table *mountinfo;
};
/**
cache->refcount--;
/*DBG(CACHE, ul_debugobj(cache, "unref=%d", cache->refcount));*/
if (cache->refcount <= 0) {
- mnt_unref_table(cache->mtab);
+ mnt_unref_table(cache->mountinfo);
mnt_free_cache(cache);
}
/**
* mnt_cache_set_targets:
* @cache: cache pointer
- * @mtab: table with already canonicalized mountpoints
+ * @mountinfo: table with already canonicalized mountpoints
*
- * Add to @cache reference to @mtab. This can be used to avoid unnecessary paths
+ * Add to @cache reference to @mountinfo. This can be used to avoid unnecessary paths
* canonicalization in mnt_resolve_target().
*
* Returns: negative number in case of error, or 0 o success.
*/
int mnt_cache_set_targets(struct libmnt_cache *cache,
- struct libmnt_table *mtab)
+ struct libmnt_table *mountinfo)
{
if (!cache)
return -EINVAL;
- mnt_ref_table(mtab);
- mnt_unref_table(cache->mtab);
- cache->mtab = mtab;
+ mnt_ref_table(mountinfo);
+ mnt_unref_table(cache->mountinfo);
+ cache->mountinfo = mountinfo;
return 0;
}
* @cache: cache for results or NULL.
*
* Like mnt_resolve_path(), unless @cache is not NULL and
- * mnt_cache_set_targets(cache, mtab) was called: if @path is found in the
- * cached @mtab and the matching entry was provided by the kernel, assume that
+ * mnt_cache_set_targets(cache, mountinfo) was called: if @path is found in the
+ * cached @mountinfo and the matching entry was provided by the kernel, assume that
* @path is already canonicalized. By avoiding a call to realpath(2) on
* known mount points, there is a lower risk of stepping on a stale mount
* point, which can result in an application freeze. This is also faster in
/*DBG(CACHE, ul_debugobj(cache, "resolving target %s", path));*/
- if (!cache || !cache->mtab)
+ if (!cache || !cache->mountinfo)
return mnt_resolve_path(path, cache);
p = (char *) cache_find_path(cache, path);
struct libmnt_fs *fs = NULL;
mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
- while (mnt_table_next_fs(cache->mtab, &itr, &fs) == 0) {
+ while (mnt_table_next_fs(cache->mountinfo, &itr, &fs) == 0) {
if (!mnt_fs_is_kernel(fs)
|| mnt_fs_is_swaparea(fs)
fl = cxt->flags;
mnt_unref_fs(cxt->fs);
- mnt_unref_table(cxt->mtab);
+ mnt_unref_table(cxt->mountinfo);
mnt_unref_table(cxt->utab);
free(cxt->helper);
cxt->tgt_mode = (mode_t) -1;
cxt->fs = NULL;
- cxt->mtab = NULL;
+ cxt->mountinfo = NULL;
cxt->utab = NULL;
cxt->helper = NULL;
cxt->orig_user = NULL;
goto failed;
}
- n->mtab = o->mtab;
- mnt_ref_table(n->mtab);
+ n->mountinfo = o->mountinfo;
+ mnt_ref_table(n->mountinfo);
- n->mtab = o->utab;
+ n->utab = o->utab;
mnt_ref_table(n->utab);
if (strdup_between_structs(n, o, tgt_prefix))
DBG(CXT, ul_debugobj(cxt, "checking for writable tab files"));
- cxt->mtab_writable = 0;
-
ns_old = mnt_context_switch_target_ns(cxt);
if (!ns_old)
return -MNT_ERR_NAMESPACE;
return 0;
}
-int mnt_context_mtab_writable(struct libmnt_context *cxt)
-{
- assert(cxt);
-
- context_init_paths(cxt, 1);
- return cxt->mtab_writable == 1;
-}
-
int mnt_context_utab_writable(struct libmnt_context *cxt)
{
assert(cxt);
assert(cxt);
context_init_paths(cxt, 1);
- return cxt->mtab_writable ? cxt->mtab_path : cxt->utab_path;
+ return cxt->utab_path;
}
* @cxt: mount context
* @mode: MNT_OMODE_* flags
*
- * Controls how to use mount optionssource and target paths from fstab/mtab.
+ * Controls how to use mount optionssource and target paths from fstab/mountinfo.
*
- * @MNT_OMODE_IGNORE: ignore mtab/fstab options
+ * @MNT_OMODE_IGNORE: ignore fstab options
*
- * @MNT_OMODE_APPEND: append mtab/fstab options to existing options
+ * @MNT_OMODE_APPEND: append fstab options to existing options
*
- * @MNT_OMODE_PREPEND: prepend mtab/fstab options to existing options
+ * @MNT_OMODE_PREPEND: prepend fstab options to existing options
*
- * @MNT_OMODE_REPLACE: replace existing options with options from mtab/fstab
+ * @MNT_OMODE_REPLACE: replace existing options with options from fstab
*
- * @MNT_OMODE_FORCE: always read mtab/fstab (although source and target are defined)
+ * @MNT_OMODE_FORCE: always read fstab (although source and target are defined)
*
* @MNT_OMODE_FSTAB: read from fstab
*
- * @MNT_OMODE_MTAB: read from mtab if fstab not enabled or failed
+ * @MNT_OMODE_MTAB: read from mountinfo if fstab not enabled or failed
*
- * @MNT_OMODE_NOTAB: do not read fstab/mtab at all
+ * @MNT_OMODE_NOTAB: do not read fstab/mountinfoat all
*
* @MNT_OMODE_AUTO: default mode (MNT_OMODE_PREPEND | MNT_OMODE_FSTAB | MNT_OMODE_MTAB)
*
* - MNT_OMODE_USER is always used if mount context is in restricted mode
* - MNT_OMODE_AUTO is used if nothing else is defined
* - the flags are evaluated in this order: MNT_OMODE_NOTAB, MNT_OMODE_FORCE,
- * MNT_OMODE_FSTAB, MNT_OMODE_MTAB and then the mount options from fstab/mtab
+ * MNT_OMODE_FSTAB, MNT_OMODE_MTAB and then the mount options from fstab/mountinfo
* are set according to MNT_OMODE_{IGNORE,APPEND,PREPEND,REPLACE}
*
* Returns: 0 on success, negative number in case of error.
* @cxt: mount context
* @disable: TRUE or FALSE
*
- * Disable/enable mtab update (see mount(8) man page, option -n).
+ * Disable/enable userspace mount table update (see mount(8) man page,
+ * option -n). Originally /etc/mtab, now /run/mount/utab.
*
* Returns: 0 on success, negative number in case of error.
*/
* mnt_context_get_mtab_userdata:
* @cxt: mount context
*
+ * The file /etc/mtab is no more used, @context points always to mountinfo
+ * (/proc/self/mountinfo). The function uses "mtab" in the name for backward
+ * compatibility only.
+ *
* Returns: pointer to userdata or NULL.
*/
void *mnt_context_get_mtab_userdata(struct libmnt_context *cxt)
{
- return cxt->mtab ? mnt_table_get_userdata(cxt->mtab) : NULL;
+ return cxt->mountinfo ? mnt_table_get_userdata(cxt->mountinfo) : NULL;
}
/**
return 0;
}
-/**
- * mnt_context_get_mtab:
- * @cxt: mount context
- * @tb: returns mtab
- *
- * See also mnt_table_parse_mtab() for more details about mtab/mountinfo. The
- * result will be deallocated by mnt_free_context(@cxt).
- *
- * Returns: 0 on success, negative number in case of error.
- */
-int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
+int mnt_context_get_mountinfo(struct libmnt_context *cxt, struct libmnt_table **tb)
{
int rc = 0;
struct libmnt_ns *ns_old = NULL;
if (!cxt)
return -EINVAL;
- if (!cxt->mtab) {
+ if (!cxt->mountinfo) {
ns_old = mnt_context_switch_target_ns(cxt);
if (!ns_old)
return -MNT_ERR_NAMESPACE;
context_init_paths(cxt, 0);
- cxt->mtab = mnt_new_table();
- if (!cxt->mtab) {
+ cxt->mountinfo = mnt_new_table();
+ if (!cxt->mountinfo) {
rc = -ENOMEM;
goto end;
}
if (cxt->table_errcb)
- mnt_table_set_parser_errcb(cxt->mtab, cxt->table_errcb);
+ mnt_table_set_parser_errcb(cxt->mountinfo, cxt->table_errcb);
if (cxt->table_fltrcb)
- mnt_table_set_parser_fltrcb(cxt->mtab,
+ mnt_table_set_parser_fltrcb(cxt->mountinfo,
cxt->table_fltrcb,
cxt->table_fltrcb_data);
- mnt_table_set_cache(cxt->mtab, mnt_context_get_cache(cxt));
+ mnt_table_set_cache(cxt->mountinfo, mnt_context_get_cache(cxt));
}
- /* Read the table; it's empty, because this first mnt_context_get_mtab()
+ /* Read the table; it's empty, because this first mnt_context_get_mountinfo()
* call, or because /proc was not accessible in previous calls */
- if (mnt_table_is_empty(cxt->mtab)) {
+ if (mnt_table_is_empty(cxt->mountinfo)) {
if (!ns_old) {
ns_old = mnt_context_switch_target_ns(cxt);
if (!ns_old)
return -MNT_ERR_NAMESPACE;
}
- /*
- * Note that mtab_path is NULL if mtab is useless or unsupported
- */
- if (cxt->utab)
- /* utab already parsed, don't parse it again */
- rc = __mnt_table_parse_mtab(cxt->mtab,
- cxt->mtab_path, cxt->utab);
- else
- rc = mnt_table_parse_mtab(cxt->mtab, cxt->mtab_path);
+ rc = __mnt_table_parse_mountinfo(cxt->mountinfo, NULL, cxt->utab);
if (rc)
goto end;
}
if (tb)
- *tb = cxt->mtab;
+ *tb = cxt->mountinfo;
- DBG(CXT, ul_debugobj(cxt, "mtab requested [nents=%d]",
- mnt_table_get_nents(cxt->mtab)));
+ DBG(CXT, ul_debugobj(cxt, "mountinfo requested [nents=%d]",
+ mnt_table_get_nents(cxt->mountinfo)));
end:
if (ns_old && !mnt_context_switch_ns(cxt, ns_old))
return rc;
}
+/**
+ * mnt_context_get_mtab:
+ * @cxt: mount context
+ * @tb: returns mtab
+ *
+ * Parse /proc/self/mountinfo mount table.
+ *
+ * The file /etc/mtab is no more used, @context points always to mountinfo
+ * (/proc/self/mountinfo). The function uses "mtab" in the name for backward
+ * compatibility only.
+ *
+ * See also mnt_table_parse_mtab() for more details about mountinfo. The
+ * result will be deallocated by mnt_free_context(@cxt).
+ *
+ * Returns: 0 on success, negative number in case of error.
+ */
+int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
+{
+ return mnt_context_get_mountinfo(cxt, tb);
+}
+
/*
- * Called by mtab parser to filter out entries, non-zero means that
+ * Called by mountinfo parser to filter out entries, non-zero means that
* an entry has to be filtered out.
*/
-static int mtab_filter(struct libmnt_fs *fs, void *data)
+static int mountinfo_filter(struct libmnt_fs *fs, void *data)
{
if (!fs || !data)
return 0;
}
/*
- * The same like mnt_context_get_mtab(), but does not read all mountinfo/mtab
+ * The same like mnt_context_get_mountinfo(), but does not read all mountinfo
* file, but only entries relevant for @tgt.
*/
-int mnt_context_get_mtab_for_target(struct libmnt_context *cxt,
- struct libmnt_table **mtab,
+int mnt_context_get_mountinfo_for_target(struct libmnt_context *cxt,
+ struct libmnt_table **mountinfo,
const char *tgt)
{
struct stat st;
return -MNT_ERR_NAMESPACE;
if (mnt_context_is_nocanonicalize(cxt))
- mnt_context_set_tabfilter(cxt, mtab_filter, (void *) tgt);
+ mnt_context_set_tabfilter(cxt, mountinfo_filter, (void *) tgt);
else if (mnt_stat_mountpoint(tgt, &st) == 0 && S_ISDIR(st.st_mode)) {
cache = mnt_context_get_cache(cxt);
cn_tgt = mnt_resolve_path(tgt, cache);
if (cn_tgt)
- mnt_context_set_tabfilter(cxt, mtab_filter, cn_tgt);
+ mnt_context_set_tabfilter(cxt, mountinfo_filter, cn_tgt);
}
- rc = mnt_context_get_mtab(cxt, mtab);
+ rc = mnt_context_get_mountinfo(cxt, mountinfo);
mnt_context_set_tabfilter(cxt, NULL, NULL);
if (!mnt_context_switch_ns(cxt, ns_old))
/*
* Allows to specify a filter for tab file entries. The filter is called by
- * the table parser. Currently used for mtab and utab only.
+ * the table parser. Currently used for utab only.
*/
int mnt_context_set_tabfilter(struct libmnt_context *cxt,
int (*fltr)(struct libmnt_fs *, void *),
cxt->table_fltrcb = fltr;
cxt->table_fltrcb_data = data;
- if (cxt->mtab)
- mnt_table_set_parser_fltrcb(cxt->mtab,
+ if (cxt->mountinfo)
+ mnt_table_set_parser_fltrcb(cxt->mountinfo,
cxt->table_fltrcb,
cxt->table_fltrcb_data);
* See also mnt_table_parse_file().
*
* It's strongly recommended to use the mnt_context_get_mtab() and
- * mnt_context_get_fstab() functions for mtab and fstab files. This function
+ * mnt_context_get_fstab() functions for mountinfo and fstab files. This function
* does not care about LIBMOUNT_* env.variables and does not merge userspace
* options.
*
* @cxt: mount context
* @cb: pointer to callback function
*
- * The error callback is used for all tab files (e.g. mtab, fstab)
+ * The error callback is used for all tab files (e.g. mountinfo, fstab)
* parsed within the context.
*
* See also mnt_context_get_mtab(),
if (!cxt)
return -EINVAL;
- if (cxt->mtab)
- mnt_table_set_parser_errcb(cxt->mtab, cb);
+ if (cxt->mountinfo)
+ mnt_table_set_parser_errcb(cxt->mountinfo, cb);
if (cxt->fstab)
mnt_table_set_parser_errcb(cxt->fstab, cb);
* This function increments cache reference counter.
*
* If the @cache argument is NULL, then the current cache instance is reset.
- * This function apply the cache to fstab and mtab instances (if already
+ * This function apply the cache to fstab and mountinfo instances (if already
* exists).
*
* The old cache instance reference counter is de-incremented.
cxt->cache = cache;
- if (cxt->mtab)
- mnt_table_set_cache(cxt->mtab, cache);
+ if (cxt->mountinfo)
+ mnt_table_set_cache(cxt->mountinfo, cache);
if (cxt->fstab)
mnt_table_set_cache(cxt->fstab, cache);
* mnt_context_get_lock:
* @cxt: mount context
*
- * The libmount applications don't have to care about mtab locking, but with a
+ * The libmount applications don't have to care about utab locking, but with a
* small exception: the application has to be able to remove the lock file when
* interrupted by signal or signals have to be ignored when the lock is locked.
*
* The default behavior is to ignore all signals (except SIGALRM and
- * SIGTRAP for mtab update) when the lock is locked. If this behavior
+ * SIGTRAP for utab update) when the lock is locked. If this behavior
* is unacceptable, then use:
*
* lc = mnt_context_get_lock(cxt);
/*
* DON'T call this function within libmount, it will always allocate
* the lock. The mnt_update_* functions are able to allocate the lock
- * only when mtab/utab update is really necessary.
+ * only when utab update is really necessary.
*/
if (!cxt || mnt_context_is_nomtab(cxt))
return NULL;
}
/*
- * Prepare /etc/mtab or /run/mount/utab
+ * Prepare /run/mount/utab
*/
int mnt_context_prepare_update(struct libmnt_context *cxt)
{
if (!cxt->update)
return -ENOMEM;
- mnt_update_set_filename(cxt->update, name,
- !mnt_context_mtab_writable(cxt));
+ mnt_update_set_filename(cxt->update, name);
}
if (cxt->action == MNT_ACT_UMOUNT)
rc = apply_table(cxt, tab, MNT_ITER_FORWARD, mflags);
}
- /* try mtab */
+ /* try mountinfo */
if (rc < 0 && (cxt->optsmode & MNT_OMODE_MTAB)
&& (isremount || cxt->action == MNT_ACT_UMOUNT)) {
- DBG(CXT, ul_debugobj(cxt, "trying to apply mtab (src=%s, target=%s)", src, tgt));
+ DBG(CXT, ul_debugobj(cxt, "trying to apply mountinfo (src=%s, target=%s)", src, tgt));
if (tgt)
- rc = mnt_context_get_mtab_for_target(cxt, &tab, tgt);
+ rc = mnt_context_get_mountinfo_for_target(cxt, &tab, tgt);
else
- rc = mnt_context_get_mtab(cxt, &tab);
+ rc = mnt_context_get_mountinfo(cxt, &tab);
if (!rc)
rc = apply_table(cxt, tab, MNT_ITER_BACKWARD, mflags);
}
if (!mnt_context_is_restricted(cxt)
&& tgt && !src
&& isremount) {
- DBG(CXT, ul_debugobj(cxt, "only target; ignore missing mtab entry on remount"));
+ DBG(CXT, ul_debugobj(cxt, "only target; ignore missing mountinfo entry on remount"));
return 0;
}
- DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mtab [rc=%d]: %m", rc));
+ DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mountinfo [rc=%d]: %m", rc));
- /* force to "not found in fstab/mtab" error, the details why
+ /* force to "not found in fstab/mountinfo" error, the details why
* not found are not so important and may be misinterpreted by
* applications... */
rc = -MNT_ERR_NOFSTAB;
* mnt_context_tab_applied:
* @cxt: mount context
*
- * Returns: 1 if fstab (or mtab) has been applied to the context, or 0.
+ * Returns: 1 if fstab (or mountinfo) has been applied to the context, or 0.
*/
int mnt_context_tab_applied(struct libmnt_context *cxt)
{
int mnt_context_is_fs_mounted(struct libmnt_context *cxt,
struct libmnt_fs *fs, int *mounted)
{
- struct libmnt_table *mtab, *orig;
+ struct libmnt_table *mountinfo, *orig;
int rc = 0;
struct libmnt_ns *ns_old;
if (!ns_old)
return -MNT_ERR_NAMESPACE;
- orig = cxt->mtab;
- rc = mnt_context_get_mtab(cxt, &mtab);
- if (rc == -ENOENT && mnt_fs_streq_target(fs, "/proc") &&
- (!cxt->mtab_path || startswith(cxt->mtab_path, "/proc/"))) {
+ orig = cxt->mountinfo;
+ rc = mnt_context_get_mountinfo(cxt, &mountinfo);
+ if (rc == -ENOENT && mnt_fs_streq_target(fs, "/proc")) {
if (!orig) {
- mnt_unref_table(cxt->mtab);
- cxt->mtab = NULL;
+ mnt_unref_table(cxt->mountinfo);
+ cxt->mountinfo = NULL;
}
*mounted = 0;
rc = 0; /* /proc not mounted */
} else if (rc == 0) {
- *mounted = __mnt_table_is_fs_mounted(mtab, fs,
+ *mounted = __mnt_table_is_fs_mounted(mountinfo, fs,
mnt_context_get_target_prefix(cxt));
}
assert(cxt->fs);
assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
- if (mnt_context_get_mtab(cxt, &tb))
+ if (mnt_context_get_mountinfo(cxt, &tb))
return 0;
ns_old = mnt_context_switch_target_ns(cxt);
bf = cache ? mnt_resolve_path(backing_file, cache) : backing_file;
- /* Search for a mountpoint node in mtab, proceed if any of these have the
+ /* Search for a mountpoint node in mountinfo, proceed if any of these have the
* loop option set or the device is a loop device
*/
while (rc == 0 && mnt_table_next_fs(tb, &itr, &fs) == 0) {
if (rc)
goto done;
- /* since 2.6.37 we don't have to store backing filename to mtab
+ /* since 2.6.37 we don't have to store backing filename to mountinfo
* because kernel provides the name in /sys.
*/
- if (get_linux_version() >= KERNEL_VERSION(2, 6, 37) ||
- !mnt_context_mtab_writable(cxt)) {
+ if (get_linux_version() >= KERNEL_VERSION(2, 6, 37)) {
DBG(LOOP, ul_debugobj(cxt, "enabling AUTOCLEAR flag"));
lo_flags |= LO_FLAGS_AUTOCLEAR;
}
loopcxt_is_autoclear(&lc))) {
/*
* autoclear flag accepted by the kernel, don't store
- * the "loop=" option to mtab.
+ * the "loop=" option to utab.
*/
- DBG(LOOP, ul_debugobj(cxt, "removing unnecessary loop= from mtab"));
+ DBG(LOOP, ul_debugobj(cxt, "removing unnecessary loop= from utab"));
cxt->user_mountflags &= ~MNT_MS_LOOP;
mnt_optstr_remove_option(&cxt->fs->user_optstr, "loop");
}
src = mnt_fs_get_srcpath(cxt->fs);
- if (src && mnt_context_get_mtab(cxt, &tb) == 0) {
+ if (src && mnt_context_get_mountinfo(cxt, &tb) == 0) {
struct libmnt_iter itr;
struct libmnt_fs *fs;
int *mntrc,
int *ignored)
{
- struct libmnt_table *fstab, *mtab;
+ struct libmnt_table *fstab, *mountinfo;
const char *o, *tgt;
int rc, mounted = 0;
/* ignore already mounted filesystems */
rc = mnt_context_is_fs_mounted(cxt, *fs, &mounted);
if (rc) {
- if (mnt_table_is_empty(cxt->mtab)) {
+ if (mnt_table_is_empty(cxt->mountinfo)) {
DBG(CXT, ul_debugobj(cxt, "next-mount: no mount table [rc=%d], ignore", rc));
rc = 0;
if (ignored)
mnt_context_save_template(cxt);
}
- /* reset context, but protect mtab */
- mtab = cxt->mtab;
- cxt->mtab = NULL;
+ /* reset context, but protect mountinfo */
+ mountinfo = cxt->mountinfo;
+ cxt->mountinfo = NULL;
mnt_reset_context(cxt);
- cxt->mtab = mtab;
+ cxt->mountinfo = mountinfo;
if (mnt_context_is_fork(cxt)) {
rc = mnt_fork_context(cxt);
int *mntrc,
int *ignored)
{
- struct libmnt_table *mtab;
+ struct libmnt_table *mountinfo;
const char *tgt;
int rc;
if (!cxt || !fs || !itr)
return -EINVAL;
- rc = mnt_context_get_mtab(cxt, &mtab);
+ rc = mnt_context_get_mountinfo(cxt, &mountinfo);
if (rc)
return rc;
- rc = mnt_table_next_fs(mtab, itr, fs);
+ rc = mnt_table_next_fs(mountinfo, itr, fs);
if (rc != 0)
return rc; /* more filesystems (or error) */
mnt_context_save_template(cxt);
}
- /* restore original, but protect mtab */
- cxt->mtab = NULL;
+ /* restore original, but protect mountinfo */
+ cxt->mountinfo = NULL;
mnt_reset_context(cxt);
- cxt->mtab = mtab;
+ cxt->mountinfo = mountinfo;
rc = mnt_context_set_target(cxt, tgt);
if (!rc) {
if (!dir)
return 0;
- if (mnt_context_get_mtab(cxt, &tb) || !tb)
+ if (mnt_context_get_mountinfo(cxt, &tb) || !tb)
goto done;
mnt = strdup(dir);
} else if (mnt_context_get_syscall_errno(cxt) == 0) {
/*
* mount(2) syscall success, but something else failed
- * (probably error in mtab processing).
+ * (probably error in utab processing).
*/
if (rc == -MNT_ERR_LOCK) {
if (buf)
# define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */
#endif
-/* search in mountinfo/mtab */
-static int __mtab_find_umount_fs(struct libmnt_context *cxt,
+/* search in mountinfo */
+static int __mountinfo_find_umount_fs(struct libmnt_context *cxt,
const char *tgt,
struct libmnt_fs **pfs)
{
int rc;
struct libmnt_ns *ns_old;
- struct libmnt_table *mtab = NULL;
+ struct libmnt_table *mountinfo = NULL;
struct libmnt_fs *fs;
char *loopdev = NULL;
*
* The filter uses mnt_fs_streq_{target,srcpath} function where all
* paths should be absolute and canonicalized. This is done within
- * mnt_context_get_mtab_for_target() where LABEL, UUID or symlinks are
+ * mnt_context_get_mountinfo_for_target() where LABEL, UUID or symlinks are
* canonicalized. If --no-canonicalize is enabled than the target path
* is expected already canonical.
*
* Anyway it's better to read huge mount table than canonicalize target
* paths. It means we use the filter only if --no-canonicalize enabled.
*
- * It also means that we have to read mount table from kernel
- * (non-writable mtab).
+ * It also means that we have to read mount table from kernel.
*/
- if (mnt_context_is_nocanonicalize(cxt) &&
- !mnt_context_mtab_writable(cxt) && *tgt == '/')
- rc = mnt_context_get_mtab_for_target(cxt, &mtab, tgt);
+ if (mnt_context_is_nocanonicalize(cxt) && *tgt == '/')
+ rc = mnt_context_get_mountinfo_for_target(cxt, &mountinfo, tgt);
else
- rc = mnt_context_get_mtab(cxt, &mtab);
+ rc = mnt_context_get_mountinfo(cxt, &mountinfo);
if (rc) {
- DBG(CXT, ul_debugobj(cxt, "umount: failed to read mtab"));
+ DBG(CXT, ul_debugobj(cxt, "umount: failed to read mountinfo"));
return rc;
}
- if (mnt_table_get_nents(mtab) == 0) {
- DBG(CXT, ul_debugobj(cxt, "umount: mtab empty"));
+ if (mnt_table_get_nents(mountinfo) == 0) {
+ DBG(CXT, ul_debugobj(cxt, "umount: mountinfo empty"));
return 1;
}
return -MNT_ERR_NAMESPACE;
try_loopdev:
- fs = mnt_table_find_target(mtab, tgt, MNT_ITER_BACKWARD);
+ fs = mnt_table_find_target(mountinfo, tgt, MNT_ITER_BACKWARD);
if (!fs && mnt_context_is_swapmatch(cxt)) {
/*
* Maybe the option is source rather than target (sometimes
* people use e.g. "umount /dev/sda1")
*/
- fs = mnt_table_find_source(mtab, tgt, MNT_ITER_BACKWARD);
+ fs = mnt_table_find_source(mountinfo, tgt, MNT_ITER_BACKWARD);
if (fs) {
- struct libmnt_fs *fs1 = mnt_table_find_target(mtab,
+ struct libmnt_fs *fs1 = mnt_table_find_target(mountinfo,
mnt_fs_get_target(fs),
MNT_ITER_BACKWARD);
if (!fs1) {
- DBG(CXT, ul_debugobj(cxt, "mtab is broken?!?!"));
+ DBG(CXT, ul_debugobj(cxt, "mountinfo is broken?!?!"));
rc = -EINVAL;
goto err;
}
/* In future this function should be extended to support for example
* fsinfo() (or another cheap way kernel will support), for now the
- * default is expensive mountinfo/mtab.
+ * default is expensive mountinfo.
*/
- return __mtab_find_umount_fs(cxt, tgt, pfs);
+ return __mountinfo_find_umount_fs(cxt, tgt, pfs);
}
/* Check if there is something important in the utab file. The parsed utab is
* stored in context->utab and deallocated by mnt_free_context().
*
* This function exists to avoid (if possible) /proc/self/mountinfo usage, so
- * don't use things like mnt_resolve_target(), mnt_context_get_mtab() etc here.
+ * don't use things like mnt_resolve_target(), mnt_context_get_mountinfo() etc here.
* See lookup_umount_fs() for more details.
*/
static int has_utab_entry(struct libmnt_context *cxt, const char *target)
if (mnt_context_is_restricted(cxt)
|| *tgt != '/'
|| (cxt->flags & MNT_FL_HELPER)
- || mnt_context_mtab_writable(cxt)
|| mnt_context_is_force(cxt)
|| mnt_context_is_lazy(cxt)
|| mnt_context_is_nocanonicalize(cxt)
}
}
if (type) {
- DBG(CXT, ul_debugobj(cxt, " umount: disabling mtab"));
+ DBG(CXT, ul_debugobj(cxt, " umount: disabling mountinfo"));
mnt_context_disable_mtab(cxt, TRUE);
DBG(CXT, ul_debugobj(cxt,
DBG(CXT, ul_debugobj(cxt, " lookup by mountinfo"));
/* search */
- rc = __mtab_find_umount_fs(cxt, tgt, &fs);
+ rc = __mountinfo_find_umount_fs(cxt, tgt, &fs);
if (rc != 0)
return rc;
DBG(CXT, ul_debugobj(cxt, " failed to copy FS"));
return -errno;
}
- DBG(CXT, ul_debugobj(cxt, " mtab applied"));
+ DBG(CXT, ul_debugobj(cxt, " mountinfo applied"));
}
cxt->flags |= MNT_FL_TAB_APPLIED;
}
/*
- * Note that cxt->fs contains relevant mtab entry!
+ * Note that cxt->fs contains relevant mountinfo entry!
*/
static int evaluate_permissions(struct libmnt_context *cxt)
{
if (!mnt_context_tab_applied(cxt)) {
DBG(CXT, ul_debugobj(cxt,
- "cannot find %s in mtab and you are not root",
+ "cannot find %s in mountinfo and you are not root",
mnt_fs_get_target(cxt->fs)));
goto eperm;
}
if (!fs) {
/*
* It's possible that there is /path/file.img in fstab and
- * /dev/loop0 in mtab -- then we have to check the relation
+ * /dev/loop0 in mountinfo -- then we have to check the relation
* between loopdev and the file.
*/
fs = mnt_table_find_target(fstab, tgt, MNT_ITER_FORWARD);
if (fs) {
struct libmnt_cache *cache = mnt_context_get_cache(cxt);
- const char *sp = mnt_fs_get_srcpath(cxt->fs); /* devname from mtab */
+ const char *sp = mnt_fs_get_srcpath(cxt->fs); /* devname from mountinfo */
const char *dev = sp && cache ? mnt_resolve_path(sp, cache) : sp;
if (!dev || !is_associated_fs(dev, fs))
}
if (!fs) {
DBG(CXT, ul_debugobj(cxt,
- "umount %s: mtab disagrees with fstab",
+ "umount %s: mountinfo disagrees with fstab",
tgt));
goto eperm;
}
* this may be a security risk.
*
* The options `user', `owner' and `group' only allow unmounting by the
- * user that mounted (visible in mtab).
+ * user that mounted (visible in mountinfo).
*/
optstr = mnt_fs_get_user_options(fs); /* FSTAB mount options! */
if (!optstr)
return 0;
}
/*
- * Check user=<username> setting from mtab if there is a user, owner or
+ * Check user=<username> setting from utab if there is a user, owner or
* group option in /etc/fstab
*/
if (u_flags & (MNT_MS_USER | MNT_MS_OWNER | MNT_MS_GROUP)) {
char *curr_user;
- char *mtab_user = NULL;
+ char *utab_user = NULL;
size_t sz;
struct libmnt_ns *ns_old;
DBG(CXT, ul_debugobj(cxt,
- "umount: checking user=<username> from mtab"));
+ "umount: checking user=<username> from mountinfo"));
ns_old = mnt_context_switch_origin_ns(cxt);
if (!ns_old)
goto eperm;
}
- /* get options from mtab */
+ /* get options from utab */
optstr = mnt_fs_get_user_options(cxt->fs);
if (optstr && !mnt_optstr_get_option(optstr,
- "user", &mtab_user, &sz) && sz)
- ok = !strncmp(curr_user, mtab_user, sz);
+ "user", &utab_user, &sz) && sz)
+ ok = !strncmp(curr_user, utab_user, sz);
free(curr_user);
}
}
if (!rc && (cxt->user_mountflags & MNT_MS_LOOP))
- /* loop option explicitly specified in mtab, detach this loop */
+ /* loop option explicitly specified in utab, detach this loop */
mnt_context_enable_loopdel(cxt, TRUE);
if (!rc && mnt_context_is_loopdel(cxt) && cxt->fs) {
/*
* Umounted, do some post-umount operations
* - remove loopdev
- * - refresh in-memory mtab stuff if remount rather than
+ * - refresh in-memory utab stuff if remount rather than
* umount has been performed
*/
if (mnt_context_is_loopdel(cxt)
&& !(cxt->mountflags & MS_REMOUNT))
rc = mnt_context_delete_loopdev(cxt);
-
- if (!mnt_context_is_nomtab(cxt)
- && mnt_context_get_status(cxt)
- && !cxt->helper
- && mnt_context_is_rdonly_umount(cxt)
- && (cxt->mountflags & MS_REMOUNT)) {
-
- /* use "remount" instead of "umount" in /etc/mtab */
- if (!rc && cxt->update && mnt_context_mtab_writable(cxt))
- rc = mnt_update_set_fs(cxt->update,
- cxt->mountflags, NULL, cxt->fs);
- }
}
end:
if (!mnt_context_switch_ns(cxt, ns_old))
* @mntrc: returns the return code from mnt_context_umount()
* @ignored: returns 1 for not matching
*
- * This function tries to umount the next filesystem from mtab (as returned by
- * mnt_context_get_mtab()).
+ * This function tries to umount the next filesystem from mountinfo file.
*
* You can filter out filesystems by:
* mnt_context_set_options_pattern() to simulate umount -a -O pattern
int *mntrc,
int *ignored)
{
- struct libmnt_table *mtab;
+ struct libmnt_table *mountinfo;
const char *tgt;
int rc;
if (!cxt || !fs || !itr)
return -EINVAL;
- rc = mnt_context_get_mtab(cxt, &mtab);
- cxt->mtab = NULL; /* do not reset mtab */
+ rc = mnt_context_get_mountinfo(cxt, &mountinfo);
+ cxt->mountinfo = NULL; /* do not reset mountinfo */
mnt_reset_context(cxt);
if (rc)
return rc;
- cxt->mtab = mtab;
+ cxt->mountinfo = mountinfo;
do {
- rc = mnt_table_next_fs(mtab, itr, fs);
+ rc = mnt_table_next_fs(mountinfo, itr, fs);
if (rc != 0)
return rc; /* no more filesystems (or error) */
*/
if (rc == -EPERM && !mnt_context_tab_applied(cxt)) {
/* failed to evaluate permissions because not found
- * relevant entry in mtab */
+ * relevant entry in mountinfo */
if (buf)
snprintf(buf, bufsz, _("not mounted"));
return MNT_EX_USAGE;
} if (mnt_context_get_syscall_errno(cxt) == 0) {
/*
* umount(2) syscall success, but something else failed
- * (probably error in mtab processing).
+ * (probably error in utab processing).
*/
if (rc == -MNT_ERR_LOCK) {
if (buf)
/**
* SECTION: fs
* @title: Filesystem
- * @short_description: represents one entry from fstab, mtab, or mountinfo file
+ * @short_description: represents one entry from fstab, or mountinfo file
*
*/
#include <ctype.h>
/**
* libmnt_lock:
*
- * Stores information about the locked file (e.g. /etc/mtab)
+ * Stores information about the locked file
*/
struct libmnt_lock;
/**
* libmnt_fs:
*
- * Parsed fstab/mtab/mountinfo entry
+ * Parsed fstab or mountinfo entry
*/
struct libmnt_fs;
/**
* libmnt_table:
*
- * List of struct libmnt_fs entries (parsed fstab/mtab/mountinfo)
+ * List of struct libmnt_fs entries (parsed fstab or mountinfo)
*/
struct libmnt_table;
/**
* libmnt_update
*
- * /etc/mtab or utab update description
+ * utab update description
*/
struct libmnt_update;
/**
* MNT_ERR_LOCK:
*
- * failed to lock mtab/utab or so.
+ * failed to lock utab or so.
*/
#define MNT_ERR_LOCK 5008
/**
/**
* MNT_EX_FILEIO:
*
- * [u]mount(8) exit code: problems writing, locking, ... mtab/utab
+ * [u]mount(8) exit code: problems writing, locking, ... utab
*/
#define MNT_EX_FILEIO 16
extern void mnt_unref_cache(struct libmnt_cache *cache);
extern int mnt_cache_set_targets(struct libmnt_cache *cache,
- struct libmnt_table *mtab);
+ struct libmnt_table *mountinfo);
extern int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname);
extern int mnt_cache_device_has_tag(struct libmnt_cache *cache,
/* context.c */
/*
- * Mode for mount options from fstab (or mtab), see mnt_context_set_optsmode().
+ * Mode for mount options from fstab), see mnt_context_set_optsmode().
*/
enum {
- MNT_OMODE_IGNORE = (1 << 1), /* ignore mtab/fstab options */
- MNT_OMODE_APPEND = (1 << 2), /* append mtab/fstab options to existing options */
- MNT_OMODE_PREPEND = (1 << 3), /* prepend mtab/fstab options to existing options */
+ MNT_OMODE_IGNORE = (1 << 1), /* ignore fstab options */
+ MNT_OMODE_APPEND = (1 << 2), /* append fstab options to existing options */
+ MNT_OMODE_PREPEND = (1 << 3), /* prepend fstab options to existing options */
MNT_OMODE_REPLACE = (1 << 4), /* replace existing options with options from mtab/fstab */
- MNT_OMODE_FORCE = (1 << 5), /* always read mtab/fstab options */
+ MNT_OMODE_FORCE = (1 << 5), /* always read fstab options */
MNT_OMODE_FSTAB = (1 << 10), /* read from fstab */
- MNT_OMODE_MTAB = (1 << 11), /* read from mtab if fstab not enabled or failed */
- MNT_OMODE_NOTAB = (1 << 12), /* do not read fstab/mtab at all */
+ MNT_OMODE_MTAB = (1 << 11), /* read from mountinfo if fstab not enabled or failed */
+ MNT_OMODE_NOTAB = (1 << 12), /* do not read fstab at all */
/* default */
MNT_OMODE_AUTO = (MNT_OMODE_PREPEND | MNT_OMODE_FSTAB | MNT_OMODE_MTAB),
MOUNT_2_39 {
mnt_context_enable_onlyonce;
mnt_context_is_lazy;
+ mnt_context_get_mountinfo_userdata;
} MOUNT_2_38;
int (*cb)(struct libmnt_fs *, void *),
void *data);
-extern int __mnt_table_parse_mtab(struct libmnt_table *tb,
+extern int __mnt_table_parse_mountinfo(struct libmnt_table *tb,
const char *filename,
struct libmnt_table *u_tb);
/*
- * This struct represents one entry in a mtab/fstab/mountinfo file.
+ * This struct represents one entry in a fstab/mountinfo file.
* (note that fstab[1] means the first column from fstab, and so on...)
*/
struct libmnt_fs {
#define MNT_FS_MERGED (1 << 5) /* already merged data from /run/mount/utab */
/*
- * mtab/fstab/mountinfo file
+ * fstab/mountinfo file
*/
struct libmnt_table {
int fmt; /* MNT_FMT_* file format */
struct libmnt_fs *fs; /* filesystem description (type, mountpoint, device, ...) */
struct libmnt_fs *fs_template; /* used for @fs on mnt_reset_context() */
- struct libmnt_table *fstab; /* fstab (or mtab for some remounts) entries */
- struct libmnt_table *mtab; /* mtab entries */
+ struct libmnt_table *fstab; /* fstab entries */
+ struct libmnt_table *mountinfo; /* already mounted filesystems */
struct libmnt_table *utab; /* rarely used by umount only */
int (*table_errcb)(struct libmnt_table *tb, /* callback for libmnt_table structs */
struct list_head addmounts; /* additional mounts */
struct libmnt_cache *cache; /* paths cache */
- struct libmnt_lock *lock; /* mtab lock */
- struct libmnt_update *update;/* mtab/utab update */
+ struct libmnt_lock *lock; /* utab lock */
+ struct libmnt_update *update;/* utab update */
- const char *mtab_path; /* path to mtab */
- int mtab_writable; /* is mtab writable */
+ const char *mountinfo_path; /* usualy /proc/self/moutinfo */
const char *utab_path; /* path to utab */
int utab_writable; /* is utab writable */
#define MNT_FL_ONLYONCE (1 << 15)
#define MNT_FL_MOUNTDATA (1 << 20)
-#define MNT_FL_TAB_APPLIED (1 << 21) /* mtab/fstab merged to cxt->fs */
+#define MNT_FL_TAB_APPLIED (1 << 21) /* fstab merged to cxt->fs */
#define MNT_FL_MOUNTFLAGS_MERGED (1 << 22) /* MS_* flags was read from optstr */
#define MNT_FL_SAVED_USER (1 << 23)
#define MNT_FL_PREPARED (1 << 24)
extern int mnt_optstr_fix_user(char **optstr);
/* fs.c */
-extern struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs)
- __attribute__((nonnull));
+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)
__attribute__((nonnull(1)));
extern int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype)
/* context.c */
extern struct libmnt_context *mnt_copy_context(struct libmnt_context *o);
-extern int mnt_context_mtab_writable(struct libmnt_context *cxt);
extern int mnt_context_utab_writable(struct libmnt_context *cxt);
extern const char *mnt_context_get_writable_tabpath(struct libmnt_context *cxt);
-extern int mnt_context_get_mtab_for_target(struct libmnt_context *cxt,
- struct libmnt_table **mtab, const char *tgt);
+extern int mnt_context_get_mountinfo(struct libmnt_context *cxt, struct libmnt_table **tb);
+extern int mnt_context_get_mountinfo_for_target(struct libmnt_context *cxt,
+ struct libmnt_table **mountinfo, const char *tgt);
extern int mnt_context_prepare_srcpath(struct libmnt_context *cxt);
extern int mnt_context_prepare_target(struct libmnt_context *cxt);
extern int mnt_context_deferred_delete_veritydev(struct libmnt_context *cxt);
/* tab_update.c */
-extern int mnt_update_set_filename(struct libmnt_update *upd,
- const char *filename, int userspace_only);
+extern int mnt_update_set_filename(struct libmnt_update *upd, const char *filename);
extern int mnt_update_already_done(struct libmnt_update *upd,
struct libmnt_lock *lc);
struct libmnt_fs *fs;
struct libmnt_iter *itr = NULL;
struct libmnt_cache *mpc = NULL;
- int writable = 0;
- const char *path = NULL;
-
- if (mnt_has_regular_mtab(&path, &writable) == 1 && writable == 0)
- tb = mnt_new_table_from_file(path);
- else
- tb = mnt_new_table_from_file("/proc/self/mountinfo");
+ tb = mnt_new_table_from_file("/proc/self/mountinfo");
if (!tb) {
fprintf(stderr, "failed to parse mountinfo\n");
return -1;
#include "strutils.h"
struct libmnt_parser {
- FILE *f; /* fstab, mtab, swaps or mountinfo ... */
+ FILE *f; /* fstab, swaps or mountinfo ... */
const char *filename; /* file name or NULL */
char *buf; /* buffer (the current line content) */
size_t bufsiz; /* size of the buffer */
if (strncmp(line, "Filename\t", 9) == 0)
return MNT_FMT_SWAPS;
- return MNT_FMT_FSTAB; /* fstab, mtab or /proc/mounts */
+ return MNT_FMT_FSTAB; /* fstab, or /proc/mounts */
}
static int is_comment_line(const char *line)
/* default filename is /proc/self/mountinfo
*/
-int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
+int __mnt_table_parse_mountinfo(struct libmnt_table *tb, const char *filename,
struct libmnt_table *u_tb)
{
int rc = 0, priv_utab = 0;
assert(tb);
if (filename)
- DBG(TAB, ul_debugobj(tb, "%s requested as mtab", filename));
+ DBG(TAB, ul_debugobj(tb, "%s requested as mount table", filename));
if (!filename || strcmp(filename, _PATH_PROC_MOUNTINFO) == 0) {
filename = _PATH_PROC_MOUNTINFO;
tb->fmt = MNT_FMT_MOUNTINFO;
- DBG(TAB, ul_debugobj(tb, "mtab parse: #1 read mountinfo"));
+ DBG(TAB, ul_debugobj(tb, "mountinfo parse: #1 read mountinfo"));
} else
tb->fmt = MNT_FMT_GUESS;
if (!is_mountinfo(tb))
return 0;
- DBG(TAB, ul_debugobj(tb, "mtab parse: #2 read utab"));
+ DBG(TAB, ul_debugobj(tb, "mountinfo parse: #2 read utab"));
if (mnt_table_get_nents(tb) == 0)
return 0; /* empty, ignore utab */
priv_utab = 1;
}
- DBG(TAB, ul_debugobj(tb, "mtab parse: #3 merge utab"));
+ DBG(TAB, ul_debugobj(tb, "mountinfo parse: #3 merge utab"));
if (rc == 0) {
struct libmnt_fs *u_fs;
* mountinfo file then /run/mount/utabs is parsed too and both files are merged
* to the one libmnt_table.
*
- * If libmount is compiled with classic mtab file support, and the /etc/mtab is
- * a regular file then this file is parsed.
+ * The file /etc/mtab is no more used. The function uses "mtab" in the name for
+ * backward compatibility only.
*
* It's strongly recommended to use NULL as a @filename to keep code portable.
*
*/
int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename)
{
- return __mnt_table_parse_mtab(tb, filename, NULL);
+ return __mnt_table_parse_mountinfo(tb, filename, NULL);
}
* @short_description: userspace mount information management
*
* The struct libmnt_update provides an abstraction to manage mount options in
- * userspace independently of system configuration. This low-level API works on
- * systems both with and without /etc/mtab. On systems without the regular /etc/mtab
- * file, the userspace mount options (e.g. user=) are stored in the /run/mount/utab
- * file.
+ * userspace independently of system configuration. The userspace mount options
+ * (e.g. user=) are stored in the /run/mount/utab file.
*
* It's recommended to use high-level struct libmnt_context API.
*/
struct libmnt_fs *fs;
char *filename;
unsigned long mountflags;
- int userspace_only;
int ready;
struct libmnt_table *mountinfo;
/*
* Returns 0 on success, <0 in case of error.
*/
-int mnt_update_set_filename(struct libmnt_update *upd, const char *filename,
- int userspace_only)
+int mnt_update_set_filename(struct libmnt_update *upd, const char *filename)
{
const char *path = NULL;
int rw = 0;
if (!p)
return -ENOMEM;
- upd->userspace_only = userspace_only;
free(upd->filename);
upd->filename = p;
}
if (upd->filename)
return 0;
- /* detect tab filename -- /etc/mtab or /run/mount/utab
+ /* detect tab filename -- /run/mount/utab
*/
path = NULL;
mnt_has_regular_utab(&path, &rw);
if (!rw)
return -EACCES;
- upd->userspace_only = TRUE;
upd->filename = strdup(path);
if (!upd->filename)
return -ENOMEM;
* mnt_update_get_filename:
* @upd: update
*
- * This function returns the file name (e.g. /etc/mtab) of the up-dated file.
+ * This function returns the file name of the up-dated file.
*
* Returns: pointer to filename that will be updated or NULL in case of error.
*/
* @upd: update handler
*
* Returns: 1 if entry described by @upd is successfully prepared and will be
- * written to the mtab/utab file.
+ * written to the utab file.
*/
int mnt_update_is_ready(struct libmnt_update *upd)
{
upd->mountflags = mountflags;
- rc = mnt_update_set_filename(upd, NULL, 0);
+ rc = mnt_update_set_filename(upd, NULL);
if (rc) {
DBG(UPDATE, ul_debugobj(upd, "no writable file available [rc=%d]", rc));
return rc; /* error or no file available (rc = 1) */
return -ENOMEM;
} else if (fs) {
- if (upd->userspace_only && !(mountflags & MS_MOVE)) {
+ if (!(mountflags & MS_MOVE)) {
rc = utab_new_entry(upd, fs, mountflags);
if (rc)
- return rc;
+ return rc;
} else {
upd->fs = mnt_copy_mtab_fs(fs);
if (!upd->fs)
return -ENOMEM;
-
}
}
-
DBG(UPDATE, ul_debugobj(upd, "ready"));
upd->ready = TRUE;
return 0;
if (!rdonly && !(upd->mountflags & MS_RDONLY))
return 0;
- if (!upd->userspace_only) {
- /* /etc/mtab -- we care about VFS options there */
- const char *o = mnt_fs_get_options(upd->fs);
- char *n = o ? strdup(o) : NULL;
-
- if (n)
- mnt_optstr_remove_option(&n, rdonly ? "rw" : "ro");
- if (!mnt_optstr_prepend_option(&n, rdonly ? "ro" : "rw", NULL))
- rc = mnt_fs_set_options(upd->fs, n);
-
- free(n);
- }
-
if (rdonly)
upd->mountflags &= ~MS_RDONLY;
else
fputs(mnt_table_get_intro_comment(tb), f);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
- if (upd->userspace_only)
- rc = fprintf_utab_fs(f, fs);
- else
- rc = fprintf_mtab_fs(f, fs);
+ rc = fprintf_utab_fs(f, fs);
if (rc) {
DBG(UPDATE, ul_debugobj(upd,
"%s: write entry failed: %m", uq));
if (rc)
return -MNT_ERR_LOCK;
- tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
+ tb = __mnt_new_table_from_file(upd->filename, MNT_FMT_UTAB, 1);
if (tb)
rc = add_file_entry(tb, upd);
if (lc)
if (rc)
return -MNT_ERR_LOCK;
- tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
+ tb = __mnt_new_table_from_file(upd->filename, MNT_FMT_UTAB, 1);
if (tb) {
struct libmnt_fs *rem = mnt_table_find_target(tb, upd->target, MNT_ITER_BACKWARD);
if (rem) {
if (rc)
return -MNT_ERR_LOCK;
- tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
+ tb = __mnt_new_table_from_file(upd->filename, MNT_FMT_UTAB, 1);
if (tb) {
const char *upd_source = mnt_fs_get_srcpath(upd->fs);
const char *upd_target = mnt_fs_get_target(upd->fs);
if (rc)
return -MNT_ERR_LOCK;
- tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
+ tb = __mnt_new_table_from_file(upd->filename, MNT_FMT_UTAB, 1);
if (tb) {
struct libmnt_fs *cur = mnt_table_find_target(tb,
mnt_fs_get_target(fs),
MNT_ITER_BACKWARD);
if (cur) {
- if (upd->userspace_only)
- rc = mnt_fs_set_attributes(cur, mnt_fs_get_attributes(fs));
+ rc = mnt_fs_set_attributes(cur, mnt_fs_get_attributes(fs));
if (!rc)
rc = mnt_fs_set_options(cur, mnt_fs_get_options(fs));
if (!rc)
if (lc)
mnt_lock_block_signals(lc, TRUE);
}
- if (lc && upd->userspace_only)
+ if (lc)
mnt_lock_use_simplelock(lc, TRUE); /* use flock */
if (!upd->fs && upd->target)
if (lc)
mnt_lock_block_signals(lc, TRUE);
}
- if (lc && upd->userspace_only)
+ if (lc)
mnt_lock_use_simplelock(lc, TRUE); /* use flock */
if (lc) {
rc = mnt_lock_file(lc);
}
}
- tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
+ tb = __mnt_new_table_from_file(upd->filename, MNT_FMT_UTAB, 1);
if (lc)
mnt_unlock_file(lc);
if (!tb)
/**
* mnt_has_regular_mtab:
- * @mtab: returns path to mtab
- * @writable: returns 1 if the file is writable
+ * @mtab: returns NULL
+ * @writable: returns 0
*
- * If the file does not exist and @writable argument is not NULL, then it will
- * try to create the file.
+ * Returns: 0
*
- * Returns: 1 if /etc/mtab is a regular file, and 0 in case of error (check
- * errno for more details).
+ * Deprecated: libmount does not use /etc/mtab at all since v2.39.
*/
int mnt_has_regular_mtab(const char **mtab, int *writable)
{
- struct stat st;
- int rc;
- const char *filename = mtab && *mtab ? *mtab : mnt_get_mtab_path();
-
if (writable)
*writable = 0;
- if (mtab && !*mtab)
- *mtab = filename;
-
- DBG(UTILS, ul_debug("mtab: %s", filename));
-
- rc = lstat(filename, &st);
-
- if (rc == 0) {
- /* file exists */
- if (S_ISREG(st.st_mode)) {
- if (writable)
- *writable = !try_write(filename, NULL);
- DBG(UTILS, ul_debug("%s: writable", filename));
- return 1;
- }
- goto done;
- }
-
- /* try to create the file */
- if (writable) {
- *writable = !try_write(filename, NULL);
- if (*writable) {
- DBG(UTILS, ul_debug("%s: writable", filename));
- return 1;
- }
- }
-
-done:
- DBG(UTILS, ul_debug("%s: irregular/non-writable", filename));
+ if (mtab)
+ *mtab = NULL;
return 0;
}
/**
* mnt_get_mtab_path:
*
- * This function returns the *default* location of the mtab file. The result does
- * not have to be writable. See also mnt_has_regular_mtab().
+ * This function returns the *default* location of the mtab file.
+ *
*
* Returns: path to /etc/mtab or $LIBMOUNT_MTAB.
+ *
+ * Deprecated: libmount uses /proc/self/mountinfo only.
+ *
*/
const char *mnt_get_mtab_path(void)
{
*LIBMOUNT_FSTAB*=<path>::
overrides the default location of the _fstab_ file (ignored for suid)
-*LIBMOUNT_MTAB*=<path>::
-overrides the default location of the _mtab_ file (ignored for suid)
-
*LIBMOUNT_DEBUG*=all::
enables libmount debug output
*LIBMOUNT_FSTAB*=<path>::
overrides the default location of the _fstab_ file (ignored for *suid*)
-*LIBMOUNT_MTAB*=<path>::
-overrides the default location of the _mtab_ file (ignored for *suid*)
-
*LIBMOUNT_DEBUG*=all::
enables *libmount* debug output
ts_log "Do tests..."
-export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
-rm -f $LIBMOUNT_MTAB
-ln -s /proc/mounts $LIBMOUNT_MTAB
-
export LIBMOUNT_UTAB=$TS_OUTPUT.utab
rm -f $LIBMOUNT_UTAB
> $LIBMOUNT_UTAB
ts_log "Do tests..."
-export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
-rm -f $LIBMOUNT_MTAB
-ln -s /proc/mounts $LIBMOUNT_MTAB
-
export LIBMOUNT_UTAB=$TS_OUTPUT.utab
rm -f $LIBMOUNT_UTAB
> $LIBMOUNT_UTAB