if (!fs_path)
die("Please supply a filesystem");
- char *dev_path = arg_pop();
- if (!dev_path)
+ dev_opts.path = arg_pop();
+ if (!dev_opts.path)
die("Please supply a device");
if (argc)
struct bchfs_handle fs = bcache_fs_open(fs_path);
- dev_opts.path = dev_path;
dev_opts.fd = open_for_format(dev_opts.path, force);
struct bch_opt_strs fs_opt_strs;
struct bch_opts fs_opts = bch2_parse_opts(fs_opt_strs);
opt_set(fs_opts, block_size,
- read_file_u64(fs.sysfs_fd, "block_size") >> 9);
+ read_file_u64(fs.sysfs_fd, "options/block_size") >> 9);
opt_set(fs_opts, btree_node_size,
- read_file_u64(fs.sysfs_fd, "btree_node_size") >> 9);
+ read_file_u64(fs.sysfs_fd, "options/btree_node_size") >> 9);
struct bch_sb *sb = bch2_format(fs_opt_strs,
fs_opts,
free(ctl);
} else {
/* It's a path: */
- ret.ioctl_fd = xopen(path, O_RDONLY);
+ ret.ioctl_fd = open(path, O_RDONLY);
+ if (ret.ioctl_fd < 0)
+ die("Error opening filesystem at %s: %m", path);
struct bch_ioctl_query_uuid uuid;
if (ioctl(ret.ioctl_fd, BCH_IOCTL_QUERY_UUID, &uuid) < 0)
{
char *buf = read_file_str(dirfd, path);
u64 v;
- if (kstrtou64(buf, 10, &v))
+ if (bch2_strtou64_h(buf, &v))
die("read_file_u64: error parsing %s (got %s)", path, buf);
free(buf);
return v;
const char *fs_type = NULL, *fs_label = NULL;
size_t fs_type_len, fs_label_len;
- int fd = xopen(dev, O_RDWR|O_EXCL);
+ int fd = open(dev, O_RDWR|O_EXCL);
+ if (fd < 0)
+ die("Error opening device to format %s: %m", dev);
if (force)
return fd;