summaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2013-04-06 18:56:00 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-08 17:21:48 +0200
commit3c2670e6515cf584810f417db9b00992c8b2d75a (patch)
treebc13c7babc6c8f08b6a82d0b3848778b264d9651 /drivers/base/core.c
parentsysfs: check if one entry has been removed before freeing (diff)
downloadlinux-3c2670e6515cf584810f417db9b00992c8b2d75a.tar.xz
linux-3c2670e6515cf584810f417db9b00992c8b2d75a.zip
driver core: add uid and gid to devtmpfs
Some drivers want to tell userspace what uid and gid should be used for their device nodes, so allow that information to percolate through the driver core to userspace in order to make this happen. This means that some systems (i.e. Android and friends) will not need to even run a udev-like daemon for their device node manager and can just rely in devtmpfs fully, reducing their footprint even more. Signed-off-by: Kay Sievers <kay@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a7391a30cb29..8a428b51089d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -283,15 +283,21 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
const char *tmp;
const char *name;
umode_t mode = 0;
+ uid_t uid = 0;
+ gid_t gid = 0;
add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt));
add_uevent_var(env, "MINOR=%u", MINOR(dev->devt));
- name = device_get_devnode(dev, &mode, &tmp);
+ name = device_get_devnode(dev, &mode, &uid, &gid, &tmp);
if (name) {
add_uevent_var(env, "DEVNAME=%s", name);
- kfree(tmp);
if (mode)
add_uevent_var(env, "DEVMODE=%#o", mode & 0777);
+ if (uid)
+ add_uevent_var(env, "DEVUID=%u", uid);
+ if (gid)
+ add_uevent_var(env, "DEVGID=%u", gid);
+ kfree(tmp);
}
}
@@ -1281,6 +1287,8 @@ static struct device *next_device(struct klist_iter *i)
* device_get_devnode - path of device node file
* @dev: device
* @mode: returned file access mode
+ * @uid: returned file owner
+ * @gid: returned file group
* @tmp: possibly allocated string
*
* Return the relative path of a possible device node.
@@ -1289,7 +1297,8 @@ static struct device *next_device(struct klist_iter *i)
* freed by the caller.
*/
const char *device_get_devnode(struct device *dev,
- umode_t *mode, const char **tmp)
+ umode_t *mode, uid_t *uid, gid_t *gid,
+ const char **tmp)
{
char *s;
@@ -1297,7 +1306,7 @@ const char *device_get_devnode(struct device *dev,
/* the device type may provide a specific name */
if (dev->type && dev->type->devnode)
- *tmp = dev->type->devnode(dev, mode);
+ *tmp = dev->type->devnode(dev, mode, uid, gid);
if (*tmp)
return *tmp;