/* * udev_run_devd.c - directory multiplexer * * Copyright (C) 2005 Kay Sievers * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2 of the License. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include "../../udev_utils.h" #include "../../list.h" #include "../../logging.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, ...) { va_list args; static int udev_log = -1; if (udev_log == -1) { const char *value; value = getenv("UDEV_LOG"); if (value) udev_log = log_priority(value); else udev_log = LOG_ERR; } if (priority > udev_log) return; va_start(args, format); vsyslog(priority, format, args); va_end(args); } #endif int main(int argc, char *argv[], char *envp[]) { const char *subsystem; int fd; if (getenv("DEVNAME") == NULL) exit(0); subsystem = argv[1]; logging_init("udev_run_devd"); fd = open("/dev/null", O_RDWR); if (fd >= 0) { dup2(fd, STDOUT_FILENO); dup2(fd, STDIN_FILENO); dup2(fd, STDERR_FILENO); close(fd); } dbg("running dev.d directory"); run_directory("/etc/dev.d", ".dev", subsystem); exit(0); }