summaryrefslogtreecommitdiff
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2018-07-21 00:56:49 +0300
committerDavid S. Miller <davem@davemloft.net>2018-07-21 09:44:35 +0300
commitd028b6f703209dbe96201b2714ff46625877128e (patch)
tree8bf72328aa2e5d854f9dd63640f6ee5ec129a554 /lib/kobject.c
parent5f81880d5204ee2388fd9a75bb850ccd526885b7 (diff)
downloadlinux-d028b6f703209dbe96201b2714ff46625877128e.tar.xz
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 <dmitry.torokhov@gmail.com> Reviewed-by: Tyler Hicks <tyhicks@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index f2dc1f756007..389829d3a1d1 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,
};
/**