summaryrefslogtreecommitdiffstats
path: root/common/binfmt.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-09-22 12:57:38 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-24 09:03:18 +0200
commit45212cdd722b0ebcdab0fe9e9d043b8cd0132edb (patch)
treeaa122ae201f543b39ad31ba12754127c5d85ca2a /common/binfmt.c
parent56f33b467953c28ac084e86048503ce86d3d389f (diff)
downloadbarebox-45212cdd722b0ebcdab0fe9e9d043b8cd0132edb.tar.gz
command: Let builtin command take precedence
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>
Diffstat (limited to 'common/binfmt.c')
-rw-r--r--common/binfmt.c5
1 files changed, 4 insertions, 1 deletions
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)