continue;
}
- res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count,
- 0, discard);
+ res = btrfs_prepare_device(devfd, argv[i], &dev_block_count, 0,
+ PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE |
+ (discard ? PREP_DEVICE_DISCARD : 0));
close(devfd);
if (res) {
ret++;
int all = 0;
int ret = 0;
- optind = 1;
while (1) {
int c;
static const struct option long_options[] = {
if (all || argc - optind == 0) {
printf("Scanning for Btrfs filesystems\n");
- ret = btrfs_scan_lblkid();
+ ret = btrfs_scan_devices();
error_on(ret, "error %d while scanning", ret);
ret = btrfs_register_all_devices();
error_on(ret, "there are %d errors while registering devices", ret);
clean_args_no_options(argc, argv, cmd_device_ready_usage);
- if (check_argc_min(argc - optind, 1))
+ if (check_argc_exact(argc - optind, 1))
usage(cmd_device_ready_usage);
fd = open("/dev/btrfs-control", O_RDWR);
__u64 flags = 0;
DIR *dirstream = NULL;
- optind = 1;
while ((c = getopt(argc, argv, "z")) != -1) {
switch (c) {
case 'z':
/* No path when device is missing. */
if (!canonical_path) {
canonical_path = malloc(32);
+ if (!canonical_path) {
+ error("not enough memory for path buffer");
+ goto out;
+ }
snprintf(canonical_path, 32,
"devid:%llu", args.devid);
}