chiark / gitweb /
rule-generator: net - whitelist NICs that violate MAC local scheme
[elogind.git] / udev / udevadm-settle.c
index 54f905bf6ff1c2165b4421c5a87f7e4631aec0e4..1c3c28176b98fcea62f9e3a723ae9fb02f3e37e0 100644 (file)
@@ -1,5 +1,7 @@
 /*
  * Copyright (C) 2006-2008 Kay Sievers <kay@vrfy.org>
+ * Copyright (C) 2009 Canonical Ltd.
+ * Copyright (C) 2009 Scott James Remnant <scott@netsplit.com>
  *
  * 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
@@ -41,6 +43,8 @@ static void asmlinkage sig_handler(int signum)
        switch (signum) {
                case SIGALRM:
                        is_timeout = 1;
+               case SIGUSR1:
+                       ;
        }
 }
 
@@ -70,6 +74,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
        sigemptyset (&act.sa_mask);
        act.sa_flags = 0;
        sigaction(SIGALRM, &act, NULL);
+       sigaction(SIGUSR1, &act, NULL);
 
        while (1) {
                int option;
@@ -148,6 +153,24 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
                }
        }
 
+       /* guarantee that the udev daemon isn't pre-processing */
+       if (getuid() == 0) {
+               struct udev_ctrl *uctrl;
+
+               uctrl = udev_ctrl_new_from_socket(udev, UDEV_CTRL_SOCK_PATH);
+               if (uctrl != NULL) {
+                       sigset_t mask, oldmask;
+
+                       sigemptyset(&mask);
+                       sigaddset(&mask, SIGUSR1);
+                       sigaddset(&mask, SIGALRM);
+                       sigprocmask(SIG_BLOCK, &mask, &oldmask);
+                       if (udev_ctrl_send_settle(uctrl) > 0)
+                               sigsuspend(&oldmask);
+                       udev_ctrl_unref(uctrl);
+               }
+       }
+
        while (!is_timeout) {
                /* exit if queue is empty */
                if (udev_queue_get_queue_is_empty(udev_queue))