btrfs-progs: mkfs: open code profile parsing helper
There's a helper to parse profile name and exits on error. As this is a trivial helper we can open code it and adapt the error message to be more specific what failed. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
e331037d40
commit
74be9f5115
26
mkfs/main.c
26
mkfs/main.c
|
@ -421,20 +421,6 @@ static void print_usage(int ret)
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 parse_profile(const char *s)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
u64 flags = 0;
|
|
||||||
|
|
||||||
ret = parse_bg_profile(s, &flags);
|
|
||||||
if (ret) {
|
|
||||||
error("unknown profile %s", s);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *parse_label(const char *input)
|
static char *parse_label(const char *input)
|
||||||
{
|
{
|
||||||
int len = strlen(input);
|
int len = strlen(input);
|
||||||
|
@ -1053,7 +1039,11 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||||
force_overwrite = true;
|
force_overwrite = true;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
data_profile = parse_profile(optarg);
|
ret = parse_bg_profile(optarg, &data_profile);
|
||||||
|
if (ret) {
|
||||||
|
error("unknown data profile %s", optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
data_profile_opt = true;
|
data_profile_opt = true;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
@ -1067,7 +1057,11 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||||
label = parse_label(optarg);
|
label = parse_label(optarg);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
metadata_profile = parse_profile(optarg);
|
ret = parse_bg_profile(optarg, &metadata_profile);
|
||||||
|
if (ret) {
|
||||||
|
error("unknown metadata profile %s", optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
metadata_profile_opt = true;
|
metadata_profile_opt = true;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
|
|
Loading…
Reference in New Issue