- dbg("exec: '%s' (%s)\n", devpath, path);
-
- class_dev = sysfs_open_class_device_path(path);
- if (class_dev == NULL) {
- dbg ("sysfs_open_class_device_path failed");
- return -ENODEV;
+ /* clear and set environment for next event */
+ clearenv();
+ setenv("ACTION", "add", 1);
+ setenv("UDEV_START", "1", 1);
+ if (udev_log_str)
+ setenv("UDEV_LOG", udev_log_str, 1);
+ if (udev_run_str)
+ setenv("UDEV_RUN", udev_run_str, 1);
+
+ dev = sysfs_device_get(devpath);
+ if (dev == NULL)
+ return -1;
+
+ udev = udev_device_init();
+ if (udev == NULL)
+ return -1;
+
+ /* override built-in sysfs device */
+ udev->dev = dev;
+ strcpy(udev->action, "add");
+
+ if (strcmp(udev->dev->subsystem, "net") != 0) {
+ udev->devt = udev_device_get_devt(udev);
+ if (major(udev->devt) == 0)
+ return -1;