[PATCH-next v2] erofs: add support for FS_IOC_GETFSSYSFSPATH
Huang Xiaojia
huangxiaojia2 at huawei.com
Tue Jul 16 21:29:39 AEST 2024
FS_IOC_GETFSSYSFSPATH ioctl exposes /sys/fs path of a given filesystem,
potentially standarizing sysfs reporting. This patch add support for
FS_IOC_GETFSSYSFSPATH for erofs, "erofs/<dev>" will be outpt for bdev
case, and "erofs/[domain_id,]<fs_id>" will be output for non-bdev case.
Signed-off-by: Huang Xiaojia <huangxiaojia2 at huawei.com>
---
v2: handle non-bdev case.
v1: https://lore.kernel.org/all/20240624063801.2476116-1-huangxiaojia2@huawei.com/
---
fs/erofs/super.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 1b91d9513013..a24b6907363c 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -576,6 +576,20 @@ static const struct export_operations erofs_export_ops = {
.get_parent = erofs_get_parent,
};
+static void erofs_set_sysfs_name(struct super_block *sb)
+{
+ struct erofs_sb_info *sbi = EROFS_SB(sb);
+
+ if (erofs_is_fscache_mode(sb)) {
+ if (sbi->domain_id)
+ super_set_sysfs_name_generic(sb, "%s,%s", sbi->domain_id, sbi->fsid);
+ else
+ super_set_sysfs_name_generic(sb, "%s", sbi->fsid);
+ } else {
+ super_set_sysfs_name_id(sb);
+ }
+}
+
static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
{
struct inode *inode;
@@ -643,6 +657,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_flags |= SB_POSIXACL;
else
sb->s_flags &= ~SB_POSIXACL;
+ erofs_set_sysfs_name(sb);
#ifdef CONFIG_EROFS_FS_ZIP
xa_init(&sbi->managed_pslots);
--
2.34.1
More information about the Linux-erofs
mailing list