diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-07-20 21:56:50 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-20 23:44:35 -0700 |
commit | 9944e894c1266dc8515c82d1ff752d681215526b (patch) | |
tree | 38b9c8de3fb5c789d3e57f0f05cd4acbd075407b /drivers/base | |
parent | d028b6f703209dbe96201b2714ff46625877128e (diff) | |
download | op-kernel-dev-9944e894c1266dc8515c82d1ff752d681215526b.zip op-kernel-dev-9944e894c1266dc8515c82d1ff752d681215526b.tar.gz |
driver core: set up ownership of class devices in sysfs
Plumb in get_ownership() callback for devices belonging to a class so that
they can be created with uid/gid different from global root. This will
allow network devices in a container to belong to container's root and not
global root.
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 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index df3e1a4..276c7e3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -866,10 +866,19 @@ static const void *device_namespace(struct kobject *kobj) return ns; } +static void device_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) +{ + struct device *dev = kobj_to_dev(kobj); + + if (dev->class && dev->class->get_ownership) + dev->class->get_ownership(dev, uid, gid); +} + static struct kobj_type device_ktype = { .release = device_release, .sysfs_ops = &dev_sysfs_ops, .namespace = device_namespace, + .get_ownership = device_get_ownership, }; |