From: Karel Zak Date: Thu, 11 Feb 2010 12:54:06 +0000 (+0100) Subject: mount: warn users that mtab is read-only X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=978ba3889c8ff3955daf13dd2874bb8f159b450c;p=util-linux 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 --- 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); }