mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-09 00:00:04 +03:00
Fix device add for kernel sysfs changes
Also slightly improve some error messages Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
55e3496d06
commit
2fc5a50bd6
@ -104,8 +104,8 @@ int cmd_device_add(int argc, char *argv[])
|
||||
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)
|
||||
@ -113,7 +113,6 @@ int cmd_device_add(int argc, char *argv[])
|
||||
|
||||
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;
|
||||
@ -122,9 +121,9 @@ int cmd_device_add(int argc, char *argv[])
|
||||
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,
|
||||
|
@ -899,7 +899,9 @@ struct bchfs_handle bcache_fs_open(const char *path)
|
||||
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)
|
||||
|
@ -211,7 +211,7 @@ u64 read_file_u64(int dirfd, const char *path)
|
||||
{
|
||||
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;
|
||||
@ -262,7 +262,9 @@ int open_for_format(const char *dev, bool force)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user