src = mnt_fs_get_source(cxt->fs);
- /* ignore filesystems without a real source */
- if (!src || (cxt->fs->flags & (MNT_FS_PSEUDO | MNT_FS_NET)))
+ /* ignore filesystems without a real source or MS_PROPAGATION stuff */
+ if (!src ||
+ (cxt->fs->flags & (MNT_FS_PSEUDO | MNT_FS_NET)) ||
+ (cxt->mountflags & (MS_BIND | MS_MOVE | MS_PROPAGATION)))
return 0;
DBG(CXT, mnt_debug_h(cxt, "srcpath '%s'", src));
/*
* Initialize loop device
*/
- if (is_loop(cxt) &&
- !(cxt->mountflags & (MS_BIND | MS_MOVE |
- MS_PROPAGATION | MS_REMOUNT))) {
+ if (is_loop(cxt)) {
; /* TODO */
}
!cxt->mtab_writable);
}
- rc = mnt_update_set_fs(cxt->update, cxt->mountflags,
- mnt_fs_get_target(cxt->fs),
- cxt->action == MNT_ACT_UMOUNT ? NULL : cxt->fs);
+ if (cxt->action == MNT_ACT_UMOUNT)
+ rc = mnt_update_set_fs(cxt->update, cxt->mountflags,
+ mnt_fs_get_target(cxt->fs), NULL);
+ else
+ rc = mnt_update_set_fs(cxt->update, cxt->mountflags,
+ NULL, cxt->fs);
return rc < 0 ? rc : 0;
}
* 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.
*/
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]",
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)
}
}
- if (target) {
- upd->target = strdup(target);
- if (!upd->target)
- return -ENOMEM;
- }
DBG(UPDATE, mnt_debug_h(upd, "ready"));
upd->ready = TRUE;
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)