summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg KH <gregkh@suse.de>2005-07-14 15:24:59 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2005-07-14 15:24:59 -0700
commit04b90b7e256762bb6eecf0567ca33ceec03621f5 (patch)
treeac109967fba5fffae7cef88874a6e2b8bf705bc4
parent78e21e3ed4a038a8aa358eb109b6029ca9c3cdd1 (diff)
Really commit the udev_run_devd changes...
-rw-r--r--extras/run_directory/run_directory.c17
-rw-r--r--extras/run_directory/udev_run_devd.c25
-rw-r--r--extras/run_directory/udev_run_hotplugd.c7
3 files changed, 30 insertions, 19 deletions
diff --git a/extras/run_directory/run_directory.c b/extras/run_directory/run_directory.c
index e6c6173eca..770d8d84a1 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 02bbc8c353..e708de8aa4 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 54b6bf44e3..a21835ae4e 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);
}