mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/6] nv: Add option to explicitly save nv variables
Date: Fri, 22 Jul 2016 12:39:16 +0200	[thread overview]
Message-ID: <1469183959-9002-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1469183959-9002-1-git-send-email-s.hauer@pengutronix.de>

We now have code to save the nv variables without saving the
rest of the environment. This gives us the possibility to explicitly
save the nv variables. This patch adds an option to the 'nv' command
for this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/nv.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/commands/nv.c b/commands/nv.c
index 8cebb85..e312368 100644
--- a/commands/nv.c
+++ b/commands/nv.c
@@ -26,20 +26,26 @@
 static int do_nv(int argc, char *argv[])
 {
 	int opt;
-	int do_remove = 0;
+	int do_remove = 0, do_save = 0;
 	int ret;
 	char *value;
 
-	while ((opt = getopt(argc, argv, "r")) > 0) {
+	while ((opt = getopt(argc, argv, "rs")) > 0) {
 		switch (opt) {
 		case 'r':
 			do_remove = 1;
 			break;
+		case 's':
+			do_save = 1;
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
 	}
 
+	if (do_save)
+		return nvvar_save();
+
 	if (argc == optind) {
 		nvvar_print();
 		return 0;
@@ -68,11 +74,12 @@ static int do_nv(int argc, char *argv[])
 BAREBOX_CMD_HELP_START(nv)
 BAREBOX_CMD_HELP_TEXT("Add a new non volatile variable named VAR, optionally set to VALUE.")
 BAREBOX_CMD_HELP_TEXT("non volatile variables are persistent variables that overwrite the")
-BAREBOX_CMD_HELP_TEXT("global variables of the same name. Their value is saved with")
-BAREBOX_CMD_HELP_TEXT("'saveenv'.")
+BAREBOX_CMD_HELP_TEXT("global variables of the same name. Their value is saved implicitly with")
+BAREBOX_CMD_HELP_TEXT("'saveenv' or explicitly with 'nv -s'")
 BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT("-r", "remove a non volatile variable")
+BAREBOX_CMD_HELP_OPT("-s", "Save NV variables")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(nv)
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-07-22 10:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 10:39 nv variable changes Sascha Hauer
2016-07-22 10:39 ` [PATCH 1/6] nv: Do not save nv variables while loading Sascha Hauer
2016-07-22 10:39 ` [PATCH 2/6] nv: Save nv variables on shutdown Sascha Hauer
2016-07-22 10:39 ` Sascha Hauer [this message]
2016-07-22 10:39 ` [PATCH 4/6] nv: Allow to set/remove multiple variables with one command Sascha Hauer
2016-07-22 10:39 ` [PATCH 5/6] nv: Use dev_remove_param to delete nv variable Sascha Hauer
2016-07-22 10:39 ` [PATCH 6/6] nv: Allow wildcards when removing NV vars Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1469183959-9002-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox