diff options
author | André Almeida <andrealmeid@igalia.com> | 2024-10-21 13:37:24 -0300 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-10-28 13:36:55 +0100 |
commit | 5132f08bd3325602f4de01ccd59537c7f91e1f89 (patch) | |
tree | bed9cf4cd17dd8bbd52d17be1fa8dd1e9d09e709 /mm/shmem.c | |
parent | 5cd9aecbc72c07e8b83e900078669a7d0bc5f98f (diff) | |
download | lwn-5132f08bd3325602f4de01ccd59537c7f91e1f89.tar.gz lwn-5132f08bd3325602f4de01ccd59537c7f91e1f89.zip |
tmpfs: Expose filesystem features via sysfs
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>
Link: https://lore.kernel.org/r/20241021-tonyk-tmpfs-v8-8-f443d5814194@igalia.com
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index ea01628e4434..0739143d1419 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5546,3 +5546,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) +static 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 */ |