X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fpb-discover.c;h=007e66f2dcd671ae83058b257d9b4a72a43e785a;hp=fac1c9deb261301e9927b9dc7c095339a6d83370;hb=e5f5a2e91e89af08925b6dae3680fc9ef62190ff;hpb=32fe8024f5af5cd8de23c638ddad8ada67a46cd5 diff --git a/discover/pb-discover.c b/discover/pb-discover.c index fac1c9d..007e66f 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -17,6 +17,7 @@ #include "user-event.h" #include "discover-server.h" #include "device-handler.h" +#include "network.h" static void print_version(void) { @@ -27,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"); } /** @@ -41,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; }; /** @@ -54,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, }; @@ -76,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; @@ -108,6 +116,7 @@ int main(int argc, char *argv[]) { struct device_handler *handler; struct discover_server *server; + struct network *network; struct waitset *waitset; struct opts opts; struct pb_udev *udev; @@ -154,6 +163,10 @@ int main(int argc, char *argv[]) if (!server) return EXIT_FAILURE; + network = network_init(server, waitset, opts.dry_run == opt_yes); + if (!network) + return EXIT_FAILURE; + handler = device_handler_init(server, waitset, opts.dry_run == opt_yes); if (!handler) return EXIT_FAILURE;