From: Karel Zak Date: Thu, 12 Apr 2007 11:27:41 +0000 (+0200) Subject: mount: update mtab correctly when mount --move X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b44c6155b8430fdf832fabc42d3f4b8dfa9f072;p=util-linux mount: update mtab correctly when mount --move Signed-off-by: Karel Zak --- diff --git a/mount/fstab.c b/mount/fstab.c index bdcc7a67..1e186c19 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -638,9 +638,13 @@ update_mtab (const char *dir, struct my_mntent *instead) { mc->nxt->prev = mc->prev; free(mc); } - } else { + } else if (!strcmp(mc->m.mnt_dir, instead->mnt_dir)) { /* A remount */ mc->m.mnt_opts = instead->mnt_opts; + } else { + /* A move */ + my_free(mc->m.mnt_dir); + mc->m.mnt_dir = xstrdup(instead->mnt_dir); } } else if (instead) { /* not found, add a new entry */ diff --git a/mount/mount.c b/mount/mount.c index 63e67313..1360d235 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -752,7 +752,7 @@ update_mtab_entry(const char *spec, const char *node, const char *type, mnt.mnt_opts = opts; mnt.mnt_freq = freq; mnt.mnt_passno = pass; - + /* We get chatty now rather than after the update to mtab since the mount succeeded, even if the write to /etc/mtab should fail. */ if (verbose) @@ -761,6 +761,8 @@ update_mtab_entry(const char *spec, const char *node, const char *type, if (!nomtab && mtab_is_writable()) { if (flags & MS_REMOUNT) update_mtab (mnt.mnt_dir, &mnt); + else if (flags & MS_MOVE) + update_mtab(mnt.mnt_fsname, &mnt); else { mntFILE *mfp;