Allow petitboot to run udevtrigger on start
authorJeremy Kerr <jk@ozlabs.org>
Wed, 4 Apr 2007 05:54:42 +0000 (15:54 +1000)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 4 Apr 2007 05:54:42 +0000 (15:54 +1000)
Add an option (-u) to run udevtrigger when petitboot is ready for
device discovery. Also add -h to explain what -u does.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
devices.c
petitboot.c
petitboot.h

index 43a388dfbecd832da7098eea799bf285802838b7..4936f9ab2adfc515c61ff30a990dcc7cdcfea369 100644 (file)
--- a/devices.c
+++ b/devices.c
@@ -238,7 +238,7 @@ static twin_bool_t pboot_proc_server_sock(int sock, twin_file_op_t ops,
        return TWIN_TRUE;
 }
 
-int pboot_start_device_discovery(void)
+int pboot_start_device_discovery(int udev_trigger)
 {
        int sock;
        struct sockaddr_un addr;
@@ -269,6 +269,12 @@ int pboot_start_device_discovery(void)
 
        twin_set_file(pboot_proc_server_sock, sock, TWIN_READ, &_ctx);
 
+       if (udev_trigger) {
+               int rc = system("udevtrigger");
+               if (rc)
+                       LOG("udevtrigger failed, rc %d\n", rc);
+       }
+
        return TWIN_TRUE;
 }
 
index 84a76f62fc092903a35308ba899c12c24ed5ddae..d566e3ff188ff7dc8cf20d36b52545fe2e894205 100644 (file)
@@ -914,8 +914,35 @@ static void sigint(int sig)
        syscall(__NR_exit);
 }
 
+static void usage(const char *progname)
+{
+       fprintf(stderr, "Usage: %s [-u] [-h]\n", progname);
+}
+
 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);
 
@@ -956,7 +983,7 @@ int main(int argc, char **argv)
        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;
        }
index 147fe7f2d004bfa98a44c57bc35da4d48ecf2ea8..e9102df9504ee42f5fdab2f0d8fb7b0d9eb78482 100644 (file)
@@ -12,5 +12,5 @@ int pboot_add_option(int devindex, const char *title,
                     const char *subtitle, twin_pixmap_t *badge, void *data);
 int pboot_remove_device(const char *dev_id);
 
-int pboot_start_device_discovery(void);
+int pboot_start_device_discovery(int udev_trigger);
 void pboot_exec_option(void *data);