[PATCH] Fix /etc/mtab updating with mount --move [was Re: devfs vs udev, thoughts from a devfs user]

From: Bill Rugolsky Jr.
Date: Wed Feb 11 2004 - 10:13:31 EST


On Wed, Feb 11, 2004 at 07:33:52AM -0500, Bill Rugolsky Jr. wrote:
> Anyway, with traditional /etc/mtab, mount --move produces:
>
> none on /tmp/a type ramfs (rw)
> /tmp/a on /tmp/b type none (rw)

Andries,

The attached patch against util-linux-2.12pre fixes /etc/mtab updating
when using mount --move.

Regards,

Bill Rugolsky
--- util-linux-2.12pre/mount/fstab.c.move 2003-07-05 16:16:05.000000000 -0400
+++ util-linux-2.12pre/mount/fstab.c 2004-02-11 09:56:12.644436000 -0500
@@ -541,8 +541,12 @@
mc->nxt->prev = mc->prev;
}
} else {
- /* A remount */
+ /* A remount or move */
mc->m.mnt_opts = instead->mnt_opts;
+ if (!streq(mc->m.mnt_dir, instead->mnt_dir)) {
+ free(mc->m.mnt_dir);
+ mc->m.mnt_dir = xstrdup(instead->mnt_dir);
+ }
}
} else if (instead) {
/* not found, add a new entry */
--- util-linux-2.12pre/mount/mount.c.move 2003-07-13 17:26:13.000000000 -0400
+++ util-linux-2.12pre/mount/mount.c 2004-02-11 10:03:25.754436000 -0500
@@ -635,7 +635,9 @@
print_one (&mnt);

if (!nomtab && mtab_is_writable()) {
- if (flags & MS_REMOUNT)
+ if (flags & MS_MOVE)
+ update_mtab (mnt.mnt_fsname, &mnt);
+ else if (flags & MS_REMOUNT)
update_mtab (mnt.mnt_dir, &mnt);
else {
mntFILE *mfp;