mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-21 00:00:10 +03:00
Add support for FS_IOC_GETFSSYSFSPATH
With single device mode we won't always show up in sysfs by UUID, but the new VFS ioctl handles this nicely. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
844721635c
commit
c9ee646718
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
|
|
||||||
|
#include <linux/fs.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
|
||||||
#include "libbcachefs.h"
|
#include "libbcachefs.h"
|
||||||
@ -447,12 +448,19 @@ int bcache_fs_open_fallible(const char *path, struct bchfs_handle *fs)
|
|||||||
|
|
||||||
fs->uuid = uuid.uuid;
|
fs->uuid = uuid.uuid;
|
||||||
|
|
||||||
char uuid_str[40];
|
struct fs_sysfs_path fs_sysfs_path;
|
||||||
uuid_unparse(uuid.uuid.b, uuid_str);
|
if (!ioctl(path_fd, FS_IOC_GETFSSYSFSPATH, &fs_sysfs_path)) {
|
||||||
|
char *sysfs = mprintf("/sys/fs/%s", fs_sysfs_path.name);
|
||||||
|
fs->sysfs_fd = xopen(sysfs, O_RDONLY);
|
||||||
|
free(sysfs);
|
||||||
|
} else {
|
||||||
|
char uuid_str[40];
|
||||||
|
uuid_unparse(uuid.uuid.b, uuid_str);
|
||||||
|
|
||||||
char *sysfs = mprintf(SYSFS_BASE "%s", uuid_str);
|
char *sysfs = mprintf(SYSFS_BASE "%s", uuid_str);
|
||||||
fs->sysfs_fd = xopen(sysfs, O_RDONLY);
|
fs->sysfs_fd = xopen(sysfs, O_RDONLY);
|
||||||
free(sysfs);
|
free(sysfs);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user