Commit c422d217 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

driver core: added location of device in driverfs tree to /sbin/hotplug call.

/sbin/hotplug is now called when any device is added or removed from the
system.
parent 40fb1fcc
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include "base.h" #include "base.h"
#include "fs/fs.h"
/* /*
* hotplugging invokes what /proc/sys/kernel/hotplug says (normally * hotplugging invokes what /proc/sys/kernel/hotplug says (normally
...@@ -32,14 +33,16 @@ ...@@ -32,14 +33,16 @@
int dev_hotplug (struct device *dev, const char *action) int dev_hotplug (struct device *dev, const char *action)
{ {
char *argv [3], **envp, *buffer, *scratch; char *argv [3], **envp, *buffer, *scratch;
char *dev_path;
int retval; int retval;
int i = 0; int i = 0;
int dev_length;
pr_debug ("%s\n", __FUNCTION__); pr_debug ("%s\n", __FUNCTION__);
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
if (!dev->bus || !dev->bus->hotplug) if (!dev->bus)
return -ENODEV; return -ENODEV;
if (!hotplug_path [0]) if (!hotplug_path [0])
...@@ -66,6 +69,18 @@ int dev_hotplug (struct device *dev, const char *action) ...@@ -66,6 +69,18 @@ int dev_hotplug (struct device *dev, const char *action)
return -ENOMEM; return -ENOMEM;
} }
dev_length = get_devpath_length (dev);
dev_length += strlen("root");
dev_path = kmalloc (dev_length, GFP_KERNEL);
if (!dev_path) {
kfree (buffer);
kfree (envp);
return -ENOMEM;
}
memset (dev_path, 0x00, dev_length);
strcpy (dev_path, "root");
fill_devpath (dev, dev_path, dev_length);
/* only one standardized param to hotplug command: the bus name */ /* only one standardized param to hotplug command: the bus name */
argv [0] = hotplug_path; argv [0] = hotplug_path;
argv [1] = dev->bus->name; argv [1] = dev->bus->name;
...@@ -77,26 +92,33 @@ int dev_hotplug (struct device *dev, const char *action) ...@@ -77,26 +92,33 @@ int dev_hotplug (struct device *dev, const char *action)
scratch = buffer; scratch = buffer;
/* action: add, remove */
envp [i++] = scratch; envp [i++] = scratch;
scratch += sprintf (scratch, "ACTION=%s", action) + 1; scratch += sprintf (scratch, "ACTION=%s", action) + 1;
/* have the bus specific function set up the rest of the environment */ envp [i++] = scratch;
scratch += sprintf (scratch, "DEVICE=%s", dev_path) + 1;
if (dev->bus->hotplug) {
/* have the bus specific function add its stuff */
retval = dev->bus->hotplug (dev, &envp[i], NUM_ENVP - i, retval = dev->bus->hotplug (dev, &envp[i], NUM_ENVP - i,
scratch, BUFFER_SIZE - (scratch - buffer)); scratch,
BUFFER_SIZE - (scratch - buffer));
if (retval) { if (retval) {
pr_debug ("%s - hotplug() returned %d\n", __FUNCTION__, retval); pr_debug ("%s - hotplug() returned %d\n",
__FUNCTION__, retval);
goto exit; goto exit;
} }
}
pr_debug ("%s: %s %s %s %s %s %s\n", __FUNCTION__, argv [0], argv[1], pr_debug ("%s: %s %s %s %s %s %s\n", __FUNCTION__, argv [0], argv[1],
action, envp[0], envp[1], envp[2]); envp[0], envp[1], envp[2], envp[3]);
retval = call_usermodehelper (argv [0], argv, envp); retval = call_usermodehelper (argv [0], argv, envp);
if (retval) if (retval)
pr_debug ("%s - call_usermodehelper returned %d\n", pr_debug ("%s - call_usermodehelper returned %d\n",
__FUNCTION__, retval); __FUNCTION__, retval);
exit: exit:
kfree (dev_path);
kfree (buffer); kfree (buffer);
kfree (envp); kfree (envp);
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment