diff mbox series

[4/5] tmpfs: Expose filesystem features via sysfs

Message ID 20240823173332.281211-5-andrealmeid@igalia.com (mailing list archive)
State New
Headers show
Series tmpfs: Add case-insesitive support for tmpfs | expand

Commit Message

André Almeida Aug. 23, 2024, 5:33 p.m. UTC
Expose filesystem features through sysfs, so userspace can query if
tmpfs support casefold.

This follows the same setup as defined by ext4 and f2fs to expose
casefold support to userspace.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 mm/shmem.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

kernel test robot Aug. 26, 2024, 10:58 p.m. UTC | #1
Hi André,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.11-rc5 next-20240826]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/tmpfs-Add-casefold-lookup-support/20240826-135457
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240823173332.281211-5-andrealmeid%40igalia.com
patch subject: [PATCH 4/5] tmpfs: Expose filesystem features via sysfs
config: i386-randconfig-063-20240827 (https://download.01.org/0day-ci/archive/20240827/202408270618.4ue8oNhS-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240827/202408270618.4ue8oNhS-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/202408270618.4ue8oNhS-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> mm/shmem.c:5515:1: sparse: sparse: symbol 'dev_attr_casefold' was not declared. Should it be static?

vim +/dev_attr_casefold +5515 mm/shmem.c

  5512	
  5513	#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
  5514	#if IS_ENABLED(CONFIG_UNICODE)
> 5515	DEVICE_STRING_ATTR_RO(casefold, 0444, "supported");
  5516	#endif
  5517
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 5c77b4e73204..f6e19b88d647 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -5384,3 +5384,40 @@  struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
 	return page;
 }
 EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp);
+
+#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
+#if IS_ENABLED(CONFIG_UNICODE)
+DEVICE_STRING_ATTR_RO(casefold, 0444, "supported");
+#endif
+
+static struct attribute *tmpfs_attributes[] = {
+#if IS_ENABLED(CONFIG_UNICODE)
+	&dev_attr_casefold.attr.attr,
+#endif
+	NULL
+};
+
+static const struct attribute_group tmpfs_attribute_group = {
+	.attrs = tmpfs_attributes,
+	.name = "features"
+};
+
+static struct kobject *tmpfs_kobj;
+
+static int __init tmpfs_sysfs_init(void)
+{
+	int ret;
+
+	tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
+	if (!tmpfs_kobj)
+		return -ENOMEM;
+
+	ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
+	if (ret)
+		kobject_put(tmpfs_kobj);
+
+	return ret;
+}
+
+fs_initcall(tmpfs_sysfs_init);
+#endif /* CONFIG_SYSFS && CONFIG_TMPFS */