#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)
{
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);
#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, ...)
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");
}
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);
}
#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, ...)
int main(int argc, char *argv[], char *envp[])
{
+ char dirname[NAME_SIZE];
const char *subsystem;
int fd;
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);
}