- main_argv = argv;
- setenv("DEVPATH", path, 1);
- setenv("ACTION", "add", 1);
- udev_add_device(path, subsys, fake);
+ /* set environment for callouts and dev.d/ */
+ setenv("DEVPATH", devpath, 1);
+ setenv("SUBSYSTEM", subsystem, 1);
+
+ 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;
+ }
+
+ udev_init_device(&udev, devpath, subsystem);
+ udev_add_device(&udev, class_dev);
+
+ /* run dev.d/ scripts if we created a node or changed a netif name */
+ if (udev_dev_d && udev.devname[0] != '\0') {
+ setenv("DEVNAME", udev.devname, 1);
+ udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
+ }
+
+ sysfs_close_class_device(class_dev);
+ udev_cleanup_device(&udev);
+
+ return 0;