* @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()).
+ * Converts mount options string to MNT_MS_* flags and bitewise-OR the result
+ * with already defined flags (see mnt_context_set_userspace_mountflags()).
*
* Returns: 0 on success, negative number in case of error.
*/
rc = stat(helper, &st);
}
- DBG(CXT, mnt_debug_h(cxt, "%s ... %s", helper,
+ DBG(CXT, mnt_debug_h(cxt, "%-25s ... %s", helper,
rc ? "not found" : "found"));
if (rc)
continue;
}
/*
- * Converts already evalulated and fixed options to the form that is comaptible
+ * Converts already evalulated and fixed options to the form that is compatible
* with /sbin/mount.<type> helpers.
*
* Retursn newly allocated string.
*/
static int evaluate_permissions(mnt_context *cxt)
{
- unsigned long u_flags;
+ unsigned long u_flags = 0;
const char *srcpath;
assert(cxt);
static int evaluate_permissions(mnt_context *cxt)
{
mnt_tab *fstab;
- unsigned long u_flags;
+ unsigned long u_flags = 0;
const char *tgt, *src, *optstr;
int rc, ok = 0;
mnt_fs *fs;
if (mnt_optstr_get_userspace_mountflags(optstr, &u_flags))
goto eperm;
- if (u_flags & MNT_MS_USERS)
- /* promiscuous setting in fstab */
+ if (u_flags & MNT_MS_USERS) {
+ DBG(CXT, mnt_debug_h(cxt,
+ "umount: promiscuous setting ('users') in fstab"));
return 0;
+ }
/*
* Check user=<username> setting from mtab if there is user, owner or
* group option in /etc/fstab
if ((u_flags & MNT_MS_USER) || (u_flags & MNT_MS_OWNER) ||
(u_flags & MNT_MS_GROUP)) {
- char *curr_user = mnt_get_username(getuid());
+ char *curr_user = NULL;
char *mtab_user = NULL;
size_t sz;
+ DBG(CXT, mnt_debug_h(cxt,
+ "umount: checking user=<username> from mtab"));
+
+ curr_user = mnt_get_username(getuid());
+
if (!curr_user) {
DBG(CXT, mnt_debug_h(cxt, "umount %s: cannot "
- "convert %d to username",
- tgt, getuid()));
+ "convert %d to username", tgt, getuid()));
goto eperm;
}
*
* "bind,noexec,foo,bar" --returns-> MS_BIND|MS_NOEXEC
*
- * Note that @flags are not zeroized by this function.
+ * Note that @flags are not zeroized by this function! This function set/unset
+ * bites in the @flags only.
*
* Returns: 0 on success or negative number in case of error
*/
*
* "bind,noexec,foo,bar" --returns-> MS_BIND|MS_NOEXEC
*
- * Note that @flags are not zeroized by this function.
+ * Note that @flags are not zeroized by this function! This function set/unset
+ * bites in the @flags only.
*
* Returns: 0 on success or negative number in case of error
*/
*
* "bind,exec,loop" --returns-> MNT_MS_LOOP
*
- * Note that @flags are not zeroized by this function.
+ * Note that @flags are not zeroized by this function! This function set/unset
+ * bites in the @flags only.
*
* Returns: 0 on success or negative number in case of error
*/
};
static int utab_new_entry(mnt_fs *fs, unsigned long mountflags, mnt_fs **ent);
-static int set_fs_root(mnt_fs *fs, unsigned long mountflags);
+static int set_fs_root(mnt_fs *result, mnt_fs *fs, unsigned long mountflags);
/**
* mnt_new_update:
u = NULL;
if (!(mountflags & MS_REMOUNT)) {
- rc = set_fs_root(*ent, mountflags);
+ rc = set_fs_root(*ent, fs, mountflags);
if (rc)
goto err;
}
return rc;
}
-static int set_fs_root(mnt_fs *fs, unsigned long mountflags)
+static int set_fs_root(mnt_fs *result, mnt_fs *fs, unsigned long mountflags)
{
char *root = NULL, *mnt = NULL;
const char *fstype, *optstr;
int rc = -ENOMEM;
assert(fs);
+ assert(result);
DBG(UPDATE, mnt_debug("setting FS root"));
src = mnt_fs_get_srcpath(fs);
if (src) {
- rc = mnt_fs_set_bindsrc(fs, src);
+ rc = mnt_fs_set_bindsrc(result, src);
if (rc)
goto err;
mnt = mnt_get_mountpoint(src);
/* set device name and fs */
src = mnt_fs_get_srcpath(src_fs);
- rc = mnt_fs_set_source(fs, src);
+ rc = mnt_fs_set_source(result, src);
if (rc)
goto err;
- mnt_fs_set_fstype(fs, mnt_fs_get_fstype(src_fs));
+ mnt_fs_set_fstype(result, mnt_fs_get_fstype(src_fs));
/* on btrfs the subvolume is used as fs-root in
* /proc/self/mountinfo, so we have get the original subvolume
if (!root)
goto err;
}
- fs->root = root;
+ result->root = root;
DBG(UPDATE, mnt_debug("FS root result: %s", root));