@@ -5126,6 +5126,66 @@ static struct file_system_type shmem_fs_type = {
5126
5126
.fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP ,
5127
5127
};
5128
5128
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
+
5129
5189
void __init shmem_init (void )
5130
5190
{
5131
5191
int error ;
@@ -5149,6 +5209,14 @@ void __init shmem_init(void)
5149
5209
goto out1 ;
5150
5210
}
5151
5211
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
+
5152
5220
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
5153
5221
if (has_transparent_hugepage () && shmem_huge > SHMEM_HUGE_DENY )
5154
5222
SHMEM_SB (shm_mnt -> mnt_sb )-> huge = shmem_huge ;
@@ -5546,40 +5614,3 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
5546
5614
return page ;
5547
5615
}
5548
5616
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