From: kay.sievers@vrfy.org Date: Sat, 2 Apr 2005 22:29:05 +0000 (+0200) Subject: [PATCH] export DEVNAME to RUN-key executed programs X-Git-Tag: 057~10 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=81af4e0519498fdbf75ad1e4250bfa3278262bde [PATCH] export DEVNAME to RUN-key executed programs --- diff --git a/udev.8.in b/udev.8.in index 4beab0d35..3527d6912 100644 --- a/udev.8.in +++ b/udev.8.in @@ -314,7 +314,7 @@ The name of a program must have the suffix .I .dev to be recognized. .br -In addition to the hotplug environment variables, +In addition to the kernel provided hotplug environment variables, .B UDEV_LOG is set and contains the numerical priority value, if udev is configured to use .BR syslog (3). diff --git a/udev.c b/udev.c index 5728be59e..ce9b42f30 100644 --- a/udev.c +++ b/udev.c @@ -204,6 +204,9 @@ int main(int argc, char *argv[], char *envp[]) retval = udev_remove_device(&udev); } + if (udev.devname[0] != '\0') + setenv("DEVNAME", udev.devname, 1); + if (udev_run && !list_empty(&udev.run_list)) { struct name_entry *name_loop; @@ -213,11 +216,9 @@ int main(int argc, char *argv[], char *envp[]) } /* run dev.d/ scripts if we created/deleted a node or changed a netif name */ - if (udev.devname[0] != '\0') { - setenv("DEVNAME", udev.devname, 1); - if (udev_dev_d) - udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX); - } + if (udev_dev_d && udev.devname[0] != '\0') + udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX); + } else if (udev.type == DEV_DEVICE) { if (strcmp(action, "add") == 0) { /* wait for sysfs */ diff --git a/udevstart.c b/udevstart.c index d41702efd..60e63c5ad 100644 --- a/udevstart.c +++ b/udevstart.c @@ -126,6 +126,9 @@ static int add_device(const char *path, const char *subsystem) udev_init_device(&udev, devpath, subsystem, "add"); udev_add_device(&udev, class_dev); + if (udev.devname[0] != '\0') + setenv("DEVNAME", udev.devname, 1); + if (udev_run && !list_empty(&udev.run_list)) { struct name_entry *name_loop; @@ -135,10 +138,8 @@ static int add_device(const char *path, const char *subsystem) } /* 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); + if (udev_dev_d && udev.devname[0] != '\0') udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX); - } sysfs_close_class_device(class_dev); udev_cleanup_device(&udev);