From: Greg KH Date: Thu, 14 Jul 2005 22:24:59 +0000 (-0700) Subject: Really commit the udev_run_devd changes... X-Git-Tag: 064~13 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04b90b7e256762bb6eecf0567ca33ceec03621f5;p=systemd Really commit the udev_run_devd changes... --- diff --git a/extras/run_directory/run_directory.c b/extras/run_directory/run_directory.c index e6c6173e..770d8d84 100644 --- a/extras/run_directory/run_directory.c +++ b/extras/run_directory/run_directory.c @@ -25,8 +25,7 @@ #include "../../udev_utils.h" #include "../../list.h" #include "../../logging.h" - -int run_directory(const char *dir, const char *suffix, const char *subsystem); +#include "run_directory.h" static int run_program(const char *filename, const char *subsystem) { @@ -53,21 +52,11 @@ static int run_program(const char *filename, const char *subsystem) int run_directory(const char *dir, const char *suffix, const char *subsystem) { - char dirname[NAME_SIZE]; struct name_entry *name_loop, *name_tmp; LIST_HEAD(name_list); - if (subsystem) { - snprintf(dirname, sizeof(dirname), "%s/%s", dir, subsystem); - dirname[sizeof(dirname)-1] = '\0'; - dbg("looking at '%s'", dirname); - add_matching_files(&name_list, dirname, suffix); - } - - snprintf(dirname, sizeof(dirname), "%s/default", dir); - dirname[sizeof(dirname)-1] = '\0'; - dbg("looking at '%s'", dirname); - add_matching_files(&name_list, dirname, suffix); + dbg("looking at '%s'", dir); + add_matching_files(&name_list, dir, suffix); list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) { run_program(name_loop->name, subsystem); diff --git a/extras/run_directory/udev_run_devd.c b/extras/run_directory/udev_run_devd.c index 02bbc8c3..e708de8a 100644 --- a/extras/run_directory/udev_run_devd.c +++ b/extras/run_directory/udev_run_devd.c @@ -25,8 +25,8 @@ #include "../../udev_utils.h" #include "../../list.h" #include "../../logging.h" +#include "run_directory.h" -extern int run_directory(const char *dir, const char *suffix, const char *subsystem); #ifdef USE_LOG void log_message (int priority, const char *format, ...) @@ -55,11 +55,25 @@ void log_message (int priority, const char *format, ...) int main(int argc, char *argv[], char *envp[]) { + char dirname[NAME_SIZE]; + const char *devname; + const char *my_devname; const char *subsystem; int fd; - if (getenv("DEVNAME") == NULL) + devname = getenv("DEVNAME"); + if (devname == NULL) exit(0); + /* + * Hack, we are assuming that the device nodes are in /dev, + * if not, this will not work, but you should be using the + * RUN= rule anyway... + */ + my_devname = strstr(devname, "/dev/"); + if (my_devname != NULL) + my_devname = &my_devname[5]; + else + my_devname = devname; subsystem = argv[1]; logging_init("udev_run_devd"); @@ -73,6 +87,11 @@ int main(int argc, char *argv[], char *envp[]) } dbg("running dev.d directory"); - run_directory("/etc/dev.d", ".dev", subsystem); + sprintf(dirname, "/etc/dev.d/%s", my_devname); + run_directory(dirname, ".dev", subsystem); + sprintf(dirname, "/etc/dev.d/%s", subsystem); + run_directory(dirname, ".dev", subsystem); + run_directory("/etc/dev.d/default", ".dev", subsystem); + exit(0); } diff --git a/extras/run_directory/udev_run_hotplugd.c b/extras/run_directory/udev_run_hotplugd.c index 54b6bf44..a21835ae 100644 --- a/extras/run_directory/udev_run_hotplugd.c +++ b/extras/run_directory/udev_run_hotplugd.c @@ -25,8 +25,8 @@ #include "../../udev_utils.h" #include "../../list.h" #include "../../logging.h" +#include "run_directory.h" -extern int run_directory(const char *dir, const char *suffix, const char *subsystem); #ifdef USE_LOG void log_message (int priority, const char *format, ...) @@ -55,6 +55,7 @@ void log_message (int priority, const char *format, ...) int main(int argc, char *argv[], char *envp[]) { + char dirname[NAME_SIZE]; const char *subsystem; int fd; @@ -71,6 +72,8 @@ int main(int argc, char *argv[], char *envp[]) dbg("running dev.d directory"); - run_directory("/etc/hotplug.d", ".hotplug", subsystem); + sprintf(dirname, "/etc/hotplug.d/%s", subsystem); + run_directory(dirname, ".hotplug", subsystem); + run_directory("/etc/hotplug.d/default", ".hotplug", subsystem); exit(0); }