Please, review. From my point of view the patch makes sense. Karel >From 50c383482eb2165222ef79040ffaeacca233b365 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin <markmc@xxxxxxxxxx> Date: Mon, 28 Jan 2008 14:30:29 +0100 Subject: [PATCH] mount: "can't create lock file" message sometimes means failure, sometimes not What the patch does is goes from the situation where: 1) If /etc/mtab doesn't exist and /etc is read-only, you get the "can't create lock file" message and the mount fails 2) If /etc/mtab does exist and /etc is read-only,you get the same message but the mount succeeds Clearly, the failure to update /etc/mtab should either cause the mount to fail or not ... sometimes causing it to fail, and sometimes not (each with the same message) is not useful. This patch sets the same behaviour for create and update mtab. In both cases it prints error message and the mount succeeds. Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx> Signed-off-by: Karel Zak <kzak@xxxxxxxxxx> --- mount/fstab.c | 5 +++++ mount/fstab.h | 1 + mount/mount.c | 16 +++++++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/mount/fstab.c b/mount/fstab.c index 03ddf4e..814e6fc 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -41,6 +41,11 @@ get_mtab_info(void) { } } +void +reset_mtab_info(void) { + have_mtab_info = 0; +} + int mtab_does_not_exist(void) { get_mtab_info(); diff --git a/mount/fstab.h b/mount/fstab.h index 75a34e3..14b24c4 100644 --- a/mount/fstab.h +++ b/mount/fstab.h @@ -4,6 +4,7 @@ #include "mount_mntent.h" int mtab_is_writable(void); int mtab_does_not_exist(void); +void reset_mtab_info(void); int is_mounted_once(const char *name); struct mntentchn { diff --git a/mount/mount.c b/mount/mount.c index 41fe71d..e6e733d 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -562,6 +562,8 @@ create_mtab (void) { my_endmntent (mfp); unlock_mtab(); + + reset_mtab_info(); } /* count successful mount system calls */ @@ -983,6 +985,13 @@ update_mtab_entry(const char *spec, const char *node, const char *type, if (verbose) print_one (&mnt); + if (!nomtab && mtab_does_not_exist()) { + if (verbose > 1) + printf(_("mount: no %s found - creating it..\n"), + MOUNTED); + create_mtab (); + } + if (!nomtab && mtab_is_writable()) { if (flags & MS_REMOUNT) update_mtab (mnt.mnt_dir, &mnt); @@ -2017,13 +2026,6 @@ main(int argc, char *argv[]) { die (EX_USAGE, _("mount: only root can do that")); } - if (!nomtab && mtab_does_not_exist()) { - if (verbose > 1) - printf(_("mount: no %s found - creating it..\n"), - _PATH_MOUNTED); - create_mtab (); - } - atexit(unlock_mtab); switch (argc+specseen) { -- 1.5.3.1 - To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html