From: Dmitry Torokhov Date: Fri, 20 Jul 2018 21:56:49 +0000 (+0000) Subject: kobject: kset_create_and_add() - fetch ownership info from parent X-Git-Tag: v4.19~410^2~307^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d028b6f703209dbe96201b2714ff46625877128e;p=platform%2Fkernel%2Flinux-rpi.git kobject: kset_create_and_add() - fetch ownership info from parent This change implements get_ownership() for ksets created with kset_create_and_add() call by fetching ownership data from parent kobject. This is done mostly for benefit of "queues" attribute of net devices so that corresponding directory belongs to container's root instead of global root for network devices in a container. Signed-off-by: Dmitry Torokhov Reviewed-by: Tyler Hicks Signed-off-by: David S. Miller --- diff --git a/lib/kobject.c b/lib/kobject.c index f2dc1f7..389829d 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -887,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, }; /**