summaryrefslogtreecommitdiff
path: root/c_src
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-04-13 18:39:23 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-04-13 21:10:24 -0400
commitc9ee6467183b224b40ca437fd23eeabe0ae6a158 (patch)
tree0345ab2882897a8d3c95a5a580f01e69db2e3540 /c_src
parent844721635c1c8e7e43fb546052a659bfc92ed99d (diff)
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>
Diffstat (limited to 'c_src')
-rw-r--r--c_src/libbcachefs.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/c_src/libbcachefs.c b/c_src/libbcachefs.c
index c8503839..31644ea1 100644
--- a/c_src/libbcachefs.c
+++ b/c_src/libbcachefs.c
@@ -16,6 +16,7 @@
#include <uuid/uuid.h>
+#include <linux/fs.h>
#include <linux/mm.h>
#include "libbcachefs.h"
@@ -447,12 +448,19 @@ int bcache_fs_open_fallible(const char *path, struct bchfs_handle *fs)
fs->uuid = uuid.uuid;
- char uuid_str[40];
- uuid_unparse(uuid.uuid.b, uuid_str);
+ struct fs_sysfs_path fs_sysfs_path;
+ 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);
- fs->sysfs_fd = xopen(sysfs, O_RDONLY);
- free(sysfs);
+ char *sysfs = mprintf(SYSFS_BASE "%s", uuid_str);
+ fs->sysfs_fd = xopen(sysfs, O_RDONLY);
+ free(sysfs);
+ }
return 0;
}