]> err.no Git - util-linux/commitdiff
mount: fix list logic in update_mtab
authorKarel Zak <kzak@redhat.com>
Wed, 25 Apr 2007 23:49:28 +0000 (01:49 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 25 Apr 2007 23:49:28 +0000 (01:49 +0200)
If mtab does not contain the new entry, then only mc0->prev is updated
to point to absent, but not the old mc0->prev's nxt pointer.  Because
we then use the nxt pointers to write the new mtab, absent is not
added to the new mtab.

(Note: fortunately, the mount doesn't use the update_mtab() for new
mounts, but for remount, move and umount only -- kzak)

If mtab is empty, absent->prev should be set to mc0, and not
mc0->prev, as it will be NULL.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/fstab.c

index 8e59c8a02b67c65151b697ef42195cb42dd68197..72c46f3676692e3a595085c738669664450e14fa 100644 (file)
@@ -665,7 +665,12 @@ update_mtab (const char *dir, struct my_mntent *instead) {
                absent->m.mnt_freq = instead->mnt_freq;
                absent->m.mnt_passno = instead->mnt_passno;
                absent->nxt = mc0;
-               absent->prev = mc0->prev;
+               if (mc0->prev != NULL) {
+                       absent->prev = mc0->prev;
+                       mc0->prev->nxt = absent;
+               } else {
+                       absent->prev = mc0;
+               }
                mc0->prev = absent;
                if (mc0->nxt == NULL)
                        mc0->nxt = absent;