summaryrefslogtreecommitdiffstats
path: root/openwrt/package
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-11-09 13:25:00 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-11-09 13:25:00 +0000
commit6f0ddd19ee7baafa78a3c47f8b4e42973db5ed56 (patch)
tree37918a8b13ab2b0c77f66b2cf93f8c38c6337abf /openwrt/package
parente6f2e06d246df0b2c5d54e53a6f31d397fa6b7f5 (diff)
add a busybox ash performance hack
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@2398 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'openwrt/package')
-rw-r--r--openwrt/package/busybox/patches/190-ash_performance.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/openwrt/package/busybox/patches/190-ash_performance.patch b/openwrt/package/busybox/patches/190-ash_performance.patch
new file mode 100644
index 000000000..7f2954de7
--- /dev/null
+++ b/openwrt/package/busybox/patches/190-ash_performance.patch
@@ -0,0 +1,77 @@
+diff -urN busybox.old/shell/ash.c busybox.dev/shell/ash.c
+--- busybox.old/shell/ash.c 2004-10-08 11:43:34.000000000 +0200
++++ busybox.dev/shell/ash.c 2005-11-09 14:06:10.800983750 +0100
+@@ -1414,6 +1414,13 @@
+
+ #define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) )
+
++static const char *safe_applets[] = {
++ "[", "test", "echo", "cat",
++ "ln", "cp", "touch", "mkdir", "rm",
++ "cut", "hexdump", "awk", "sort",
++ "find", "xargs", "ls", "dd",
++ "chown", "chmod"
++};
+
+
+ struct cmdentry {
+@@ -2050,6 +2057,19 @@
+ static void exitshell(void) __attribute__((__noreturn__));
+ static int decode_signal(const char *, int);
+
++
++static int is_safe_applet(char *name)
++{
++ int n = sizeof(safe_applets) / sizeof(char *);
++ int i;
++ for (i = 0; i < n; i++)
++ if (strcmp(safe_applets[i], name) == 0)
++ return 1;
++
++ return 0;
++}
++
++
+ /*
+ * This routine is called when an error or an interrupt occurs in an
+ * interactive shell and control is returned to the main command loop.
+@@ -3680,6 +3700,7 @@
+ clearredir(1);
+ envp = environment();
+ if (strchr(argv[0], '/') != NULL
++ || is_safe_applet(argv[0])
+ #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
+ || find_applet_by_name(argv[0])
+ #endif
+@@ -3721,6 +3742,18 @@
+ tryexec(char *cmd, char **argv, char **envp)
+ {
+ int repeated = 0;
++ struct BB_applet *a;
++ int argc = 0;
++ char **c;
++
++ if(strchr(cmd, '/') == NULL && is_safe_applet(cmd) && (a = find_applet_by_name(cmd)) != NULL) {
++ c = argv;
++ while (*c != NULL) {
++ c++; argc++;
++ }
++ bb_applet_name = "[";
++ exit(a->main(argc, argv));
++ }
+ #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
+ int flg_bb = 0;
+ char *name = cmd;
+@@ -3919,6 +3952,12 @@
+ }
+ #endif
+
++ if (is_safe_applet(name)) {
++ entry->cmdtype = CMDNORMAL;
++ entry->u.index = -1;
++ return;
++ }
++
+ updatetbl = (path == pathval());
+ if (!updatetbl) {
+ act |= DO_ALTPATH;