From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ctqbd-0001ei-13 for barebox@lists.infradead.org; Fri, 31 Mar 2017 07:04:22 +0000 From: Sascha Hauer Date: Fri, 31 Mar 2017 09:03:37 +0200 Message-Id: <20170331070346.26878-34-s.hauer@pengutronix.de> In-Reply-To: <20170331070346.26878-1-s.hauer@pengutronix.de> References: <20170331070346.26878-1-s.hauer@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 33/42] commands: state: allow loading state with -l To: Barebox List 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 --- commands/state.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/commands/state.c b/commands/state.c index 4b51759e3e..aded6e71e2 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; -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox