aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sysfs.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-09-11 22:29:05 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 18:30:22 -0400
commite34ff4906199d2ebd248ae897ae34f52bea151c9 (patch)
tree2ae9507f68e08651b3f960de51b77a1d84e21453 /include/linux/sysfs.h
parent58292cbe6669d74498a5f08db13e57cb3bcfb81d (diff)
sysfs: remove ktype->namespace() invocations in directory code
For some unrecognizable reason, namespace information is communicated to sysfs through ktype->namespace() callback when there's *nothing* which needs the use of a callback. The whole sequence of operations is completely synchronous and sysfs operations simply end up calling back into the layer which just invoked it in order to find out the namespace information, which is completely backwards, obfuscates what's going on and unnecessarily tangles two separate layers. This patch doesn't remove ktype->namespace() but shifts its handling to kobject layer. We probably want to get rid of the callback in the long term. This patch adds an explicit param to sysfs_{create|rename|move}_dir() and renames them to sysfs_{create|rename|move}_dir_ns(), respectively. ktype->namespace() invocations are moved to the calling sites of the above functions. A new helper kboject_namespace() is introduced which directly tests kobj_ns_type_operations->type which should give the same result as testing sysfs_fs_type(parent_sd) and returns @kobj's namespace tag as necessary. kobject_namespace() is extern as it will be used from another file in the following patches. This patch should be an equivalent conversion without any functional difference. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Kay Sievers <kay@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/sysfs.h')
-rw-r--r--include/linux/sysfs.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 82f7fac78e77..7f56bad3be82 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -182,11 +182,13 @@ struct sysfs_dirent;
182int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), 182int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
183 void *data, struct module *owner); 183 void *data, struct module *owner);
184 184
185int __must_check sysfs_create_dir(struct kobject *kobj); 185int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
186void sysfs_remove_dir(struct kobject *kobj); 186void sysfs_remove_dir(struct kobject *kobj);
187int __must_check sysfs_rename_dir(struct kobject *kobj, const char *new_name); 187int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
188int __must_check sysfs_move_dir(struct kobject *kobj, 188 const void *new_ns);
189 struct kobject *new_parent_kobj); 189int __must_check sysfs_move_dir_ns(struct kobject *kobj,
190 struct kobject *new_parent_kobj,
191 const void *new_ns);
190 192
191int __must_check sysfs_create_file_ns(struct kobject *kobj, 193int __must_check sysfs_create_file_ns(struct kobject *kobj,
192 const struct attribute *attr, 194 const struct attribute *attr,
@@ -258,7 +260,7 @@ static inline int sysfs_schedule_callback(struct kobject *kobj,
258 return -ENOSYS; 260 return -ENOSYS;
259} 261}
260 262
261static inline int sysfs_create_dir(struct kobject *kobj) 263static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
262{ 264{
263 return 0; 265 return 0;
264} 266}
@@ -267,13 +269,15 @@ static inline void sysfs_remove_dir(struct kobject *kobj)
267{ 269{
268} 270}
269 271
270static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name) 272static inline int sysfs_rename_dir_ns(struct kobject *kobj,
273 const char *new_name, const void *new_ns)
271{ 274{
272 return 0; 275 return 0;
273} 276}
274 277
275static inline int sysfs_move_dir(struct kobject *kobj, 278static inline int sysfs_move_dir_ns(struct kobject *kobj,
276 struct kobject *new_parent_kobj) 279 struct kobject *new_parent_kobj,
280 const void *new_ns)
277{ 281{
278 return 0; 282 return 0;
279} 283}