From 978ba3889c8ff3955daf13dd2874bb8f159b450c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 11 Feb 2010 13:54:06 +0100 Subject: [PATCH] mount: warn users that mtab is read-only In repair mode the root filesystem is read-only and mtab file is not up to date. Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=427183 Signed-off-by: Karel Zak --- mount/fstab.c | 2 +- mount/fstab.h | 1 + mount/mount.c | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mount/fstab.c b/mount/fstab.c index 8cd35d64..97d64a2c 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -55,7 +55,7 @@ mtab_does_not_exist(void) { return var_mtab_does_not_exist; } -static int +int mtab_is_a_symlink(void) { get_mtab_info(); return var_mtab_is_a_symlink; diff --git a/mount/fstab.h b/mount/fstab.h index 8fc8fd41..38f7bab9 100644 --- a/mount/fstab.h +++ b/mount/fstab.h @@ -3,6 +3,7 @@ #include "mount_mntent.h" int mtab_is_writable(void); +int mtab_is_a_symlink(void); int mtab_does_not_exist(void); void reset_mtab_info(void); int is_mounted_once(const char *name); diff --git a/mount/mount.c b/mount/mount.c index 5cefdccc..6f93bc8a 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -201,6 +201,7 @@ static int opt_nofail = 0; static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit, *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper; +static int is_readonly(const char *node); static int mounted (const char *spec0, const char *node0); static int check_special_mountprog(const char *spec, const char *node, const char *type, int flags, char *extra_opts, int *status); @@ -282,6 +283,14 @@ print_all (char *types) { if (matching_type (mc->m.mnt_type, types)) print_one (&(mc->m)); } + + if (!mtab_does_not_exist() && !mtab_is_a_symlink() && is_readonly(_PATH_MOUNTED)) + printf(_("\n" + "mount: warning: /etc/mtab is not writable (e.g. read-only filesystem).\n" + " It's possible that information reported by mount(8) is not\n" + " up to date. For actual information about system mount points\n" + " check the /proc/mounts file.\n\n")); + exit (0); } -- 2.39.5