From patchwork Thu Dec 22 18:59:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 132889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 0BD90B7199 for ; Fri, 23 Dec 2011 06:31:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2489628194; Thu, 22 Dec 2011 20:31:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OpF8hSvVkZsQ; Thu, 22 Dec 2011 20:31:18 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C93CB28198; Thu, 22 Dec 2011 20:31:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 23D9828148 for ; Thu, 22 Dec 2011 20:00:15 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G-k3Le1gt0uo for ; Thu, 22 Dec 2011 20:00:13 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-iy0-f172.google.com (mail-iy0-f172.google.com [209.85.210.172]) by theia.denx.de (Postfix) with ESMTPS id 2E8C82809A for ; Thu, 22 Dec 2011 20:00:12 +0100 (CET) Received: by iaen33 with SMTP id n33so5306555iae.3 for ; Thu, 22 Dec 2011 11:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=MpjF4+8Y03c3moh4J3C4DADXrZjNJSBqsX+iS3Yf67M=; b=khuBdbSJskzZl8Zd+2E2yOeCxQqOp+0+GhJk/x+Dxhy6ykj7iElnp8H+ngBYNJP8p2 t8W8ZsBfEC7lnRmH1uKRcedQe6AkSMjh8GlMPNNzJGOv67++lGfaaYWCI/3ok6MzUygX aosUJuU4TbzRZTopf57yWRsP137xO24rsKGog= Received: by 10.50.217.168 with SMTP id oz8mr9996062igc.24.1324580411040; Thu, 22 Dec 2011 11:00:11 -0800 (PST) Received: from localhost.localdomain (74-93-5-105-SFBA.hfc.comcastbusiness.net. [74.93.5.105]) by mx.google.com with ESMTPS id r5sm1526845igl.3.2011.12.22.11.00.10 (version=SSLv3 cipher=OTHER); Thu, 22 Dec 2011 11:00:10 -0800 (PST) From: Grant Erickson To: u-boot@lists.denx.de Date: Thu, 22 Dec 2011 10:59:55 -0800 Message-Id: <1324580395-27004-1-git-send-email-marathon96@gmail.com> X-Mailer: git-send-email 1.7.7.3 X-Mailman-Approved-At: Thu, 22 Dec 2011 20:31:00 +0100 Cc: Grant Erickson Subject: [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- 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 + #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';