summaryrefslogtreecommitdiff
path: root/extras/run_directory/udev_run_devd.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-06-05 05:11:29 +0200
committerKay Sievers <kay.sievers@suse.de>2005-06-05 05:11:29 +0200
commit6a522681e1438bbd9c317654cc35d5d206d378ad (patch)
tree8a580e47fcd69bd32c9cfb354c5e74e777519300 /extras/run_directory/udev_run_devd.c
parentc974742bf4d6d8fab1e1c90e2e57dae0a2f297a1 (diff)
udev: move dev.d/ handling to external helper
Modern rules are expected to call notification and postprocessing with the RUN key. For compatibility the current behavior can be emulated with an external helper. Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Diffstat (limited to 'extras/run_directory/udev_run_devd.c')
-rw-r--r--extras/run_directory/udev_run_devd.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/extras/run_directory/udev_run_devd.c b/extras/run_directory/udev_run_devd.c
new file mode 100644
index 0000000000..02bbc8c353
--- /dev/null
+++ b/extras/run_directory/udev_run_devd.c
@@ -0,0 +1,78 @@
+/*
+ * udev_run_devd.c - directory multiplexer
+ *
+ * Copyright (C) 2005 Kay Sievers <kay@vrfy.org>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+
+#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);
+}