mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Fix bchu_fs_get_devices()
This commit is contained in:
parent
7d2baabdb1
commit
c58f66878f
@ -1114,7 +1114,7 @@ dev_names bchu_fs_get_devices(struct bchfs_handle fs)
|
||||
darray_init(devs);
|
||||
|
||||
while ((errno = 0), (d = readdir(dir))) {
|
||||
struct dev_name n;
|
||||
struct dev_name n = { 0, NULL, NULL };
|
||||
|
||||
if (sscanf(d->d_name, "dev-%u", &n.idx) != 1)
|
||||
continue;
|
||||
@ -1122,9 +1122,12 @@ dev_names bchu_fs_get_devices(struct bchfs_handle fs)
|
||||
char *block_attr = mprintf("dev-%u/block", n.idx);
|
||||
|
||||
char sysfs_block_buf[4096];
|
||||
if (readlinkat(fs.sysfs_fd, block_attr,
|
||||
sysfs_block_buf, sizeof(sysfs_block_buf)) > 0)
|
||||
ssize_t r = readlinkat(fs.sysfs_fd, block_attr,
|
||||
sysfs_block_buf, sizeof(sysfs_block_buf));
|
||||
if (r > 0) {
|
||||
sysfs_block_buf[r] = '\0';
|
||||
n.dev = strdup(basename(sysfs_block_buf));
|
||||
}
|
||||
|
||||
free(block_attr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user