- /* 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 blacklisted subsystems */
- 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);
-
- /* init rules, permissions */
- namedev_init();
-
- /* name, create node, store in db */
- retval = udev_add_device(&udev, class_dev);
-
- /* run dev.d/ scripts if we created a node or changed a netif name */
- if (udev.devname[0] != '\0') {
- setenv("DEVNAME", udev.devname, 1);
- dev_d_execute(&udev, DEVD_DIR, DEVD_SUFFIX);
- }
-
- sysfs_close_class_device(class_dev);
- } else if (strcmp(action, "remove") == 0) {
- /* possibly remove a node */
- dbg("udev remove");
-
- /* get node from db, remove db-entry, delete created node */
- retval = udev_remove_device(&udev);
-
- /* Set the DEVNAME if known */
- if (udev.devname[0] != '\0') {
- setenv("DEVNAME", udev.devname, 1);
- }
- /* run dev.d/ scripts if we're not instructed to ignore the event */
- if (udev.devname[0] != '\0') {
- setenv("DEVNAME", udev.devname, 1);
- dev_d_execute(&udev, DEVD_DIR, DEVD_SUFFIX);
- }