+ /* let the executed programs know if we handle the whole hotplug event */
+ managed_event = manage_hotplug_event();
+ if (managed_event)
+ setenv("MANAGED_EVENT", "1", 1);
+
+ action = getenv("ACTION");
+ devpath = getenv("DEVPATH");
+ subsystem = getenv("SUBSYSTEM");
+ /* 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;
+ }
+
+ if (!devpath) {
+ dbg("no devpath");
+ goto hotplug;
+ }
+
+ /* export logging flag, as called scripts may want to do the same as udev */
+ if (udev_log)
+ setenv("UDEV_LOG", "1", 1);
+
+ if ((strncmp(devpath, "/block/", 7) == 0) || (strncmp(devpath, "/class/", 7) == 0)) {
+ if (strcmp(action, "add") == 0) {
+ /* wait for sysfs and possibly add node */
+ dbg("udev add");
+
+ /* skip subsystems without "dev", but handle net devices */
+ if (udev.type != 'n' && subsystem_expect_no_dev(udev.subsystem)) {
+ dbg("don't care about '%s' devices", udev.subsystem);
+ goto hotplug;
+ }
+
+ snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, udev.devpath);
+ class_dev = wait_class_device_open(path);
+ if (class_dev == NULL) {
+ dbg ("open class device failed");
+ goto hotplug;
+ }
+ dbg("opened class_dev->name='%s'", class_dev->name);
+
+ wait_for_class_device(class_dev, &error);