X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fpb-discover.c;h=a0535c2f5e6639a423ffba3bcd534aae408ba8fc;hp=986401d9fff6f434bff7c9c007f4e50548961341;hb=e12710c40ea278209c03d8351936f32964ad5c18;hpb=c75acc64833eb7263b340079e7ba3153ebc60aec diff --git a/discover/pb-discover.c b/discover/pb-discover.c index 986401d..a0535c2 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -28,7 +28,8 @@ static void print_usage(void) { print_version(); printf( -"Usage: pb-discover [-h, --help] [-l, --log log-file] [-V, --version]\n"); +"Usage: pb-discover [-a, --no-autoboot] [-h, --help] [-l, --log log-file]\n" +" [-n, --dry-run] [-V, --version]\n"); } /** @@ -42,10 +43,11 @@ enum opt_value {opt_undef = 0, opt_yes, opt_no}; */ struct opts { + enum opt_value no_autoboot; enum opt_value show_help; const char *log_file; - enum opt_value show_version; enum opt_value dry_run; + enum opt_value show_version; }; /** @@ -55,14 +57,16 @@ struct opts { static int opts_parse(struct opts *opts, int argc, char *argv[]) { static const struct option long_options[] = { + {"no-autoboot", no_argument, NULL, 'a'}, {"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:nV"; + static const char short_options[] = "ahl:nV"; static const struct opts default_values = { + .no_autoboot = opt_no, .log_file = "/var/log/petitboot/pb-discover.log", .dry_run = opt_no, }; @@ -77,6 +81,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) break; switch (c) { + case 'a': + opts->no_autoboot = opt_yes; + break; case 'h': opts->show_help = opt_yes; break; @@ -150,6 +157,9 @@ int main(int argc, char *argv[]) config_init(NULL); + if (opts.no_autoboot == opt_yes) + config_set_autoboot(false); + waitset = waitset_create(NULL); server = discover_server_init(waitset); @@ -174,15 +184,12 @@ int main(int argc, char *argv[]) if (!uev) return EXIT_FAILURE; - user_event_trigger(uev); - for (running = 1; running;) { if (waiter_poll(waitset)) break; } device_handler_destroy(handler); - waitset_destroy(waitset); udev_destroy(udev); config_fini();