enum opt_value show_help;
const char *log_file;
enum opt_value show_version;
+ enum opt_value dry_run;
};
/**
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;
case 'l':
opts->log_file = optarg;
break;
+ case 'n':
+ opts->dry_run = opt_yes;
+ break;
case 'V':
opts->show_version = opt_yes;
break;
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)) {
if (!server)
return EXIT_FAILURE;
- handler = device_handler_init(server);
+ handler = device_handler_init(server, waitset, opts.dry_run == opt_yes);
if (!handler)
return EXIT_FAILURE;
if (!uev)
return EXIT_FAILURE;
- udev_trigger(udev);
user_event_trigger(uev);
for (running = 1; running;) {
device_handler_destroy(handler);
waitset_destroy(waitset);
+ udev_destroy(udev);
pb_log("--- end ---\n");