summaryrefslogtreecommitdiffstats
path: root/shlibs/mount
diff options
context:
space:
mode:
authorKarel Zak2010-11-26 14:33:29 +0100
committerKarel Zak2011-01-03 12:28:46 +0100
commit766af80be1c76bbae78bf86ce0ae757082bb92fa (patch)
tree88b95682bbd0fbe7c73833b39f70f74d111bb2eb /shlibs/mount
parentlibmount: use better format for utab, improve bind mounts (diff)
downloadkernel-qcow2-util-linux-766af80be1c76bbae78bf86ce0ae757082bb92fa.tar.gz
kernel-qcow2-util-linux-766af80be1c76bbae78bf86ce0ae757082bb92fa.tar.xz
kernel-qcow2-util-linux-766af80be1c76bbae78bf86ce0ae757082bb92fa.zip
libmount: fix to work with btrfs subvolume user mounts
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount')
-rw-r--r--shlibs/mount/src/context.c6
-rw-r--r--shlibs/mount/src/context_mount.c4
-rw-r--r--shlibs/mount/src/context_umount.c18
-rw-r--r--shlibs/mount/src/optstr.c9
-rw-r--r--shlibs/mount/src/tab_update.c15
5 files changed, 31 insertions, 21 deletions
diff --git a/shlibs/mount/src/context.c b/shlibs/mount/src/context.c
index 6ee68c16a..069a88343 100644
--- a/shlibs/mount/src/context.c
+++ b/shlibs/mount/src/context.c
@@ -756,8 +756,8 @@ int mnt_context_set_userspace_mountflags(mnt_context *cxt, unsigned long flags)
* @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.
*/
@@ -995,7 +995,7 @@ int mnt_context_prepare_helper(mnt_context *cxt, const char *name,
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;
diff --git a/shlibs/mount/src/context_mount.c b/shlibs/mount/src/context_mount.c
index cb681e0dd..fb593c3fd 100644
--- a/shlibs/mount/src/context_mount.c
+++ b/shlibs/mount/src/context_mount.c
@@ -126,7 +126,7 @@ done:
}
/*
- * 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.
@@ -160,7 +160,7 @@ static int generate_helper_optstr(mnt_context *cxt, char **optstr)
*/
static int evaluate_permissions(mnt_context *cxt)
{
- unsigned long u_flags;
+ unsigned long u_flags = 0;
const char *srcpath;
assert(cxt);
diff --git a/shlibs/mount/src/context_umount.c b/shlibs/mount/src/context_umount.c
index 7cb4a2a44..ca9ca7749 100644
--- a/shlibs/mount/src/context_umount.c
+++ b/shlibs/mount/src/context_umount.c
@@ -138,7 +138,7 @@ static int mnt_loopdev_associated_fs(const char *devname, mnt_fs *fs)
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;
@@ -243,9 +243,11 @@ static int evaluate_permissions(mnt_context *cxt)
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
@@ -253,14 +255,18 @@ static int evaluate_permissions(mnt_context *cxt)
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;
}
diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c
index c5c7c221a..475c4cf1f 100644
--- a/shlibs/mount/src/optstr.c
+++ b/shlibs/mount/src/optstr.c
@@ -520,7 +520,8 @@ int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs,
*
* "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
*/
@@ -567,7 +568,8 @@ int mnt_optstr_get_flags(const char *optstr, unsigned long *flags,
*
* "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
*/
@@ -589,7 +591,8 @@ int mnt_optstr_get_mountflags(const char *optstr, unsigned long *flags)
*
* "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
*/
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c
index 7a39c1b06..baf5b0b61 100644
--- a/shlibs/mount/src/tab_update.c
+++ b/shlibs/mount/src/tab_update.c
@@ -35,7 +35,7 @@ struct _mnt_update {
};
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:
@@ -212,7 +212,7 @@ static int utab_new_entry(mnt_fs *fs, unsigned long mountflags, mnt_fs **ent)
u = NULL;
if (!(mountflags & MS_REMOUNT)) {
- rc = set_fs_root(*ent, mountflags);
+ rc = set_fs_root(*ent, fs, mountflags);
if (rc)
goto err;
}
@@ -225,7 +225,7 @@ 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;
@@ -233,6 +233,7 @@ static int set_fs_root(mnt_fs *fs, unsigned long mountflags)
int rc = -ENOMEM;
assert(fs);
+ assert(result);
DBG(UPDATE, mnt_debug("setting FS root"));
@@ -248,7 +249,7 @@ static int set_fs_root(mnt_fs *fs, unsigned long mountflags)
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);
@@ -268,11 +269,11 @@ static int set_fs_root(mnt_fs *fs, unsigned long mountflags)
/* 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
@@ -321,7 +322,7 @@ dflt:
if (!root)
goto err;
}
- fs->root = root;
+ result->root = root;
DBG(UPDATE, mnt_debug("FS root result: %s", root));