[PATCH 1/2] befs: Add FS_IOC_GETFSLABEL ioctl

Ethan Ferguson posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH 1/2] befs: Add FS_IOC_GETFSLABEL ioctl
Posted by Ethan Ferguson 1 month, 2 weeks ago
Add the FS_IOC_GETFSLABEL ioctl to the befs filesystem.

Signed-off-by: Ethan Ferguson <ethan.ferguson@zetier.com>
---
 fs/befs/befs.h     |  1 +
 fs/befs/linuxvfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/befs/super.c    |  1 +
 3 files changed, 48 insertions(+)

diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index 7cd47245694d..e4e2e9f4e307 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -30,6 +30,7 @@ struct befs_mount_options {
 };
 
 struct befs_sb_info {
+	char name[B_OS_NAME_LENGTH];
 	u32 magic1;
 	u32 block_size;
 	u32 block_shift;
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index d7c5d9270387..4850295e5fe0 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -64,6 +64,15 @@ static struct dentry *befs_fh_to_parent(struct super_block *sb,
 				struct fid *fid, int fh_len, int fh_type);
 static struct dentry *befs_get_parent(struct dentry *child);
 static void befs_free_fc(struct fs_context *fc);
+static int befs_ioctl_get_volume_label(struct super_block *sb,
+				       char __user *arg);
+static long befs_generic_ioctl(struct file *filp, unsigned int cmd,
+			       unsigned long arg);
+#ifdef CONFIG_COMPAT
+static long befs_generic_compat_ioctl(struct file *filp, unsigned int cmd,
+				      unsigned long arg);
+#endif
+
 
 static const struct super_operations befs_sops = {
 	.alloc_inode	= befs_alloc_inode,	/* allocate a new inode */
@@ -81,6 +90,10 @@ static const struct file_operations befs_dir_operations = {
 	.iterate_shared	= befs_readdir,
 	.llseek		= generic_file_llseek,
 	.setlease	= generic_setlease,
+	.unlocked_ioctl	= befs_generic_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= befs_generic_compat_ioctl,
+#endif
 };
 
 static const struct inode_operations befs_dir_inode_operations = {
@@ -940,6 +953,39 @@ befs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	return 0;
 }
 
+static int befs_ioctl_get_volume_label(struct super_block *sb, char __user *arg)
+{
+	struct befs_sb_info *sbi = BEFS_SB(sb);
+
+	if (copy_to_user(arg, sbi->name, B_OS_NAME_LENGTH))
+		return -EFAULT;
+
+	return 0;
+}
+
+static long befs_generic_ioctl(struct file *filp, unsigned int cmd,
+			       unsigned long arg)
+{
+	struct inode *inode = file_inode(filp);
+	char __user *user = (char __user *)arg;
+
+	switch (cmd) {
+	case FS_IOC_GETFSLABEL:
+		return befs_ioctl_get_volume_label(inode->i_sb, user);
+	default:
+		return -ENOTTY;
+	}
+}
+
+#ifdef CONFIG_COMPAT
+static long befs_generic_compat_ioctl(struct file *filp, unsigned int cmd,
+				      unsigned long arg)
+
+{
+	return befs_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static int befs_get_tree(struct fs_context *fc)
 {
 	return get_tree_bdev(fc, befs_fill_super);
diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c99d8..e6a13b497ac1 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -28,6 +28,7 @@ befs_load_sb(struct super_block *sb, befs_super_block *disk_sb)
 	else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE)
 		befs_sb->byte_order = BEFS_BYTESEX_BE;
 
+	memcpy(befs_sb->name, disk_sb->name, B_OS_NAME_LENGTH);
 	befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1);
 	befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2);
 	befs_sb->magic3 = fs32_to_cpu(sb, disk_sb->magic3);
-- 
2.43.0
Re: [PATCH 1/2] befs: Add FS_IOC_GETFSLABEL ioctl
Posted by kernel test robot 1 month, 2 weeks ago
Hi Ethan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 541c43310e85dbf35368b43b720c6724bc8ad8ec]

url:    https://github.com/intel-lab-lkp/linux/commits/Ethan-Ferguson/befs-Add-FS_IOC_GETFSLABEL-ioctl/20260213-071516
base:   541c43310e85dbf35368b43b720c6724bc8ad8ec
patch link:    https://lore.kernel.org/r/20260212231339.644714-2-ethan.ferguson%40zetier.com
patch subject: [PATCH 1/2] befs: Add FS_IOC_GETFSLABEL ioctl
config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20260213/202602131600.jVbNpmdD-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260213/202602131600.jVbNpmdD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602131600.jVbNpmdD-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/befs/linuxvfs.c:985:54: error: call to undeclared function 'compat_ptr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     985 |         return befs_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
         |                                                             ^
   1 error generated.


vim +/compat_ptr +985 fs/befs/linuxvfs.c

   979	
   980	#ifdef CONFIG_COMPAT
   981	static long befs_generic_compat_ioctl(struct file *filp, unsigned int cmd,
   982					      unsigned long arg)
   983	
   984	{
 > 985		return befs_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
   986	}
   987	#endif
   988	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 1/2] befs: Add FS_IOC_GETFSLABEL ioctl
Posted by kernel test robot 1 month, 2 weeks ago
Hi Ethan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 541c43310e85dbf35368b43b720c6724bc8ad8ec]

url:    https://github.com/intel-lab-lkp/linux/commits/Ethan-Ferguson/befs-Add-FS_IOC_GETFSLABEL-ioctl/20260213-071516
base:   541c43310e85dbf35368b43b720c6724bc8ad8ec
patch link:    https://lore.kernel.org/r/20260212231339.644714-2-ethan.ferguson%40zetier.com
patch subject: [PATCH 1/2] befs: Add FS_IOC_GETFSLABEL ioctl
config: sparc-randconfig-002-20260213 (https://download.01.org/0day-ci/archive/20260213/202602131301.1CCwgtrL-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 13.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260213/202602131301.1CCwgtrL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602131301.1CCwgtrL-lkp@intel.com/

All errors (new ones prefixed by >>):

   fs/befs/linuxvfs.c: In function 'befs_generic_compat_ioctl':
>> fs/befs/linuxvfs.c:985:61: error: implicit declaration of function 'compat_ptr' [-Werror=implicit-function-declaration]
     985 |         return befs_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
         |                                                             ^~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/compat_ptr +985 fs/befs/linuxvfs.c

   979	
   980	#ifdef CONFIG_COMPAT
   981	static long befs_generic_compat_ioctl(struct file *filp, unsigned int cmd,
   982					      unsigned long arg)
   983	
   984	{
 > 985		return befs_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
   986	}
   987	#endif
   988	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki