X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev.c;h=c26ce46b64ded246f87a5cca5f329a9a6421989f;hp=5dbade3c6f6dffb7cfb91f385944552090c459d3;hb=57e1a2770c4d85edd377488906c437f6d1e9b369;hpb=5ef42682053f57fc031d420f0a2ae3e204421b8d diff --git a/udev.c b/udev.c index 5dbade3c6..c26ce46b6 100644 --- a/udev.c +++ b/udev.c @@ -96,7 +96,6 @@ static void asmlinkage sig_handler(int signum) int main(int argc, char *argv[], char *envp[]) { - struct sigaction act; struct sysfs_class_device *class_dev; struct sysfs_device *devices_dev; struct udevice udev; @@ -106,6 +105,7 @@ int main(int argc, char *argv[], char *envp[]) const char *devpath; const char *subsystem; int managed_event; + struct sigaction act; int retval = -EINVAL; if (argc == 2 && strcmp(argv[1], "-V") == 0) { @@ -152,20 +152,11 @@ int main(int argc, char *argv[], char *envp[]) /* older kernels passed the SUBSYSTEM only as argument */ if (!subsystem && argc == 2) subsystem = argv[1]; - udev_init_device(&udev, devpath, subsystem); - if (!action) { - dbg("no action"); - goto hotplug; - } - - if (!subsystem) { - dbg("no subsystem"); - goto hotplug; - } + udev_init_device(&udev, devpath, subsystem); - if (!devpath) { - dbg("no devpath"); + if (!action || !subsystem || !devpath) { + dbg("action, subsystem or devpath missing"); goto hotplug; } @@ -173,7 +164,7 @@ int main(int argc, char *argv[], char *envp[]) if (udev_log) setenv("UDEV_LOG", "1", 1); - if ((strncmp(devpath, "/block/", 7) == 0) || (strncmp(devpath, "/class/", 7) == 0)) { + if (udev.type == BLOCK || udev.type == CLASS || udev.type == NET) { if (strcmp(action, "add") == 0) { /* wait for sysfs and possibly add node */ dbg("udev add"); @@ -221,7 +212,7 @@ int main(int argc, char *argv[], char *envp[]) if (udev_dev_d) udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX); } - } else if ((strncmp(devpath, "/devices/", 9) == 0)) { + } else if (udev.type == PHYSDEV) { if (strcmp(action, "add") == 0) { /* wait for sysfs */ dbg("devices add"); @@ -245,6 +236,7 @@ int main(int argc, char *argv[], char *envp[]) } hotplug: + udev_cleanup_device(&udev); if (udev_hotplug_d && managed_event) udev_multiplex_directory(&udev, HOTPLUGD_DIR, HOTPLUG_SUFFIX);