Skip to content

Commit 5132f08

Browse files
andrealmeidbrauner
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Gabriel Krisman Bertazi <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 5cd9aec commit 5132f08

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

mm/shmem.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5546,3 +5546,40 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
55465546
return page;
55475547
}
55485548
EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp);
5549+
5550+
#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
5551+
#if IS_ENABLED(CONFIG_UNICODE)
5552+
static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported");
5553+
#endif
5554+
5555+
static struct attribute *tmpfs_attributes[] = {
5556+
#if IS_ENABLED(CONFIG_UNICODE)
5557+
&dev_attr_casefold.attr.attr,
5558+
#endif
5559+
NULL
5560+
};
5561+
5562+
static const struct attribute_group tmpfs_attribute_group = {
5563+
.attrs = tmpfs_attributes,
5564+
.name = "features"
5565+
};
5566+
5567+
static struct kobject *tmpfs_kobj;
5568+
5569+
static int __init tmpfs_sysfs_init(void)
5570+
{
5571+
int ret;
5572+
5573+
tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
5574+
if (!tmpfs_kobj)
5575+
return -ENOMEM;
5576+
5577+
ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
5578+
if (ret)
5579+
kobject_put(tmpfs_kobj);
5580+
5581+
return ret;
5582+
}
5583+
5584+
fs_initcall(tmpfs_sysfs_init);
5585+
#endif /* CONFIG_SYSFS && CONFIG_TMPFS */

0 commit comments

Comments
 (0)