summaryrefslogtreecommitdiff
path: root/udev.c
diff options
context:
space:
mode:
authortrini@kernel.crashing.org <trini@kernel.crashing.org>2004-08-10 00:50:21 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:36:59 -0700
commiteb6c7cd03635ffc28798734f0b87b9e21dae6f9e (patch)
tree0bd2587399783c7fa82439772ae114bda931bb44 /udev.c
parent807755776d294a9811c0c8e835538e83abf734bc (diff)
[PATCH] Make udev/udevstart be one binary
Hi, The following patch makes udev/udevstart be a common binary. First, doing this grows udev by a total of 1.8kB (ppc32, stripped) whereas udevstart by itself is 6.4kB. I know you mentioned being able to replace udevstart with a script, but at 1.8kB I don't think it'll be easy to beat this with size there. Next, the following are by-eye timings of before, after, and with devfs on a slow, but still usable embedded platform (config stripped down to more-or-less bare for ramdisk): -- Embedded Planet RPX LITE, 64Mhz MPC 823e -- devfs : 15.333s, 15.253s, 14.988s (15.191s avg) udev-pristine : 18.675s, 18.079s, 18.418s (18.390s avg) udev-multi : 14.587s, 14.747s, 14.868s (14.734s avg) The patch ends up being rather large to add this, as in doing so I ended up making all refs (that I hit..) to devpath/subsystem be marked as 'const'. Signed-off-by: Tom Rini <trini@kernel.crashing.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'udev.c')
-rw-r--r--udev.c66
1 files changed, 42 insertions, 24 deletions
diff --git a/udev.c b/udev.c
index cc6ce10542..0ef4cf8657 100644
--- a/udev.c
+++ b/udev.c
@@ -40,6 +40,9 @@
char **main_argv;
char **main_envp;
+/* local variables */
+static int is_udevstart;
+
#ifdef LOG
unsigned char logname[LOGNAME_SIZE];
void log_message(int level, const char *format, ...)
@@ -76,27 +79,13 @@ static char *subsystem_blacklist[] = {
""
};
-static int udev_hotplug(void)
+int __udev_hotplug(char *action, const char *devpath, const char *subsystem)
{
- char *action;
- char *devpath;
- char *subsystem;
int retval = -EINVAL;
int i;
struct sigaction act;
const int nofake = 0;
- action = get_action();
- if (!action) {
- dbg("no action?");
- goto exit;
- }
-
- devpath = get_devpath();
- if (!devpath) {
- dbg("no devpath?");
- goto exit;
- }
dbg("looking at '%s'", devpath);
/* we only care about class devices and block stuff */
@@ -106,12 +95,6 @@ static int udev_hotplug(void)
goto exit;
}
- /* skip blacklisted subsystems */
- subsystem = get_subsystem(main_argv[1]);
- if (!subsystem) {
- dbg("no subsystem?");
- goto exit;
- }
i = 0;
while (subsystem_blacklist[i][0] != '\0') {
if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
@@ -136,7 +119,9 @@ static int udev_hotplug(void)
sigaction(SIGTERM, &act, NULL);
if (strcmp(action, "add") == 0) {
- namedev_init();
+ /* Already done. */
+ if (!is_udevstart)
+ namedev_init();
retval = udev_add_device(devpath, subsystem, nofake);
goto action_done;
}
@@ -156,17 +141,50 @@ exit:
return retval;
}
+static int udev_hotplug(void)
+{
+ char *action;
+ char *devpath;
+ char *subsystem;
+
+ action = get_action();
+ if (!action) {
+ dbg("no action?");
+ return -EINVAL;
+ }
+
+ devpath = get_devpath();
+ if (!devpath) {
+ dbg("no devpath?");
+ return -EINVAL;
+ }
+
+ /* skip blacklisted subsystems */
+ subsystem = get_subsystem(main_argv[1]);
+ if (!subsystem) {
+ dbg("no subsystem?");
+ return -EINVAL;
+ }
+
+ return __udev_hotplug(action, devpath, subsystem);
+}
+
int main(int argc, char *argv[], char *envp[])
{
main_argv = argv;
main_envp = envp;
- init_logging("udev");
+ if (strstr(argv[0], "udevstart"))
+ is_udevstart = 1;
/* initialize our configuration */
udev_init_config();
dbg("version %s", UDEV_VERSION);
- return udev_hotplug();
+ if (is_udevstart) {
+ namedev_init();
+ return udev_start();
+ } else
+ return udev_hotplug();
}