summaryrefslogtreecommitdiffstats
path: root/commands/state.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-24 15:46:32 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 18:43:53 +0200
commit3a5ddf3d0db006e9256c8e256e7dc7b4a3f89a14 (patch)
treef540254f82abe8fcd4b9d723403aa86ee41c4e9d /commands/state.c
parente18b4ad84db80e6a0442fd521f84dd113314e29e (diff)
downloadbarebox-3a5ddf3d0db006e9256c8e256e7dc7b4a3f89a14.tar.gz
commands: state: allow loading state with -l
At least for testing purposes it's useful to be able to manually load a state. Add -l option for this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/state.c')
-rw-r--r--commands/state.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/commands/state.c b/commands/state.c
index 4b51759..aded6e7 100644
--- a/commands/state.c
+++ b/commands/state.c
@@ -21,20 +21,23 @@ static int do_state(int argc, char *argv[])
{
int opt, ret = 0;
struct state *state = NULL;
- int do_save = 0;
+ int do_save = 0, do_load = 0;
const char *statename = "state";
- while ((opt = getopt(argc, argv, "s")) > 0) {
+ while ((opt = getopt(argc, argv, "sl")) > 0) {
switch (opt) {
case 's':
do_save = 1;
break;
+ case 'l':
+ do_load = 1;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
}
- if (!do_save) {
+ if (!do_save && !do_load) {
state_info();
return 0;
}
@@ -48,7 +51,9 @@ static int do_state(int argc, char *argv[])
return -ENOENT;
}
- if (do_save)
+ if (do_load)
+ ret = state_load(state);
+ else if (do_save)
ret = state_save(state);
return ret;