chiark / gitweb /
[PATCH] remove historical SYSFS_attr="value" format
[elogind.git] / udevstart.c
index c4ec0f7b7abd132399d7fc77f73e2f46d5db7c20..c1d877fb37dd42a85faff49f25ab931433fcbeb7 100644 (file)
@@ -92,27 +92,31 @@ static int add_device(char *devpath, char *subsystem)
        struct udevice udev;
        char path[SYSFS_PATH_MAX];
        struct sysfs_class_device *class_dev;
-       char *argv[3];
 
-       /* fake argument vector and environment for callouts and dev.d/ */
-       argv[0] = "udev";
-       argv[1] = subsystem;
-       argv[2] = NULL;
-
-       main_argv = argv;
+       /* set environment for callouts and dev.d/ */
        setenv("DEVPATH", devpath, 1);
-       setenv("ACTION", "add", 1);
+       setenv("SUBSYSTEM", subsystem, 1);
 
        snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, devpath);
+       path[SYSFS_PATH_MAX-1] = '\0';
        class_dev = sysfs_open_class_device_path(path);
        if (class_dev == NULL) {
                dbg ("sysfs_open_class_device_path failed");
                return -ENODEV;
        }
 
-       udev_set_values(&udev, devpath, subsystem);
+       udev_set_values(&udev, devpath, subsystem, "add");
+       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);
 
-       return udev_add_device(&udev, class_dev);
+       return 0;
 }
 
 static void exec_list(struct list_head *device_list)
@@ -285,7 +289,12 @@ static void udev_scan_class(void)
 
 int udev_start(void)
 {
+       /* set environment for callouts and dev.d/ */
+       setenv("ACTION", "add", 1);
+       setenv("UDEVSTART", "1", 1);
+
        udev_scan_class();
        udev_scan_block();
+
        return 0;
 }