summaryrefslogtreecommitdiffstats
path: root/shlibs/mount/src/tab_update.c
diff options
context:
space:
mode:
authorKarel Zak2010-12-18 01:08:25 +0100
committerKarel Zak2011-01-03 12:28:47 +0100
commit2915bdc0db7b6931c35e235879d59b6c61b4b1bc (patch)
treefe72436518b23336af7a06416749209781706396 /shlibs/mount/src/tab_update.c
parentlibmount: cleanup MS_RDONLY usageand mnt_update_* symbols (diff)
downloadkernel-qcow2-util-linux-2915bdc0db7b6931c35e235879d59b6c61b4b1bc.tar.gz
kernel-qcow2-util-linux-2915bdc0db7b6931c35e235879d59b6c61b4b1bc.tar.xz
kernel-qcow2-util-linux-2915bdc0db7b6931c35e235879d59b6c61b4b1bc.zip
libmount: clean mnt_update_* target usage
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/tab_update.c')
-rw-r--r--shlibs/mount/src/tab_update.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c
index cc0335fb8..5afa0d49d 100644
--- a/shlibs/mount/src/tab_update.c
+++ b/shlibs/mount/src/tab_update.c
@@ -146,8 +146,8 @@ int mnt_update_is_ready(mnt_update *upd)
* mnt_update_set_fs:
* @upd: update handler
* @mountflags: MS_* flags
- * @target: umount target or MS_MOVE source
- * @fs: mount or MS_REMOUNT filesystem description, or MS_MOVE target
+ * @target: umount target, must be num for mount
+ * @fs: mount filesystem description, must be NULL for umount
*
* Returns: -1 in case on error, 0 on success, 1 if update is unnecessary.
*/
@@ -161,6 +161,10 @@ int mnt_update_set_fs(mnt_update *upd, unsigned long mountflags,
if (!upd)
return -EINVAL;
+ if ((mountflags & MS_MOVE) && (!fs || !mnt_fs_get_srcpath(fs)))
+ return -EINVAL;
+ if (target && fs)
+ return -EINVAL;
DBG(UPDATE, mnt_debug_h(upd,
"reseting FS [fs=0x%p, target=%s, flags=0x%08lx]",
@@ -180,13 +184,19 @@ int mnt_update_set_fs(mnt_update *upd, unsigned long mountflags,
if (mountflags & MS_PROPAGATION)
return 1;
+
upd->mountflags = mountflags;
rc = mnt_update_set_filename(upd, NULL, 0);
if (rc)
return rc; /* error or no file available (rc = 1) */
- if (fs) {
+ if (target) {
+ upd->target = strdup(target);
+ if (!upd->target)
+ return -ENOMEM;
+
+ } else if (fs) {
if (upd->userspace_only && !(mountflags & MS_MOVE)) {
int rc = utab_new_entry(fs, mountflags, &upd->fs);
if (rc)
@@ -198,11 +208,6 @@ int mnt_update_set_fs(mnt_update *upd, unsigned long mountflags,
}
}
- if (target) {
- upd->target = strdup(target);
- if (!upd->target)
- return -ENOMEM;
- }
DBG(UPDATE, mnt_debug_h(upd, "ready"));
upd->ready = TRUE;
@@ -675,7 +680,8 @@ static int update_modify_target(mnt_update *upd, mnt_lock *lc)
tb = __mnt_new_tab_from_file(upd->filename,
upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
if (tb) {
- mnt_fs *cur = mnt_tab_find_target(tb, upd->target, MNT_ITER_BACKWARD);
+ mnt_fs *cur = mnt_tab_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)