chiark / gitweb /
add persistent-input.rules
[elogind.git] / udevcontrol.c
index f16f6a125ab40d96b1190f06ee1d4fe933a6638a..8add09e031ccd9dc313cb858e0a05163eb6d5b2c 100644 (file)
  *
  */
 
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <sys/un.h>
 #include <time.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stddef.h>
 #include <string.h>
 #include <unistd.h>
-#include <linux/stddef.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <sys/un.h>
 
 #include "udev.h"
-#include "udev_version.h"
 #include "udevd.h"
-#include "udev_utils.h"
-#include "logging.h"
 
 /* global variables */
 static int sock = -1;
-static int log = 0;
+static int udev_log = 0;
 
 #ifdef USE_LOG
 void log_message (int priority, const char *format, ...)
 {
        va_list args;
 
-       if (priority > log)
+       if (priority > udev_log)
                return;
 
        va_start(args, format);
@@ -69,7 +65,7 @@ int main(int argc, char *argv[], char *envp[])
 
        env = getenv("UDEV_LOG");
        if (env)
-               log = log_priority(env);
+               udev_log = log_priority(env);
 
        logging_init("udevcontrol");
        dbg("version %s", UDEV_VERSION);
@@ -89,6 +85,8 @@ int main(int argc, char *argv[], char *envp[])
                        usend_msg.type = UDEVD_STOP_EXEC_QUEUE;
                else if (!strcmp(arg, "start_exec_queue"))
                        usend_msg.type = UDEVD_START_EXEC_QUEUE;
+               else if (!strcmp(arg, "reload_rules"))
+                       usend_msg.type = UDEVD_RELOAD_RULES;
                else if (!strncmp(arg, "log_priority=", strlen("log_priority="))) {
                        intval = (int *) usend_msg.envbuf;
                        val = &arg[strlen("log_priority=")];
@@ -106,6 +104,7 @@ int main(int argc, char *argv[], char *envp[])
                                "  log_priority=<level> set the udev log level for the daemon\n"
                                "  stop_exec_queue      keep udevd from executing events, queue only\n"
                                "  start_exec_queue     execute events, flush queue\n"
+                               "  reload_rules         reloads the rules files\n"
                                "  max_childs=<N>       maximum number of childs running at the same time\n"
                                "  --help               print this help text\n\n");
                        exit(0);
@@ -122,7 +121,7 @@ int main(int argc, char *argv[], char *envp[])
 
        sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
        if (sock == -1) {
-               err("error getting socket");
+               err("error getting socket: %s", strerror(errno));
                goto exit;
        }
 
@@ -135,7 +134,7 @@ int main(int argc, char *argv[], char *envp[])
 
        retval = sendto(sock, &usend_msg, sizeof(usend_msg), 0, (struct sockaddr *)&saddr, addrlen);
        if (retval == -1) {
-               info("error sending message (%s)", strerror(errno));
+               err("error sending message: %s", strerror(errno));
                retval = 1;
        } else {
                dbg("sent message type=0x%02x, %u bytes sent", usend_msg.type, retval);