summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-03-07 10:22:42 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-04-15 15:42:27 +0800
commitdbf139003bd6c8c6ca03ae7f533aa74afd8060c6 (patch)
tree7613e9e0eeb314aadbef3aa341643db8c360c8f1
parentc62667e5c78ea212e5ac49244e9792954a1d8f71 (diff)
downloadtalos-petitboot-dbf139003bd6c8c6ca03ae7f533aa74afd8060c6.tar.gz
talos-petitboot-dbf139003bd6c8c6ca03ae7f533aa74afd8060c6.zip
Move --dry-run option to discover server
Now that the server does the booting, we should move the --dry-run argument to the server. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/device-handler.c7
-rw-r--r--discover/device-handler.h3
-rw-r--r--discover/pb-discover.c10
-rw-r--r--ui/ncurses/generic-main.c12
-rw-r--r--ui/ncurses/nc-cui.c3
-rw-r--r--ui/ncurses/nc-cui.h3
-rw-r--r--ui/twin/main-generic.c3
-rw-r--r--ui/twin/pbt-client.c4
-rw-r--r--ui/twin/pbt-client.h4
-rw-r--r--ui/twin/pbt-main.c6
-rw-r--r--ui/twin/pbt-main.h1
11 files changed, 24 insertions, 32 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 6a27f15..12bd5ae 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -23,6 +23,7 @@
struct device_handler {
struct discover_server *server;
+ int dry_run;
struct device **devices;
unsigned int n_devices;
@@ -407,7 +408,8 @@ int device_handler_event(struct device_handler *handler,
return handlers[event->type][event->action](handler, event);
}
-struct device_handler *device_handler_init(struct discover_server *server)
+struct device_handler *device_handler_init(struct discover_server *server,
+ int dry_run)
{
struct device_handler *handler;
@@ -415,6 +417,7 @@ struct device_handler *device_handler_init(struct discover_server *server)
handler->devices = NULL;
handler->n_devices = 0;
handler->server = server;
+ handler->dry_run = dry_run;
list_init(&handler->contexts);
@@ -455,5 +458,5 @@ void device_handler_boot(struct device_handler *handler,
opt = find_boot_option_by_id(handler, cmd->option_id);
- boot(handler, opt, cmd, 0);
+ boot(handler, opt, cmd, handler->dry_run);
}
diff --git a/discover/device-handler.h b/discover/device-handler.h
index 7207f8d..4cf7d7d 100644
--- a/discover/device-handler.h
+++ b/discover/device-handler.h
@@ -21,7 +21,8 @@ struct discover_context {
struct list_item list;
};
-struct device_handler *device_handler_init(struct discover_server *server);
+struct device_handler *device_handler_init(struct discover_server *server,
+ int dry_run);
void device_handler_destroy(struct device_handler *devices);
diff --git a/discover/pb-discover.c b/discover/pb-discover.c
index 536f6e6..c83b574 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;
@@ -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;
diff --git a/ui/ncurses/generic-main.c b/ui/ncurses/generic-main.c
index ddf0de3..5d8debb 100644
--- a/ui/ncurses/generic-main.c
+++ b/ui/ncurses/generic-main.c
@@ -45,7 +45,7 @@ static void print_usage(void)
{
print_version();
printf(
-"Usage: petitboot-nc [-d, --dry-run] [-h, --help] [-l, --log log-file]\n"
+"Usage: petitboot-nc [-h, --help] [-l, --log log-file]\n"
" [-s, --start-daemon] [-V, --version]\n");
}
@@ -60,7 +60,6 @@ enum opt_value {opt_undef = 0, opt_yes, opt_no};
*/
struct opts {
- enum opt_value dry_run;
enum opt_value show_help;
const char *log_file;
enum opt_value start_daemon;
@@ -74,7 +73,6 @@ struct opts {
static int opts_parse(struct opts *opts, int argc, char *argv[])
{
static const struct option long_options[] = {
- {"dry-run", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
{"start-daemon", no_argument, NULL, 's'},
@@ -96,9 +94,6 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
break;
switch (c) {
- case 'd':
- opts->dry_run = opt_yes;
- break;
case 'h':
opts->show_help = opt_yes;
break;
@@ -151,8 +146,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
m->on_open = cui_on_open;
m->scr.frame.title = talloc_asprintf(m,
- "Petitboot (" PACKAGE_VERSION ")%s",
- (pb_cui->cui->dry_run ? " (dry-run)" : ""));
+ "Petitboot (" PACKAGE_VERSION ")");
m->scr.frame.help = talloc_strdup(m,
"ESC=exit, Enter=accept, e=edit, o=open");
m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
@@ -260,7 +254,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
- pb.cui = cui_init(&pb, NULL, opts.start_daemon, opts.dry_run);
+ pb.cui = cui_init(&pb, NULL, opts.start_daemon);
if (!pb.cui)
return EXIT_FAILURE;
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c
index fafa293..37ba1c4 100644
--- a/ui/ncurses/nc-cui.c
+++ b/ui/ncurses/nc-cui.c
@@ -520,7 +520,7 @@ static struct discover_client_ops cui_client_ops = {
*/
struct cui *cui_init(void* platform_info,
- int (*js_map)(const struct js_event *e), int start_deamon, int dry_run)
+ int (*js_map)(const struct js_event *e), int start_deamon)
{
struct cui *cui;
unsigned int i;
@@ -536,7 +536,6 @@ struct cui *cui_init(void* platform_info,
cui->c_sig = pb_cui_sig;
cui->platform_info = platform_info;
cui->timer.handle_timeout = cui_handle_timeout;
- cui->dry_run = dry_run;
cui->waitset = waitset_create(cui);
/* Loop here for scripts that just started the server. */
diff --git a/ui/ncurses/nc-cui.h b/ui/ncurses/nc-cui.h
index 33f2661..69c15d4 100644
--- a/ui/ncurses/nc-cui.h
+++ b/ui/ncurses/nc-cui.h
@@ -51,7 +51,6 @@ struct cui {
enum pb_nc_sig c_sig;
sig_atomic_t abort;
sig_atomic_t resize;
- int dry_run;
struct nc_scr *current;
struct pmenu *main;
struct ui_timer timer;
@@ -64,7 +63,7 @@ struct cui {
};
struct cui *cui_init(void* platform_info,
- int (*js_map)(const struct js_event *e), int start_deamon, int dry_run);
+ int (*js_map)(const struct js_event *e), int start_deamon);
struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr);
int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item);
int cui_boot_editor_run(struct pmenu_item *item);
diff --git a/ui/twin/main-generic.c b/ui/twin/main-generic.c
index cc5140e..c9cb492 100644
--- a/ui/twin/main-generic.c
+++ b/ui/twin/main-generic.c
@@ -317,8 +317,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
- client = pbt_client_init(opts.backend, 1024, 640,
- opts.start_daemon, opts.dry_run);
+ client = pbt_client_init(opts.backend, 1024, 640, opts.start_daemon);
if (!client) {
ui_result = EXIT_FAILURE;
diff --git a/ui/twin/pbt-client.c b/ui/twin/pbt-client.c
index c664740..875b408 100644
--- a/ui/twin/pbt-client.c
+++ b/ui/twin/pbt-client.c
@@ -261,8 +261,7 @@ static void pbt_client_destructor(struct pbt_client *client)
}
struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
- unsigned int width, unsigned int height,
- int start_deamon, int dry_run)
+ unsigned int width, unsigned int height, int start_deamon)
{
struct pbt_client *pbt_client;
unsigned int i;
@@ -280,7 +279,6 @@ struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
pbt_client->waitset = waitset_create(pbt_client);
pbt_client->sig = "pbt_client";
- pbt_client->dry_run = dry_run;
pbt_client->frame.scr = pbt_scr_init(pbt_client, pbt_client->waitset,
backend, width, height, NULL, NULL);
diff --git a/ui/twin/pbt-client.h b/ui/twin/pbt-client.h
index 2c96d48..7b9671f 100644
--- a/ui/twin/pbt-client.h
+++ b/ui/twin/pbt-client.h
@@ -42,7 +42,6 @@ void pbt_frame_status_printf(struct pbt_frame *frame, const char *format, ...);
struct pbt_client {
const char *sig;
- int dry_run;
struct pb_signal_data signal_data;
void *client_data;
struct pbt_frame frame;
@@ -51,8 +50,7 @@ struct pbt_client {
};
struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
- unsigned int width, unsigned int height,
- int start_deamon, int dry_run);
+ unsigned int width, unsigned int height, int start_deamon);
void pbt_client_destroy(struct pbt_client *client);
void pbt_client_resize(struct pbt_client *client);
diff --git a/ui/twin/pbt-main.c b/ui/twin/pbt-main.c
index 84e824e..542f949 100644
--- a/ui/twin/pbt-main.c
+++ b/ui/twin/pbt-main.c
@@ -34,7 +34,7 @@ void pbt_print_usage(void)
{
pbt_print_version();
printf(
-"Usage: petitboot-twin [-d, --dry-run] [-h, --help] [-l, --log log-file]\n"
+"Usage: petitboot-twin [-h, --help] [-l, --log log-file]\n"
" [-r, --reset-defaults] [-s, --start-daemon]\n"
" [-t, --timeout] [-V, --version]\n"
" [[-f --fbdev] | [-x --x11]]\n");
@@ -47,7 +47,6 @@ void pbt_print_usage(void)
int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
{
static const struct option long_options[] = {
- {"dry-run", no_argument, NULL, 'd'},
{"fbdev", no_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
@@ -74,9 +73,6 @@ int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
break;
switch (c) {
- case 'd':
- opts->dry_run = pbt_opt_yes;
- break;
case 'f':
opts->backend = pbt_twin_fbdev;
break;
diff --git a/ui/twin/pbt-main.h b/ui/twin/pbt-main.h
index e5af71a..b6821cf 100644
--- a/ui/twin/pbt-main.h
+++ b/ui/twin/pbt-main.h
@@ -32,7 +32,6 @@ enum pbt_opt_value {pbt_opt_undef = 0, pbt_opt_yes, pbt_opt_no};
struct pbt_opts {
enum pbt_twin_backend backend;
- enum pbt_opt_value dry_run;
enum pbt_opt_value show_help;
const char *log_file;
enum pbt_opt_value reset_defaults;
OpenPOWER on IntegriCloud