fix serial console on ap60/61
[openwrt.git] / openwrt / package / busybox / patches / 190-ash_performance.patch
1 diff -urN busybox.old/shell/ash.c busybox.dev/shell/ash.c
2 --- busybox.old/shell/ash.c 2005-11-12 22:39:19.853826250 +0100
3 +++ busybox.dev/shell/ash.c 2005-11-12 22:39:42.771258500 +0100
4 @@ -1414,6 +1414,13 @@
5
6 #define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) )
7
8 +static const char *safe_applets[] = {
9 + "[", "test", "echo", "cat",
10 + "ln", "cp", "touch", "mkdir", "rm",
11 + "cut", "hexdump", "awk", "sort",
12 + "find", "xargs", "ls", "dd",
13 + "chown", "chmod"
14 +};
15
16
17 struct cmdentry {
18 @@ -2050,6 +2057,19 @@
19 static void exitshell(void) __attribute__((__noreturn__));
20 static int decode_signal(const char *, int);
21
22 +
23 +static int is_safe_applet(char *name)
24 +{
25 + int n = sizeof(safe_applets) / sizeof(char *);
26 + int i;
27 + for (i = 0; i < n; i++)
28 + if (strcmp(safe_applets[i], name) == 0)
29 + return 1;
30 +
31 + return 0;
32 +}
33 +
34 +
35 /*
36 * This routine is called when an error or an interrupt occurs in an
37 * interactive shell and control is returned to the main command loop.
38 @@ -3680,6 +3700,7 @@
39 clearredir(1);
40 envp = environment();
41 if (strchr(argv[0], '/') != NULL
42 + || is_safe_applet(argv[0])
43 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
44 || find_applet_by_name(argv[0])
45 #endif
46 @@ -3721,6 +3742,18 @@
47 tryexec(char *cmd, char **argv, char **envp)
48 {
49 int repeated = 0;
50 + struct BB_applet *a;
51 + int argc = 0;
52 + char **c;
53 +
54 + if(strchr(cmd, '/') == NULL && is_safe_applet(cmd) && (a = find_applet_by_name(cmd)) != NULL) {
55 + c = argv;
56 + while (*c != NULL) {
57 + c++; argc++;
58 + }
59 + bb_applet_name = cmd;
60 + exit(a->main(argc, argv));
61 + }
62 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
63 int flg_bb = 0;
64 char *name = cmd;
65 @@ -3919,6 +3952,12 @@
66 }
67 #endif
68
69 + if (is_safe_applet(name)) {
70 + entry->cmdtype = CMDNORMAL;
71 + entry->u.index = -1;
72 + return;
73 + }
74 +
75 updatetbl = (path == pathval());
76 if (!updatetbl) {
77 act |= DO_ALTPATH;
This page took 0.042382 seconds and 5 git commands to generate.