From: Theodore Ts'o Date: Sun, 29 Jul 2012 04:16:44 +0000 (-0400) Subject: e2fsck: check a file system mounted read-only if forced X-Git-Tag: v1.42.5~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78a0d2ba6decf41f541f6ff79433b2d23aad35e8;p=thirdparty%2Fe2fsprogs.git e2fsck: check a file system mounted read-only if forced Previously e2fsck would only allow a mounted file system to be checked if it was the root file system and it was mounted read-only. Now allow any file system mounted read-only if the -f option is specified. This makes it easier to test how e2fsck handles checking file systems which are mounted without having to test on the root file system. Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/unix.c b/e2fsck/unix.c index f71a125c5..da41f6995 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -225,7 +225,9 @@ static void check_mount(e2fsck_t ctx) !(ctx->options & E2F_OPT_WRITECHECK))) return; - if ((ctx->options & E2F_OPT_READONLY) && + if (((ctx->options & E2F_OPT_READONLY) || + ((ctx->options & E2F_OPT_FORCE) && + (ctx->mount_flags & EXT2_MF_READONLY))) && !(ctx->options & E2F_OPT_WRITECHECK)) { log_out(ctx, _("Warning! %s is %s.\n"), ctx->filesystem_name, @@ -1226,6 +1228,9 @@ restart: if (!(ctx->mount_flags & EXT2_MF_ISROOT && ctx->mount_flags & EXT2_MF_READONLY)) flags |= EXT2_FLAG_EXCLUSIVE; + if ((ctx->mount_flags & EXT2_MF_READONLY) && + (ctx->options & E2F_OPT_FORCE)) + flags &= ~EXT2_FLAG_EXCLUSIVE; } retval = try_open_fs(ctx, flags, io_ptr, &fs);