mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-11 12:27:58 +00:00
btrfs-progs: deal with invalid option combinations for btrfs-image
For btrfs-image, dump may not come with option '-o' -r may not come with option '-c', '-s', '-w', dev_cnt != 1 -m may not come with dev_cnt < 2 All of the above should be regarded as invalid combinations, and the usage will show up. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
729c0da103
commit
08b0fdced1
@ -2463,6 +2463,7 @@ int main(int argc, char *argv[])
|
|||||||
int ret;
|
int ret;
|
||||||
int sanitize = 0;
|
int sanitize = 0;
|
||||||
int dev_cnt = 0;
|
int dev_cnt = 0;
|
||||||
|
int usage_error = 0;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -2501,15 +2502,30 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((old_restore) && create)
|
|
||||||
print_usage();
|
|
||||||
|
|
||||||
argc = argc - optind;
|
argc = argc - optind;
|
||||||
dev_cnt = argc - 1;
|
dev_cnt = argc - 1;
|
||||||
|
|
||||||
if (multi_devices && dev_cnt < 2)
|
if (create) {
|
||||||
print_usage();
|
if (old_restore) {
|
||||||
if (!multi_devices && dev_cnt != 1)
|
fprintf(stderr, "Usage error: create and restore cannot be used at the same time\n");
|
||||||
|
usage_error++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (walk_trees || sanitize || compress_level) {
|
||||||
|
fprintf(stderr, "Usage error: use -w, -s, -c options for restore makes no sense\n");
|
||||||
|
usage_error++;
|
||||||
|
}
|
||||||
|
if (multi_devices && dev_cnt < 2) {
|
||||||
|
fprintf(stderr, "Usage error: not enough devices specified for -m option\n");
|
||||||
|
usage_error++;
|
||||||
|
}
|
||||||
|
if (!multi_devices && dev_cnt != 1) {
|
||||||
|
fprintf(stderr, "Usage error: accepts only 1 device without -m option\n");
|
||||||
|
usage_error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usage_error)
|
||||||
print_usage();
|
print_usage();
|
||||||
|
|
||||||
source = argv[optind];
|
source = argv[optind];
|
||||||
|
Loading…
Reference in New Issue
Block a user