2 * udev_run_devd.c - directory multiplexer
4 * Copyright (C) 2005 Kay Sievers <kay@vrfy.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
21 #include <sys/types.h>
25 #include "../../udev.h"
26 #include "run_directory.h"
30 void log_message (int priority, const char *format, ...)
33 static int udev_log = -1;
38 value = getenv("UDEV_LOG");
40 udev_log = log_priority(value);
45 if (priority > udev_log)
48 va_start(args, format);
49 vsyslog(priority, format, args);
54 int main(int argc, char *argv[], char *envp[])
56 char dirname[NAME_SIZE];
58 const char *my_devname;
59 const char *subsystem;
62 devname = getenv("DEVNAME");
66 * Hack, we are assuming that the device nodes are in /dev,
67 * if not, this will not work, but you should be using the
70 my_devname = strstr(devname, "/dev/");
71 if (my_devname != NULL)
72 my_devname = &my_devname[5];
77 logging_init("udev_run_devd");
79 fd = open("/dev/null", O_RDWR);
81 dup2(fd, STDOUT_FILENO);
82 dup2(fd, STDIN_FILENO);
83 dup2(fd, STDERR_FILENO);
86 dbg("running dev.d directory");
88 sprintf(dirname, "/etc/dev.d/%s", my_devname);
89 run_directory(dirname, ".dev", subsystem);
90 sprintf(dirname, "/etc/dev.d/%s", subsystem);
91 run_directory(dirname, ".dev", subsystem);
92 run_directory("/etc/dev.d/default", ".dev", subsystem);