Allow petitboot to run udevtrigger on start
[petitboot] / petitboot.c
index 84a76f62fc092903a35308ba899c12c24ed5ddae..d566e3ff188ff7dc8cf20d36b52545fe2e894205 100644 (file)
@@ -914,8 +914,35 @@ static void sigint(int sig)
        syscall(__NR_exit);
 }
 
        syscall(__NR_exit);
 }
 
+static void usage(const char *progname)
+{
+       fprintf(stderr, "Usage: %s [-u] [-h]\n", progname);
+}
+
 int main(int argc, char **argv)
 {
 int main(int argc, char **argv)
 {
+       int c;
+       int udev_trigger = 0;
+
+       for (;;) {
+               c = getopt(argc, argv, "u::h");
+               if (c == -1)
+                       break;
+
+               switch (c) {
+               case 'u':
+                       udev_trigger = 1;
+                       break;
+               case 'h':
+                       usage(argv[0]);
+                       return EXIT_SUCCESS;
+               default:
+                       fprintf(stderr, "Unknown option '%c'\n", c);
+                       usage(argv[0]);
+                       return EXIT_FAILURE;
+               }
+       }
+
        atexit(exitfunc);
        signal(SIGINT, sigint);
 
        atexit(exitfunc);
        signal(SIGINT, sigint);
 
@@ -956,7 +983,7 @@ int main(int argc, char **argv)
        twin_window_queue_paint(pboot_lpane->window);
        twin_window_queue_paint(pboot_rpane->window);
 
        twin_window_queue_paint(pboot_lpane->window);
        twin_window_queue_paint(pboot_rpane->window);
 
-       if (!pboot_start_device_discovery()) {
+       if (!pboot_start_device_discovery(udev_trigger)) {
                LOG("Couldn't start device discovery!\n");
                return 1;
        }
                LOG("Couldn't start device discovery!\n");
                return 1;
        }