return 0;
}
-
-static void print_usage(void) __attribute__((noreturn));
-static void print_usage(void)
+static void print_usage(int ret)
{
fprintf(stderr, "usage: mkfs.btrfs [options] dev [ dev ... ]\n");
fprintf(stderr, "options:\n");
fprintf(stderr, "\t-q|--quiet no messages except errors\n");
fprintf(stderr, "\t-V|--version print the mkfs.btrfs version and exit\n");
fprintf(stderr, "%s\n", PACKAGE_STRING);
- exit(1);
+ exit(ret);
}
static void print_version(void) __attribute__((noreturn));
return 0;
} else {
fprintf(stderr, "Unknown profile %s\n", s);
- print_usage();
}
/* not reached */
return 0;
u64 source_dir_size = 0;
int dev_cnt = 0;
int saved_optind;
- char estr[100];
char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 };
u64 features = BTRFS_MKFS_DEFAULT_FEATURES;
struct mkfs_allocation allocation = { 0 };
{ "features", required_argument, NULL, 'O' },
{ "uuid", required_argument, NULL, 'U' },
{ "quiet", 0, NULL, 'q' },
+ { "help", no_argument, NULL, GETOPT_VAL_HELP },
{ NULL, 0, NULL, 0}
};
case 'q':
verbose = 0;
break;
+ case GETOPT_VAL_HELP:
default:
- print_usage();
+ print_usage(c != GETOPT_VAL_HELP);
}
}
sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
saved_optind = optind;
dev_cnt = ac - optind;
if (dev_cnt == 0)
- print_usage();
+ print_usage(1);
if (source_dir_set && dev_cnt > 1) {
fprintf(stderr,
while (dev_cnt-- > 0) {
file = av[optind++];
if (is_block_device(file))
- if (test_dev_for_mkfs(file, force_overwrite, estr)) {
- fprintf(stderr, "Error: %s", estr);
+ if (test_dev_for_mkfs(file, force_overwrite))
exit(1);
- }
}
optind = saved_optind;
}
}
ret = test_num_disk_vs_raid(metadata_profile, data_profile,
- dev_cnt, mixed, estr);
- if (ret) {
- fprintf(stderr, "Error: %s\n", estr);
+ dev_cnt, mixed);
+ if (ret)
exit(1);
- }
/* if we are here that means all devs are good to btrfsify */
if (verbose) {