Really commit the udev_run_devd changes...

This commit is contained in:
Greg KH 2005-07-14 15:24:59 -07:00 committed by Greg Kroah-Hartman
parent 78e21e3ed4
commit 04b90b7e25
3 changed files with 30 additions and 19 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}