Skip to content

Commit 552b151

Browse files
committed
Merge patch series "tmpfs: Casefold fixes"
André Almeida <[email protected]> says: After casefold support for tmpfs was merged into vfs tree, two warnings were reported and I also found a small fix in the code. Thanks Nathan Chancellor and Stephen Rothwell! * patches from https://lore.kernel.org/r/[email protected]: tmpfs: Initialize sysfs during tmpfs init tmpfs: Fix type for sysfs' casefold attribute libfs: Fix kernel-doc warning in generic_ci_validate_strict_name Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 9c8f520 + 65c481f commit 552b151

File tree

2 files changed

+73
-42
lines changed

2 files changed

+73
-42
lines changed

include/linux/fs.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,12 +3477,12 @@ int generic_ci_d_compare(const struct dentry *dentry, unsigned int len,
34773477
* @name: name of the new file
34783478
*
34793479
* Return:
3480-
* * True if the filename is suitable for this directory. It can be
3481-
* true if a given name is not suitable for a strict encoding
3482-
* directory, but the directory being used isn't strict
3480+
* * True: if the filename is suitable for this directory. It can be
3481+
* true if a given name is not suitable for a strict encoding
3482+
* directory, but the directory being used isn't strict
34833483
* * False if the filename isn't suitable for this directory. This only
3484-
* happens when a directory is casefolded and the filesystem is strict
3485-
* about its encoding.
3484+
* happens when a directory is casefolded and the filesystem is strict
3485+
* about its encoding.
34863486
*/
34873487
static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name)
34883488
{

mm/shmem.c

Lines changed: 68 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5126,6 +5126,66 @@ static struct file_system_type shmem_fs_type = {
51265126
.fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP,
51275127
};
51285128

5129+
#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
5130+
5131+
#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \
5132+
{ \
5133+
.attr = { .name = __stringify(_name), .mode = _mode }, \
5134+
.show = _show, \
5135+
.store = _store, \
5136+
}
5137+
5138+
#define TMPFS_ATTR_W(_name, _store) \
5139+
static struct kobj_attribute tmpfs_attr_##_name = \
5140+
__INIT_KOBJ_ATTR(_name, 0200, NULL, _store)
5141+
5142+
#define TMPFS_ATTR_RW(_name, _show, _store) \
5143+
static struct kobj_attribute tmpfs_attr_##_name = \
5144+
__INIT_KOBJ_ATTR(_name, 0644, _show, _store)
5145+
5146+
#define TMPFS_ATTR_RO(_name, _show) \
5147+
static struct kobj_attribute tmpfs_attr_##_name = \
5148+
__INIT_KOBJ_ATTR(_name, 0444, _show, NULL)
5149+
5150+
#if IS_ENABLED(CONFIG_UNICODE)
5151+
static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *a,
5152+
char *buf)
5153+
{
5154+
return sysfs_emit(buf, "supported\n");
5155+
}
5156+
TMPFS_ATTR_RO(casefold, casefold_show);
5157+
#endif
5158+
5159+
static struct attribute *tmpfs_attributes[] = {
5160+
#if IS_ENABLED(CONFIG_UNICODE)
5161+
&tmpfs_attr_casefold.attr,
5162+
#endif
5163+
NULL
5164+
};
5165+
5166+
static const struct attribute_group tmpfs_attribute_group = {
5167+
.attrs = tmpfs_attributes,
5168+
.name = "features"
5169+
};
5170+
5171+
static struct kobject *tmpfs_kobj;
5172+
5173+
static int __init tmpfs_sysfs_init(void)
5174+
{
5175+
int ret;
5176+
5177+
tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
5178+
if (!tmpfs_kobj)
5179+
return -ENOMEM;
5180+
5181+
ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
5182+
if (ret)
5183+
kobject_put(tmpfs_kobj);
5184+
5185+
return ret;
5186+
}
5187+
#endif /* CONFIG_SYSFS && CONFIG_TMPFS */
5188+
51295189
void __init shmem_init(void)
51305190
{
51315191
int error;
@@ -5149,6 +5209,14 @@ void __init shmem_init(void)
51495209
goto out1;
51505210
}
51515211

5212+
#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
5213+
error = tmpfs_sysfs_init();
5214+
if (error) {
5215+
pr_err("Could not init tmpfs sysfs\n");
5216+
goto out1;
5217+
}
5218+
#endif
5219+
51525220
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
51535221
if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY)
51545222
SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
@@ -5546,40 +5614,3 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
55465614
return page;
55475615
}
55485616
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)