aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/ksysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/ksysfs.c')
-rw-r--r--kernel/ksysfs.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 094e2bc101a8..cf02d4ba9add 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -94,8 +94,8 @@ static struct bin_attribute notes_attr = {
94 .read = &notes_read, 94 .read = &notes_read,
95}; 95};
96 96
97decl_subsys(kernel, NULL); 97struct kset *kernel_kset;
98EXPORT_SYMBOL_GPL(kernel_subsys); 98EXPORT_SYMBOL_GPL(kernel_kset);
99 99
100static struct attribute * kernel_attrs[] = { 100static struct attribute * kernel_attrs[] = {
101#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 101#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
@@ -116,24 +116,42 @@ static struct attribute_group kernel_attr_group = {
116 116
117static int __init ksysfs_init(void) 117static int __init ksysfs_init(void)
118{ 118{
119 int error = subsystem_register(&kernel_subsys); 119 int error;
120 if (!error)
121 error = sysfs_create_group(&kernel_subsys.kobj,
122 &kernel_attr_group);
123 120
124 if (!error && notes_size > 0) { 121 kernel_kset = kset_create_and_add("kernel", NULL, NULL);
122 if (!kernel_kset) {
123 error = -ENOMEM;
124 goto exit;
125 }
126 error = sysfs_create_group(&kernel_kset->kobj, &kernel_attr_group);
127 if (error)
128 goto kset_exit;
129
130 if (notes_size > 0) {
125 notes_attr.size = notes_size; 131 notes_attr.size = notes_size;
126 error = sysfs_create_bin_file(&kernel_subsys.kobj, 132 error = sysfs_create_bin_file(&kernel_kset->kobj, &notes_attr);
127 &notes_attr); 133 if (error)
134 goto group_exit;
128 } 135 }
129 136
130 /* 137 /*
131 * Create "/sys/kernel/uids" directory and corresponding root user's 138 * Create "/sys/kernel/uids" directory and corresponding root user's
132 * directory under it. 139 * directory under it.
133 */ 140 */
134 if (!error) 141 error = uids_kobject_init();
135 error = uids_kobject_init(); 142 if (error)
136 143 goto notes_exit;
144
145 return 0;
146
147notes_exit:
148 if (notes_size > 0)
149 sysfs_remove_bin_file(&kernel_kset->kobj, &notes_attr);
150group_exit:
151 sysfs_remove_group(&kernel_kset->kobj, &kernel_attr_group);
152kset_exit:
153 kset_unregister(kernel_kset);
154exit:
137 return error; 155 return error;
138} 156}
139 157