diff options
author | trini@kernel.crashing.org <trini@kernel.crashing.org> | 2004-08-10 00:50:21 -0700 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:36:59 -0700 |
commit | eb6c7cd03635ffc28798734f0b87b9e21dae6f9e (patch) | |
tree | 0bd2587399783c7fa82439772ae114bda931bb44 /udevstart.c | |
parent | 807755776d294a9811c0c8e835538e83abf734bc (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 'udevstart.c')
-rw-r--r-- | udevstart.c | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/udevstart.c b/udevstart.c index 3ecfd4cb61..d94c9501c9 100644 --- a/udevstart.c +++ b/udevstart.c @@ -36,25 +36,12 @@ #include "logging.h" #include "udev_lib.h" #include "list.h" - - -#ifdef LOG -unsigned char logname[LOGNAME_SIZE]; -void log_message(int level, const char *format, ...) -{ - va_list args; - - va_start(args, format); - vsyslog(level, format, args); - va_end(args); -} -#endif +#include "udev.h" #define MAX_PATHLEN 1024 #define SYSBLOCK "/sys/block" #define SYSCLASS "/sys/class" -#define UDEV_BIN "/sbin/udev" struct device { struct list_head list; @@ -88,28 +75,13 @@ static int device_list_insert(char *path, char *subsystem, struct list_head *dev static void udev_exec(const char *path, const char* subsystem) { - pid_t pid; - char action[] = "ACTION=add"; - char devpath[MAX_PATHLEN]; - char nosleep[] = "UDEV_NO_SLEEP=1"; - char *env[] = { action, devpath, nosleep, NULL }; - - strcpy(devpath, "DEVPATH="); - strfieldcat(devpath, path); - - pid = fork(); - switch (pid) { - case 0: - /* child */ - execle(UDEV_BIN, "udev", subsystem, NULL, env); - dbg("exec of child failed"); + /* Setup env variables. */ + setenv("UDEV_NO_SLEEP", "1", 1); + + /* Now call __udev_hotplug(). */ + if (__udev_hotplug("add", path, subsystem)) { + dbg("Calling of udev_hotplug failed"); exit(1); - break; - case -1: - dbg("fork of child failed"); - break; - default: - wait(NULL); } } @@ -267,12 +239,9 @@ static void udev_scan_class(void) exec_list(&device_list); } -int main(int argc, char *argv[], char *envp[]) +int udev_start(void) { - init_logging("udevstart"); - udev_scan_class(); udev_scan_block(); - return 0; } |