- switch(act_type) {
- case UDEVSTART:
- dbg("udevstart");
- udev_log = 0;
- namedev_init();
- retval = udev_start();
- break;
- case ADD:
- dbg("udev add");
-
- /* open the device */
- snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, udev.devpath);
- class_dev = sysfs_open_class_device_path(path);
- if (class_dev == NULL) {
- dbg ("sysfs_open_class_device_path failed");
- break;
- }
- dbg("opened class_dev->name='%s'", class_dev->name);
+ /* 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 || !subsystem || !devpath) {
+ dbg("action, subsystem or devpath missing");
+ 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 (udev.type == BLOCK || udev.type == CLASS || udev.type == NET) {
+ if (strcmp(action, "add") == 0) {
+ /* wait for sysfs and possibly add node */
+ dbg("udev add");