[PATCH -next v3] erofs: add support for FS_IOC_GETFSSYSFSPATH
Huang Xiaojia
huangxiaojia2 at huawei.com
Sat Jul 20 18:23:35 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 outputted for bdev
cases, "erofs/[domain_id,]<fs_id>" will be outputted for fscache cases.
Signed-off-by: Huang Xiaojia <huangxiaojia2 at huawei.com>
---
v3: fix commit message, overly long line and an else branch.
For bdev, it's tested as following:
mkfs.erofs test.img <SOURCES>
mount -t erofs test.img <mntdir>
ioctl_getfssysfspath <mntdir>
erofs/<dev> will be outputted.
For fscache, it's tested via https://github.com/lostjeffle/demand-read-cachefilesd.git
./run.sh inputdir mntdir fscachedir
ioctl_getfssysfspath mntdir
erofs/[domain_id,]<fs_id> will be outputted
v2: handle non-bdev case. https://lore.kernel.org/all/20240716112939.2355999-1-huangxiaojia2@huawei.com/
v1: https://lore.kernel.org/all/20240624063801.2476116-1-huangxiaojia2@huawei.com/
---
fs/erofs/super.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 1b91d9513013..d7900262aa75 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -576,6 +576,21 @@ 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);
+ return;
+ }
+ 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 +658,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