diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-08-14 09:15:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:51:01 -0400 |
commit | 7eff2e7a8b65c25920207324e56611150eb1cd9a (patch) | |
tree | 02a0eeba9d25d996233e30c18f258dfae0ae2139 /drivers/ide | |
parent | 8380770c842faef3001e44662953d64ad9a93663 (diff) |
Driver core: change add_uevent_var to use a struct
This changes the uevent buffer functions to use a struct instead of a
long list of parameters. It does no longer require the caller to do the
proper buffer termination and size accounting, which is currently wrong
in some places. It fixes a known bug where parts of the uevent
environment are overwritten because of wrong index calculations.
Many thanks to Mathieu Desnoyers for finding bugs and improving the
error handling.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index e96212ce5729..a96a8b1b3539 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -1663,20 +1663,13 @@ static struct device_attribute ide_dev_attrs[] = { | |||
1663 | __ATTR_NULL | 1663 | __ATTR_NULL |
1664 | }; | 1664 | }; |
1665 | 1665 | ||
1666 | static int ide_uevent(struct device *dev, char **envp, int num_envp, | 1666 | static int ide_uevent(struct device *dev, struct kobj_uevent_env *env) |
1667 | char *buffer, int buffer_size) | ||
1668 | { | 1667 | { |
1669 | ide_drive_t *drive = to_ide_device(dev); | 1668 | ide_drive_t *drive = to_ide_device(dev); |
1670 | int i = 0; | 1669 | |
1671 | int length = 0; | 1670 | add_uevent_var(env, "MEDIA=%s", media_string(drive)); |
1672 | 1671 | add_uevent_var(env, "DRIVENAME=%s", drive->name); | |
1673 | add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, | 1672 | add_uevent_var(env, "MODALIAS=ide:m-%s", media_string(drive)); |
1674 | "MEDIA=%s", media_string(drive)); | ||
1675 | add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, | ||
1676 | "DRIVENAME=%s", drive->name); | ||
1677 | add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, | ||
1678 | "MODALIAS=ide:m-%s", media_string(drive)); | ||
1679 | envp[i] = NULL; | ||
1680 | return 0; | 1673 | return 0; |
1681 | } | 1674 | } |
1682 | 1675 | ||