diff options
author | Theodore Ts'o <tytso@mit.edu> | 2010-03-12 19:18:20 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-03-15 00:14:12 -0400 |
commit | 298c9c2f2e7cbe4250d054d2e0f4bef007a940ac (patch) | |
tree | 9e30147166148eb8bc57d281e9346cb2c8cd94a7 /e2fsck/unix.c | |
parent | ecced2c3586fed83750dad2b82780c9d201f6973 (diff) | |
download | e2fsprogs-298c9c2f2e7cbe4250d054d2e0f4bef007a940ac.tar.gz |
e2fsck: Make the -n always open the file system read-only
A user was surprised when -n -D caused the file system to be opened
read/write, and then outsmarted himself when e2fsck asked the question:
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)?
This is partially our fault for not documenting the fact that -D
overrode opening the filesystem read-write. But the bottom line is it
much safer if -n *always* opens the file system read-only, so there
can be no confusion. This means that we have to disable certain
combination of options, such as "-n -c", "-n -l", and "-n -L", and
"-n -D", but the utility of these combinations is pretty low, and
is more than offset by making e2fsck idiot-proof.
Addresses-Launchpad-Bug: #537483
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/unix.c')
-rw-r--r-- | e2fsck/unix.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 62489580..49e90085 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -789,8 +789,23 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) return 0; if (optind != argc - 1) usage(ctx); - if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file && - !cflag && !(ctx->options & E2F_OPT_COMPRESS_DIRS)) + if ((ctx->options & E2F_OPT_NO) && + (ctx->options & E2F_OPT_COMPRESS_DIRS)) { + com_err(ctx->program_name, 0, + _("The -n and -D options are incompatible.")); + fatal_error(ctx, 0); + } + if ((ctx->options & E2F_OPT_NO) && cflag) { + com_err(ctx->program_name, 0, + _("The -n and -c options are incompatible.")); + fatal_error(ctx, 0); + } + if ((ctx->options & E2F_OPT_NO) && bad_blocks_file) { + com_err(ctx->program_name, 0, + _("The -n and -l/-L options are incompatible.")); + fatal_error(ctx, 0); + } + if (ctx->options & E2F_OPT_NO) ctx->options |= E2F_OPT_READONLY; ctx->io_options = strchr(argv[optind], '?'); |