summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2018-07-20 21:56:50 +0000
committerDavid S. Miller <davem@davemloft.net>2018-07-20 23:44:35 -0700
commit9944e894c1266dc8515c82d1ff752d681215526b (patch)
tree38b9c8de3fb5c789d3e57f0f05cd4acbd075407b /drivers/base
parentd028b6f703209dbe96201b2714ff46625877128e (diff)
downloadtalos-op-linux-9944e894c1266dc8515c82d1ff752d681215526b.tar.gz
talos-op-linux-9944e894c1266dc8515c82d1ff752d681215526b.zip
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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index df3e1a44707a..276c7e3f754c 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,
};
OpenPOWER on IntegriCloud