From b2b7b73d5eb1ebb950ea88db929aa0f0973d9b40 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 26 Apr 2007 01:49:28 +0200 Subject: [PATCH] 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 --- mount/fstab.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; -- 2.39.5