]> Pileus Git - ~andy/linux/blobdiff - lib/kobject.c
sysfs: drop kobj_ns_type handling, take #2
[~andy/linux] / lib / kobject.c
index 5b4b8886435ec77c7f51ff0221b3bc01558e5798..16e9335b32d392c4690d4ae81f95914e0565b732 100644 (file)
@@ -65,13 +65,17 @@ static int populate_dir(struct kobject *kobj)
 
 static int create_dir(struct kobject *kobj)
 {
+       const struct kobj_ns_type_operations *ops;
        int error;
 
        error = sysfs_create_dir_ns(kobj, kobject_namespace(kobj));
-       if (!error) {
-               error = populate_dir(kobj);
-               if (error)
-                       sysfs_remove_dir(kobj);
+       if (error)
+               return error;
+
+       error = populate_dir(kobj);
+       if (error) {
+               sysfs_remove_dir(kobj);
+               return error;
        }
 
        /*
@@ -80,7 +84,20 @@ static int create_dir(struct kobject *kobj)
         */
        sysfs_get(kobj->sd);
 
-       return error;
+       /*
+        * If @kobj has ns_ops, its children need to be filtered based on
+        * their namespace tags.  Enable namespace support on @kobj->sd.
+        */
+       ops = kobj_child_ns_ops(kobj);
+       if (ops) {
+               BUG_ON(ops->type <= KOBJ_NS_TYPE_NONE);
+               BUG_ON(ops->type >= KOBJ_NS_TYPES);
+               BUG_ON(!kobj_ns_type_registered(ops->type));
+
+               sysfs_enable_ns(kobj->sd);
+       }
+
+       return 0;
 }
 
 static int get_kobj_path_length(struct kobject *kobj)