From: Karel Zak Date: Wed, 25 Apr 2007 23:49:28 +0000 (+0200) Subject: mount: fix list logic in update_mtab X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2b7b73d5eb1ebb950ea88db929aa0f0973d9b40;p=util-linux mount: fix list logic in update_mtab 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 Signed-off-by: Martin Schlemmer Signed-off-by: Karel Zak --- diff --git a/mount/fstab.c b/mount/fstab.c index 8e59c8a0..72c46f36 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -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;