X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fpb-discover.c;h=9330da6129e7ad6165fe29fb3899d897804a228f;hp=536f6e65a7b34a88a916417f553eb7414a5773f3;hb=29e6551ec43ce5ed6a51414f9f8c8c4207a804b0;hpb=37428306a270088bfcb1f94362a0fe5b7a5a888e diff --git a/discover/pb-discover.c b/discover/pb-discover.c index 536f6e6..9330da6 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -43,6 +43,7 @@ struct opts { enum opt_value show_help; const char *log_file; enum opt_value show_version; + enum opt_value dry_run; }; /** @@ -54,12 +55,14 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) static const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"log", required_argument, NULL, 'l'}, + {"dry-run", no_argument, NULL, 'n'}, {"version", no_argument, NULL, 'V'}, { NULL, 0, NULL, 0}, }; - static const char short_options[] = "hl:V"; + static const char short_options[] = "hl:nV"; static const struct opts default_values = { .log_file = "/var/log/petitboot/pb-discover.log", + .dry_run = opt_no, }; *opts = default_values; @@ -78,6 +81,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) case 'l': opts->log_file = optarg; break; + case 'n': + opts->dry_run = opt_yes; + break; case 'V': opts->show_version = opt_yes; break; @@ -103,7 +109,7 @@ int main(int argc, char *argv[]) struct discover_server *server; struct waitset *waitset; struct opts opts; - struct udev *udev; + struct pb_udev *udev; struct user_event *uev; if (opts_parse(&opts, argc, argv)) { @@ -145,7 +151,7 @@ int main(int argc, char *argv[]) if (!server) return EXIT_FAILURE; - handler = device_handler_init(server); + handler = device_handler_init(server, opts.dry_run == opt_yes); if (!handler) return EXIT_FAILURE; @@ -159,7 +165,6 @@ int main(int argc, char *argv[]) if (!uev) return EXIT_FAILURE; - udev_trigger(udev); user_event_trigger(uev); for (running = 1; running;) { @@ -169,6 +174,7 @@ int main(int argc, char *argv[]) device_handler_destroy(handler); waitset_destroy(waitset); + udev_destroy(udev); pb_log("--- end ---\n");