diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-07-20 17:56:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-21 02:44:35 -0400 |
commit | 9944e894c1266dc8515c82d1ff752d681215526b (patch) | |
tree | 38b9c8de3fb5c789d3e57f0f05cd4acbd075407b /drivers/base | |
parent | d028b6f703209dbe96201b2714ff46625877128e (diff) |
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 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) | |||
866 | return ns; | 866 | return ns; |
867 | } | 867 | } |
868 | 868 | ||
869 | static void device_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) | ||
870 | { | ||
871 | struct device *dev = kobj_to_dev(kobj); | ||
872 | |||
873 | if (dev->class && dev->class->get_ownership) | ||
874 | dev->class->get_ownership(dev, uid, gid); | ||
875 | } | ||
876 | |||
869 | static struct kobj_type device_ktype = { | 877 | static struct kobj_type device_ktype = { |
870 | .release = device_release, | 878 | .release = device_release, |
871 | .sysfs_ops = &dev_sysfs_ops, | 879 | .sysfs_ops = &dev_sysfs_ops, |
872 | .namespace = device_namespace, | 880 | .namespace = device_namespace, |
881 | .get_ownership = device_get_ownership, | ||
873 | }; | 882 | }; |
874 | 883 | ||
875 | 884 | ||