diff options
author | Hugo Mills <hugo@carfax.org.uk> | 2015-01-27 15:05:53 +0000 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-01-27 16:42:49 +0100 |
commit | 82ecb9c660959d57ac218d21c3becfc19e2740c8 (patch) | |
tree | 7377bb3c5c5ccc5da5dcd46fd46be033a0a1accc /cmds-check.c | |
parent | 7c126f7afc33d0aca7fc3053c7f1348df6feb8c8 (diff) |
btrfs-progs: check: Add --readonly flag
Particularly during support conversations, people get confused about
which options to use with btrfs check. Adding a flag, --readonly, which
implies the default read-only behaviour and which conflicts with the
read-write operations, should help make the behaviour of the tool clear.
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-check.c')
-rw-r--r-- | cmds-check.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cmds-check.c b/cmds-check.c index c24e4e04..68863707 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -8429,6 +8429,7 @@ int cmd_check(int argc, char **argv) int ret; u64 num; int init_csum_tree = 0; + int readonly = 0; int qgroup_report = 0; enum btrfs_open_ctree_flags ctree_flags = OPEN_CTREE_EXCLUSIVE; @@ -8436,10 +8437,11 @@ int cmd_check(int argc, char **argv) int c; int option_index = 0; enum { OPT_REPAIR = 257, OPT_INIT_CSUM, OPT_INIT_EXTENT, - OPT_CHECK_CSUM }; + OPT_CHECK_CSUM, OPT_READONLY }; static const struct option long_options[] = { { "super", 1, NULL, 's' }, { "repair", 0, NULL, OPT_REPAIR }, + { "readonly", 0, NULL, OPT_READONLY }, { "init-csum-tree", 0, NULL, OPT_INIT_CSUM }, { "init-extent-tree", 0, NULL, OPT_INIT_EXTENT }, { "check-data-csum", 0, NULL, OPT_CHECK_CSUM }, @@ -8488,6 +8490,9 @@ int cmd_check(int argc, char **argv) repair = 1; ctree_flags |= OPEN_CTREE_WRITES; break; + case OPT_READONLY: + readonly = 1; + break; case OPT_INIT_CSUM: printf("Creating a new CRC tree\n"); init_csum_tree = 1; @@ -8510,6 +8515,12 @@ int cmd_check(int argc, char **argv) if (check_argc_exact(argc, 1)) usage(cmd_check_usage); + /* This check is the only reason for --readonly to exist */ + if (readonly && repair) { + fprintf(stderr, "Repair options are not compatible with --readonly\n"); + exit(1); + } + radix_tree_init(); cache_tree_init(&root_cache); |