aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kobject.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 962175134702..85fb3a161b21 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -18,6 +18,24 @@
18#include <linux/stat.h> 18#include <linux/stat.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20 20
21/**
22 * kobject_namespace - return @kobj's namespace tag
23 * @kobj: kobject in question
24 *
25 * Returns namespace tag of @kobj if its parent has namespace ops enabled
26 * and thus @kobj should have a namespace tag associated with it. Returns
27 * %NULL otherwise.
28 */
29const void *kobject_namespace(struct kobject *kobj)
30{
31 const struct kobj_ns_type_operations *ns_ops = kobj_ns_ops(kobj);
32
33 if (!ns_ops || ns_ops->type == KOBJ_NS_TYPE_NONE)
34 return NULL;
35
36 return kobj->ktype->namespace(kobj);
37}
38
21/* 39/*
22 * populate_dir - populate directory with attributes. 40 * populate_dir - populate directory with attributes.
23 * @kobj: object we're working on. 41 * @kobj: object we're working on.
@@ -46,8 +64,9 @@ static int populate_dir(struct kobject *kobj)
46 64
47static int create_dir(struct kobject *kobj) 65static int create_dir(struct kobject *kobj)
48{ 66{
49 int error = 0; 67 int error;
50 error = sysfs_create_dir(kobj); 68
69 error = sysfs_create_dir_ns(kobj, kobject_namespace(kobj));
51 if (!error) { 70 if (!error) {
52 error = populate_dir(kobj); 71 error = populate_dir(kobj);
53 if (error) 72 if (error)
@@ -428,7 +447,7 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
428 goto out; 447 goto out;
429 } 448 }
430 449
431 error = sysfs_rename_dir(kobj, new_name); 450 error = sysfs_rename_dir_ns(kobj, new_name, kobject_namespace(kobj));
432 if (error) 451 if (error)
433 goto out; 452 goto out;
434 453
@@ -472,6 +491,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
472 if (kobj->kset) 491 if (kobj->kset)
473 new_parent = kobject_get(&kobj->kset->kobj); 492 new_parent = kobject_get(&kobj->kset->kobj);
474 } 493 }
494
475 /* old object path */ 495 /* old object path */
476 devpath = kobject_get_path(kobj, GFP_KERNEL); 496 devpath = kobject_get_path(kobj, GFP_KERNEL);
477 if (!devpath) { 497 if (!devpath) {
@@ -486,7 +506,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
486 sprintf(devpath_string, "DEVPATH_OLD=%s", devpath); 506 sprintf(devpath_string, "DEVPATH_OLD=%s", devpath);
487 envp[0] = devpath_string; 507 envp[0] = devpath_string;
488 envp[1] = NULL; 508 envp[1] = NULL;
489 error = sysfs_move_dir(kobj, new_parent); 509 error = sysfs_move_dir_ns(kobj, new_parent, kobject_namespace(kobj));
490 if (error) 510 if (error)
491 goto out; 511 goto out;
492 old_parent = kobj->parent; 512 old_parent = kobj->parent;