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

Bill Rugolsky Jr.
2004-02-11T15:11:51Z

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

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

[-- Attachment #2: util-linux-2.12pre-mountmove.patch --]
[-- Type: text/plain, Size: 934 bytes --]

--- 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;