erofs: Add support for FS_IOC_GETFSLABEL
PATCH 1/1 erofs: Add support for FS_IOC_GETFSLABEL
From: Bo Liu (OpenAnolis) <[email protected]>
Add support for reading to the erofs volume label from the FS_IOC_GETFSLABEL ioctls.
---
v1: https://lore.kernel.org/linux-erofs/[email protected]/T/#t
v2: https://lore.kernel.org/linux-erofs/[email protected]/T/#u
Changes since v2:
- remove unnecessary code
fs/erofs/Makefile | 2 +- fs/erofs/data.c | 4 ++++ fs/erofs/dir.c | 4 ++++ fs/erofs/inode.c | 5 +---- fs/erofs/internal.h | 7 +++++++ fs/erofs/ioctl.c | 41 +++++++++++++++++++++++++++++++++++++++++ fs/erofs/super.c | 8 ++++++++ 7 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 fs/erofs/ioctl.c
fs/erofs/Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_EROFS_FS) += erofs.o -erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o +erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o ioctl.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o zutil.o erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.o
fs/erofs/data.c +4 -0
@@ -475,6 +475,10 @@ static loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence)const struct file_operations erofs_file_fops = { .llseek = erofs_file_llseek, .read_iter = erofs_file_read_iter, + .unlocked_ioctl = erofs_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = erofs_compat_ioctl, +#endif .mmap_prepare = erofs_file_mmap_prepare, .get_unmapped_area = thp_get_unmapped_area, .splice_read = filemap_splice_read,
fs/erofs/dir.c +4 -0
@@ -123,4 +123,8 @@ const struct file_operations erofs_dir_fops = { .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = erofs_readdir, + .unlocked_ioctl = erofs_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = erofs_compat_ioctl, +#endif };
fs/erofs/inode.c +1 -4
@@ -213,10 +213,7 @@ static int erofs_fill_inode(struct inode *inode)switch (inode->i_mode &S_IFMT ) {case S_IFREG : inode->i_op = &erofs_generic_iops; -if (erofs_inode_is_data_compressed (vi->datalayout)) - inode->i_fop = &generic_ro_fops; -else - inode->i_fop = &erofs_file_fops; + inode->i_fop = &erofs_file_fops;break ;case S_IFDIR : inode->i_op = &erofs_dir_iops;
fs/erofs/internal.h +7 -0
@@ -166,6 +166,9 @@ struct erofs_sb_info {struct erofs_domain *domain;char *fsid;char *domain_id; + +/* volume name */ +char *volume_name; };#define EROFS_SB (sb) ((struct erofs_sb_info *)(sb)->s_fs_info)
@@ -535,6 +538,10 @@ static inline struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev) {static inline void erofs_fscache_submit_bio (struct bio *bio) {}#endif +long erofs_ioctl (struct file *filp,unsigned int cmd,unsigned long arg); +long erofs_compat_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg); +#define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */ #endif /* __EROFS_INTERNAL_H */
fs/erofs/ioctl.c new file +41 -0
41 lines not on this page · raw message
fs/erofs/super.c +8 -0
@@ -343,6 +343,13 @@ static int erofs_read_superblock(struct super_block *sb) sbi->fixed_nsec =le32_to_cpu (dsb->fixed_nsec);super_set_uuid (sb, (void *)dsb->uuid,sizeof (dsb->uuid)); +if (dsb->volume_name[0 ]) { + sbi->volume_name =kstrndup (dsb->volume_name, +sizeof (dsb->volume_name),GFP_KERNEL ); +if (!sbi->volume_name) +return -ENOMEM ; + } +/* parse on-disk compression configurations */ ret =z_erofs_parse_cfgs (sb, dsb);if (ret <0 )
@@ -822,6 +829,7 @@ static void erofs_sb_free(struct erofs_sb_info *sbi)kfree (sbi->domain_id);if (sbi->dif0.file)fput (sbi->dif0.file); +kfree (sbi->volume_name);kfree (sbi); }
Signature · 1 line
2.31.1
Quoted 86 lines · Bo Liu
From: Bo Liu (OpenAnolis) <[email protected]>
Add support for reading to the erofs volume label from the
FS_IOC_GETFSLABELioctls.Signed-off-by Bo Liu (OpenAnolis) <[email protected]>---
v1: https://lore.kernel.org/linux-erofs/[email protected]/T/#t
v2: https://lore.kernel.org/linux-erofs/[email protected]/T/#uChanges since v2:
- remove unnecessary codefs/erofs/Makefile | 2 +- fs/erofs/data.c | 4 ++++ fs/erofs/dir.c | 4 ++++ fs/erofs/inode.c | 5 +---- fs/erofs/internal.h | 7 +++++++ fs/erofs/ioctl.c | 41 +++++++++++++++++++++++++++++++++++++++++ fs/erofs/super.c | 8 ++++++++ 7 files changed, 66 insertions(+), 5 deletions(-)create mode 100644
fs/erofs/ioctl.cfs/erofs/Makefile +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_EROFS_FS) += erofs.o -erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o +erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o ioctl.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o zutil.o erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.ofs/erofs/data.c +4
-0@@ -475,6 +475,10 @@ static loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence)const struct file_operations erofs_file_fops = { .llseek = erofs_file_llseek, .read_iter = erofs_file_read_iter, + .unlocked_ioctl = erofs_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = erofs_compat_ioctl, +#endif .mmap_prepare = erofs_file_mmap_prepare, .get_unmapped_area = thp_get_unmapped_area, .splice_read = filemap_splice_read,fs/erofs/dir.c +4
-0@@ -123,4 +123,8 @@ const struct file_operations erofs_dir_fops = { .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = erofs_readdir, + .unlocked_ioctl = erofs_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = erofs_compat_ioctl, +#endif };fs/erofs/inode.c +1
-4@@ -213,10 +213,7 @@ static int erofs_fill_inode(struct inode *inode)switch (inode->i_mode &S_IFMT ) {case S_IFREG : inode->i_op = &erofs_generic_iops; -if (erofs_inode_is_data_compressed (vi->datalayout)) - inode->i_fop = &generic_ro_fops; -else - inode->i_fop = &erofs_file_fops; + inode->i_fop = &erofs_file_fops;break ;case S_IFDIR : inode->i_op = &erofs_dir_iops;fs/erofs/internal.h +0
-0
fs/erofs/internal.h struct erofs_sb_info { · line 170
Quoted 5 lines
fs/erofs/internal.h +2
-0@@ -166,6 +166,9 @@ struct erofs_sb_info {struct erofs_domain *domain;char *fsid;char *domain_id; + +/* volume name */
The comment is useless, just drop this line.
Quoted 21 lines
fs/erofs/internal.h +5
-0+char *volume_name; };#define EROFS_SB (sb) ((struct erofs_sb_info *)(sb)->s_fs_info)@@ -535,6 +538,10 @@ static inline struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev) {static inline void erofs_fscache_submit_bio (struct bio *bio) {}#endif +long erofs_ioctl (struct file *filp,unsigned int cmd,unsigned long arg); +long erofs_compat_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg); +#define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */ #endif /* __EROFS_INTERNAL_H */ fs/erofs/ioctl.c new file +0
-0
fs/erofs/ioctl.c line 8
Quoted 8 lines
fs/erofs/ioctl.c new file +8
-0@@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <linux/fs.h> +#include <linux/compat.h> +#include <linux/file.h> + +#include "internal.h" + +static int erofs_ioctl_get_volume_label (struct inode *inode,void __user *arg)
Can we just move these functions into inode.c instead?
Since there is no need to introduce a new file just for a few new lines.
Otherwise it looks good to me.
Thanks,
Gao Xiang
Quoted 146 lines
-----Original Message-----
From: Gao Xiang <[email protected]>
Sent: Monday, September 22, 2025 9:49 AM
To: Bo Liu (刘波)-浪潮信息 <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] erofs: Add support forFS_IOC_GETFSLABELQuoted 10 lines · Bo Liu
From: Bo Liu (OpenAnolis) <[email protected]>
Add support for reading to the erofs volume label from the
FS_IOC_GETFSLABELioctls.Signed-off-by Bo Liu (OpenAnolis) <[email protected]>---
v1:
https://lore.kernel.org/linux-erofs/63904ade56634923ba734dcdab3c45d0@i
Quoted 8 lines
nspur.com/T/#t
v2:
https://lore.kernel.org/linux-erofs/20250826103926.4424-1-liubo03@insp
ur.com/T/#uChanges since v2:
- remove unnecessary codeQuoted 6 lines
fs/erofs/Makefile | 2 +- fs/erofs/data.c | 4 ++++ fs/erofs/dir.c | 4 ++++ fs/erofs/inode.c | 5 +---- fs/erofs/internal.h | 7 +++++++ fs/erofs/ioctl.c | 41+++++++++++++++++++++++++++++++++++++++++
fs/erofs/data.c static loff_t erofs_file_llseek(struct file *file, loff_t
Quoted 22 lines
fs/erofs/super.c | 8 ++++++++ 7 files changed, 66 insertions(+), 5 deletions(-)create mode 100644
fs/erofs/ioctl.cfs/erofs/Makefile index renamed from fs/erofs/Makefile +0
-0
549abc424763..5be6cc4acc1c100644fs/erofs/Makefile +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_EROFS_FS) += erofs.o -erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o +erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o ioctl.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o zutil.o erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.o diff --git
a/fs/erofs/data.cb/fs/erofs/data.cindex3b1ba571c728..8ca29962a3dd100644fs/erofs/data.c +0
-0@@ -475,6 +475,10 @@ static loff_t erofs_file_llseek(struct file *file, loff_toffset, int whence)
Quoted 44 lines
fs/erofs/data.c +4
-0const struct file_operations erofs_file_fops = { .llseek = erofs_file_llseek, .read_iter = erofs_file_read_iter, + .unlocked_ioctl = erofs_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = erofs_compat_ioctl, +#endif .mmap_prepare = erofs_file_mmap_prepare, .get_unmapped_area = thp_get_unmapped_area, .splice_read = filemap_splice_read,fs/erofs/dir.c index renamed from fs/erofs/dir.c +0
-0
debf469ad6bd..32b4f5aa60c9100644fs/erofs/dir.c +4
-0@@ -123,4 +123,8 @@ const struct file_operations erofs_dir_fops = { .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = erofs_readdir, + .unlocked_ioctl = erofs_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = erofs_compat_ioctl, +#endif };fs/erofs/inode.c index renamed from fs/erofs/inode.c +0
-0
9a2f59721522..a7ec17eec4b2100644fs/erofs/inode.c +1
-4@@ -213,10 +213,7 @@ static int erofs_fill_inode(struct inode *inode)switch (inode->i_mode &S_IFMT ) {case S_IFREG : inode->i_op = &erofs_generic_iops; -if (erofs_inode_is_data_compressed (vi->datalayout)) - inode->i_fop = &generic_ro_fops; -else - inode->i_fop = &erofs_file_fops; + inode->i_fop = &erofs_file_fops;break ;case S_IFDIR : inode->i_op = &erofs_dir_iops;fs/erofs/internal.h index renamed from fs/erofs/internal.h +0
-0
4ccc5f0ee8df..311346a017a7100644fs/erofs/internal.h struct erofs_sb_info { · line 170
Quoted 5 lines
fs/erofs/internal.h +2
-0@@ -166,6 +166,9 @@ struct erofs_sb_info {struct erofs_domain *domain;char *fsid;char *domain_id; + +/* volume name */ The comment is useless, just drop this line.
fs/erofs/internal.h struct erofs_sb_info {
Quoted 5 lines
fs/erofs/internal.h +1
-1+char *volume_name; };#define EROFS_SB (sb) ((struct erofs_sb_info *)(sb)->s_fs_info) @@ -535,6 +538,10 @@ static inline struct bio *erofs_fscache_bio_alloc(struct
erofs_map_dev*mdev) {fs/erofs/internal.h
Quoted 8 lines
static inline void erofs_fscache_submit_bio(struct bio *bio) {} #endiffs/erofs/internal.h +4
-0+long erofs_ioctl (struct file *filp,unsigned int cmd,unsigned long +arg);long erofs_compat_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg); +#define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */
Quoted 7 lines
#endif /* __EROFS_INTERNAL_H */fs/erofs/ioctl.c new file +0
-0fs/erofs/ioctl.c line 7
Quoted 7 lines
fs/erofs/ioctl.c new file +7
-0@@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0-or-later #include <linux/fs.h> +#include <linux/compat.h> #include <linux/file.h> + +#include "internal.h" + +static int erofs_ioctl_get_volume_label (struct inode *inode,void +__user *arg)Can we just move these functions into
inode.cinstead?
Quoted 6 lines
Since there is no need to introduce a new file just for a few new lines.
Otherwise it looks good to me.
Thanks,
Gao Xiang
Thanks for your comments.
I will send the next version of the patch later.
Thanks,
Bo Liu