mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/11] command: Let builtin command take precedence
Date: Tue, 24 Sep 2013 09:08:46 +0200	[thread overview]
Message-ID: <1380006527-2599-11-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1380006527-2599-1-git-send-email-s.hauer@pengutronix.de>

In theory we can overwrite a builtin command with a script. However,
I don't know a single case where this has been done. Scripts are
often more unflexible than commands so it's unlikely that a script
can extend the functionality of a builtin command. Moreover, the
internal command is no longer accessible once it's overwritten by
a script.

Invert this logic so that a builtin command can overwrite an existing
script. This will help when the 'boot' script is converted to a
builting command. Then with old environments the builtin command will
be used instead of the script.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/binfmt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/binfmt.c b/common/binfmt.c
index 7dcf5d7..f2ff624 100644
--- a/common/binfmt.c
+++ b/common/binfmt.c
@@ -60,6 +60,9 @@ int execute_binfmt(int argc, char **argv)
 	if (strchr(argv[0], '/'))
 		return binfmt_run(argv[0], argc, argv);
 
+	if (find_cmd(argv[0]))
+		return execute_command(argc, &argv[0]);
+
 	path = find_execable(argv[0]);
 	if (path) {
 		ret = binfmt_run(path, argc, argv);
@@ -67,7 +70,7 @@ int execute_binfmt(int argc, char **argv)
 		return ret;
 	}
 
-	return execute_command(argc, &argv[0]);
+	return -ENOENT;
 }
 
 int binfmt_register(struct binfmt_hook *b)
-- 
1.8.4.rc3


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

  parent reply	other threads:[~2013-09-24  7:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-24  7:08 Bootm patches Sascha Hauer
2013-09-24  7:08 ` [PATCH 01/11] bootm: fix possible memory leak Sascha Hauer
2013-09-24  7:08 ` [PATCH 02/11] bootm: fix " Sascha Hauer
2013-09-24  7:08 ` [PATCH 03/11] bootm: check for os image file Sascha Hauer
2013-09-24  7:08 ` [PATCH 04/11] bootm: remove unused define Sascha Hauer
2013-09-24  7:08 ` [PATCH 05/11] bootm: move getenv_loadaddr from command to common Sascha Hauer
2013-09-24  7:08 ` [PATCH 06/11] bootm: move globalvars " Sascha Hauer
2013-09-24  7:08 ` [PATCH 07/11] bootm: separate bootm input data and internal data Sascha Hauer
2013-09-24  7:08 ` [PATCH 08/11] bootm: Add dryrun support Sascha Hauer
2013-09-24  7:08 ` [PATCH 09/11] ARM: compile bootm code depending on CONFIG_BOOTM Sascha Hauer
2013-09-24  7:08 ` Sascha Hauer [this message]
2013-09-24  7:08 ` [PATCH 11/11] defenv-2: replace boot script with command 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=1380006527-2599-11-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