From eb6c7cd03635ffc28798734f0b87b9e21dae6f9e Mon Sep 17 00:00:00 2001 From: "trini@kernel.crashing.org" Date: Tue, 10 Aug 2004 00:50:21 -0700 Subject: [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 Signed-off-by: Greg Kroah-Hartman --- udev.c | 66 ++++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 24 deletions(-) (limited to 'udev.c') diff --git a/udev.c b/udev.c index cc6ce105..0ef4cf86 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(); } -- cgit 1.2.3-korg