From ae1182cb8442c73e561290fbf79fd52346703987 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 9 Dec 2005 18:11:16 -0500 Subject: [PATCH] Make e2fsck -cc warn on a read-only root filesystem Don't let the user run e2fsck -ccn on the root partition, without warning that he or she might be doing something Really Stupid. Signed-off-by: "Theodore Ts'o" --- e2fsck/ChangeLog | 5 ++++- e2fsck/unix.c | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 66d5a5d..5ee9390 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,7 +1,10 @@ 2005-12-09 Theodore Ts'o * unix.c (PRS): Fix typo in error message; thanks to Solar - Designer for pointing out the missing proposition. + Designer for pointing out the missing preposition. + (check_mount): Don't let the user run e2fsck -ccn on the + root partition, without warning that he or she might + be doing something Really Stupid. * e2fsck.8.in: Clarify description of differences between the -p, -n, and -y options. diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 4e1b814..63d355e 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -179,15 +179,18 @@ static void check_mount(e2fsck_t ctx) } /* - * If the filesystem isn't mounted, or it's the root filesystem - * and it's mounted read-only, then everything's fine. + * If the filesystem isn't mounted, or it's the root + * filesystem and it's mounted read-only, and we're not doing + * a read/write check, then everything's fine. */ if ((!(ctx->mount_flags & EXT2_MF_MOUNTED)) || ((ctx->mount_flags & EXT2_MF_ISROOT) && - (ctx->mount_flags & EXT2_MF_READONLY))) + (ctx->mount_flags & EXT2_MF_READONLY) && + !(ctx->options & E2F_OPT_WRITECHECK))) return; - if (ctx->options & E2F_OPT_READONLY) { + if ((ctx->options & E2F_OPT_READONLY) && + !(ctx->options & E2F_OPT_WRITECHECK)) { printf(_("Warning! %s is mounted.\n"), ctx->filesystem_name); return; } -- 1.8.3.1