]> Git Repo - linux.git/blobdiff - lib/kobject.c
mm/sparse.c: make sparse_init_one_section void and remove check
[linux.git] / lib / kobject.c
index 18989b5b3b56b8b0b59836492606ec99fd3debbe..389829d3a1d1c8ff1c2b0bd529adcb8a2cc6c46a 100644 (file)
@@ -35,6 +35,25 @@ const void *kobject_namespace(struct kobject *kobj)
        return kobj->ktype->namespace(kobj);
 }
 
+/**
+ * kobject_get_ownership - get sysfs ownership data for @kobj
+ * @kobj: kobject in question
+ * @uid: kernel user ID for sysfs objects
+ * @gid: kernel group ID for sysfs objects
+ *
+ * Returns initial uid/gid pair that should be used when creating sysfs
+ * representation of given kobject. Normally used to adjust ownership of
+ * objects in a container.
+ */
+void kobject_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
+{
+       *uid = GLOBAL_ROOT_UID;
+       *gid = GLOBAL_ROOT_GID;
+
+       if (kobj->ktype->get_ownership)
+               kobj->ktype->get_ownership(kobj, uid, gid);
+}
+
 /*
  * populate_dir - populate directory with attributes.
  * @kobj: object we're working on.
@@ -868,9 +887,16 @@ static void kset_release(struct kobject *kobj)
        kfree(kset);
 }
 
+void kset_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
+{
+       if (kobj->parent)
+               kobject_get_ownership(kobj->parent, uid, gid);
+}
+
 static struct kobj_type kset_ktype = {
        .sysfs_ops      = &kobj_sysfs_ops,
-       .release = kset_release,
+       .release        = kset_release,
+       .get_ownership  = kset_get_ownership,
 };
 
 /**
This page took 0.030114 seconds and 4 git commands to generate.