public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Grant Erickson <marathon96@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default
Date: Thu, 22 Dec 2011 10:59:55 -0800	[thread overview]
Message-ID: <1324580395-27004-1-git-send-email-marathon96@gmail.com> (raw)

This patch allows the U-Boot user space companion utility, fw_setenv,
to overwrite the 'ethaddr' key/value pair if the current value is set
to a per-board-configured default.

This change allows 'fw_setenv' to match the behavior of 'setenv' /
'env set' on the U-Boot command line.

Signed-off-by: Grant Erickson <marathon96@gmail.com>
---
 tools/env/fw_env.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 996682e..2185be9 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -45,6 +45,8 @@
 
 #include "fw_env.h"
 
+#include <config.h>
+
 #define WHITESPACE(c) ((c == '\t') || (c == ' '))
 
 #define min(x, y) ({				\
@@ -390,15 +392,23 @@ int fw_env_write(char *name, char *value)
 	 * Delete any existing definition
 	 */
 	if (oldval) {
+#ifndef CONFIG_ENV_OVERWRITE
+
 		/*
 		 * Ethernet Address and serial# can be set only once
 		 */
-		if ((strcmp (name, "ethaddr") == 0) ||
-			(strcmp (name, "serial#") == 0)) {
+		if (
+		    (strcmp(name, "serial#") == 0) ||
+		    ((strcmp(name, "ethaddr") == 0)
+#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
+		    && (strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0)
+#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
+		   ) ) {
 			fprintf (stderr, "Can't overwrite \"%s\"\n", name);
 			errno = EROFS;
 			return -1;
 		}
+#endif /* CONFIG_ENV_OVERWRITE */
 
 		if (*++nxt == '\0') {
 			*env = '\0';
-- 
1.7.7.3

             reply	other threads:[~2011-12-22 18:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-22 18:59 Grant Erickson [this message]
2012-01-05 15:59 ` [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default Wolfgang Denk
2012-01-23 12:23   ` Andreas Bießmann
2012-01-23 13:30     ` [U-Boot] Toradex Colibri, PXA-270 (ARM) Daniel Mack
2012-01-23 14:28       ` Wolfgang Denk
2012-01-23 20:40     ` [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default Mike Frysinger

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=1324580395-27004-1-git-send-email-marathon96@gmail.com \
    --to=marathon96@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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