chiark / gitweb /
networkctl: port from libudev to sd-device
[elogind.git] / src / test / test-udev.c
index 7c011f81f774142162207ab6936c7f5ca05c9ce4..23b7faa93923089b4742a4b5870432bfc96ebbcd 100644 (file)
 ***/
 
 #include <stdio.h>
-#include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <ctype.h>
 #include <errno.h>
 #include <unistd.h>
-#include <grp.h>
 #include <sched.h>
 #include <sys/mount.h>
 #include <sys/signalfd.h>
 
 #include "missing.h"
+#include "selinux-util.h"
 #include "udev.h"
 #include "udev-util.h"
 
@@ -114,13 +110,12 @@ int main(int argc, char *argv[]) {
         rules = udev_rules_new(udev, 1);
 
         strscpyl(syspath, sizeof(syspath), "/sys", devpath, NULL);
-        dev = udev_device_new_from_syspath(udev, syspath);
+        dev = udev_device_new_from_synthetic_event(udev, syspath, action);
         if (dev == NULL) {
                 log_debug("unknown device '%s'", devpath);
                 goto out;
         }
 
-        udev_device_set_action(dev, action);
         event = udev_event_new(dev);
 
         sigfillset(&mask);
@@ -149,8 +144,14 @@ int main(int argc, char *argv[]) {
                 }
         }
 
-        udev_event_execute_rules(event, 3 * USEC_PER_SEC, USEC_PER_SEC, rules, &sigmask_orig);
-        udev_event_execute_run(event, 3 * USEC_PER_SEC, USEC_PER_SEC, NULL);
+        udev_event_execute_rules(event,
+                                 3 * USEC_PER_SEC, USEC_PER_SEC,
+                                 NULL,
+                                 rules,
+                                 &sigmask_orig);
+        udev_event_execute_run(event,
+                               3 * USEC_PER_SEC, USEC_PER_SEC,
+                               NULL);
 out:
         if (event != NULL && event->fd_signal >= 0)
                 close(event->fd_signal);