diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-01-13 04:43:48 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-01-13 04:43:48 +0000 |
commit | 05df239ed90584156b820dbf3ede638208eb440f (patch) | |
tree | 990a3d6a9beb21420fae1f7d14886c84a5ce3c12 | |
parent | 9a9a261569df0c88038de48eb233890ca189e9c0 (diff) | |
download | busybox-w32-05df239ed90584156b820dbf3ede638208eb440f.tar.gz busybox-w32-05df239ed90584156b820dbf3ede638208eb440f.tar.bz2 busybox-w32-05df239ed90584156b820dbf3ede638208eb440f.zip |
Bug fixes.
-Erik
-rw-r--r-- | Changelog | 7 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | applets/busybox.c | 15 | ||||
-rw-r--r-- | busybox.c | 15 | ||||
-rw-r--r-- | busybox.def.h | 3 | ||||
-rw-r--r-- | busybox.spec | 4 | ||||
-rw-r--r-- | coreutils/mkdir.c | 4 | ||||
-rw-r--r-- | docs/CommandList | 104 | ||||
-rw-r--r-- | examples/busybox.spec | 4 | ||||
-rw-r--r-- | init.c | 44 | ||||
-rw-r--r-- | init/init.c | 44 | ||||
-rw-r--r-- | internal.h | 1 | ||||
-rw-r--r-- | mkdir.c | 4 | ||||
-rwxr-xr-x | reg_test.sh | 34 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 5 | ||||
-rw-r--r-- | syslogd.c | 5 | ||||
-rw-r--r-- | true_false.c | 4 | ||||
-rw-r--r-- | utility.c | 11 |
19 files changed, 166 insertions, 145 deletions
@@ -1,12 +1,17 @@ | |||
1 | 0.41 | 1 | 0.41 |
2 | * New App: wc -- contributed by Edward Betts <edward@debian.org> | ||
2 | * Fixed a bug in both cp and mv preventing 'cp foo/README bar' | 3 | * Fixed a bug in both cp and mv preventing 'cp foo/README bar' |
3 | type commands (file in a directory to another directory) | 4 | type commands (file in a directory to another directory) |
4 | from working. | 5 | from working. |
5 | * Fixed a logger bug that caused garbage to be written to the syslog | 6 | * Fixed a logger bug that caused garbage to be written to the syslog |
6 | (unless you used busybox syslog, which hid the bug). Thanks | 7 | (unless you used busybox syslog, which hid the bug). Thanks |
7 | to Alex Holden <alex@linuxhacker.org> for the fix. | 8 | to Alex Holden <alex@linuxhacker.org> for the fix. |
9 | * /bin/true and /bin/false were echoing a blank line when run. Now fixed. | ||
10 | * mkdir -p would print an error when asked to mkdir an existing dir | ||
11 | with no interveining subdirectories. | ||
12 | * Fixed "syslogd -O" so that it works. | ||
8 | 13 | ||
9 | -Erik Andersen, | 14 | -Erik Andersen |
10 | 15 | ||
11 | 0.40 | 16 | 0.40 |
12 | * New Apps: sort, uniq. -beppu | 17 | * New Apps: sort, uniq. -beppu |
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | 18 | ||
19 | PROG=busybox | 19 | PROG=busybox |
20 | VERSION=0.40 | 20 | VERSION=0.41 |
21 | BUILDTIME=$(shell date "+%Y%m%d-%H%M") | 21 | BUILDTIME=$(shell date "+%Y%m%d-%H%M") |
22 | 22 | ||
23 | # Comment out the following to make a debuggable build | 23 | # Comment out the following to make a debuggable build |
@@ -18,7 +18,6 @@ around to it some time. If you have any good ideas, please let me know. | |||
18 | * hwclock | 18 | * hwclock |
19 | * killall | 19 | * killall |
20 | * stty | 20 | * stty |
21 | * wc | ||
22 | * tr | 21 | * tr |
23 | * expr (maybe?) (ash builtin?) | 22 | * expr (maybe?) (ash builtin?) |
24 | 23 | ||
diff --git a/applets/busybox.c b/applets/busybox.c index 4a7feefd2..a00f90be0 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
@@ -5,6 +5,16 @@ | |||
5 | 5 | ||
6 | static int been_there_done_that = 0; | 6 | static int been_there_done_that = 0; |
7 | 7 | ||
8 | #if 0 | ||
9 | void exit (int status) __attribute__ ((noreturn)); | ||
10 | void exit (int status) { _exit(status); }; | ||
11 | void abort (void) __attribute__ ((__noreturn__)); | ||
12 | void abort (void) { _exit(0); }; | ||
13 | int atexit (void (*__func) (void)) { _exit(0); }; | ||
14 | void *__libc_stack_end; | ||
15 | #endif | ||
16 | |||
17 | |||
8 | static const struct Applet applets[] = { | 18 | static const struct Applet applets[] = { |
9 | 19 | ||
10 | #ifdef BB_BUSYBOX //bin | 20 | #ifdef BB_BUSYBOX //bin |
@@ -219,6 +229,9 @@ static const struct Applet applets[] = { | |||
219 | {"true", true_main}, | 229 | {"true", true_main}, |
220 | {"false", false_main}, | 230 | {"false", false_main}, |
221 | #endif | 231 | #endif |
232 | #ifdef BB_WC //usr/bin | ||
233 | {"wc", wc_main}, | ||
234 | #endif | ||
222 | #ifdef BB_UNAME //bin | 235 | #ifdef BB_UNAME //bin |
223 | {"uname", uname_main}, | 236 | {"uname", uname_main}, |
224 | #endif | 237 | #endif |
@@ -241,6 +254,8 @@ static const struct Applet applets[] = { | |||
241 | {0} | 254 | {0} |
242 | }; | 255 | }; |
243 | 256 | ||
257 | |||
258 | |||
244 | int main(int argc, char **argv) | 259 | int main(int argc, char **argv) |
245 | { | 260 | { |
246 | char *s = argv[0]; | 261 | char *s = argv[0]; |
@@ -5,6 +5,16 @@ | |||
5 | 5 | ||
6 | static int been_there_done_that = 0; | 6 | static int been_there_done_that = 0; |
7 | 7 | ||
8 | #if 0 | ||
9 | void exit (int status) __attribute__ ((noreturn)); | ||
10 | void exit (int status) { _exit(status); }; | ||
11 | void abort (void) __attribute__ ((__noreturn__)); | ||
12 | void abort (void) { _exit(0); }; | ||
13 | int atexit (void (*__func) (void)) { _exit(0); }; | ||
14 | void *__libc_stack_end; | ||
15 | #endif | ||
16 | |||
17 | |||
8 | static const struct Applet applets[] = { | 18 | static const struct Applet applets[] = { |
9 | 19 | ||
10 | #ifdef BB_BUSYBOX //bin | 20 | #ifdef BB_BUSYBOX //bin |
@@ -219,6 +229,9 @@ static const struct Applet applets[] = { | |||
219 | {"true", true_main}, | 229 | {"true", true_main}, |
220 | {"false", false_main}, | 230 | {"false", false_main}, |
221 | #endif | 231 | #endif |
232 | #ifdef BB_WC //usr/bin | ||
233 | {"wc", wc_main}, | ||
234 | #endif | ||
222 | #ifdef BB_UNAME //bin | 235 | #ifdef BB_UNAME //bin |
223 | {"uname", uname_main}, | 236 | {"uname", uname_main}, |
224 | #endif | 237 | #endif |
@@ -241,6 +254,8 @@ static const struct Applet applets[] = { | |||
241 | {0} | 254 | {0} |
242 | }; | 255 | }; |
243 | 256 | ||
257 | |||
258 | |||
244 | int main(int argc, char **argv) | 259 | int main(int argc, char **argv) |
245 | { | 260 | { |
246 | char *s = argv[0]; | 261 | char *s = argv[0]; |
diff --git a/busybox.def.h b/busybox.def.h index 834555302..65ed365a5 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -72,12 +72,13 @@ | |||
72 | #define BB_SORT | 72 | #define BB_SORT |
73 | #define BB_SWAPONOFF | 73 | #define BB_SWAPONOFF |
74 | #define BB_SYNC | 74 | #define BB_SYNC |
75 | //#define BB_SYSLOGD | 75 | #define BB_SYSLOGD |
76 | #define BB_TAIL | 76 | #define BB_TAIL |
77 | #define BB_TAR | 77 | #define BB_TAR |
78 | #define BB_TEE | 78 | #define BB_TEE |
79 | #define BB_TOUCH | 79 | #define BB_TOUCH |
80 | #define BB_TRUE_FALSE | 80 | #define BB_TRUE_FALSE |
81 | #define BB_WC | ||
81 | #define BB_UMOUNT | 82 | #define BB_UMOUNT |
82 | #define BB_UNIQ | 83 | #define BB_UNIQ |
83 | #define BB_UPDATE | 84 | #define BB_UPDATE |
diff --git a/busybox.spec b/busybox.spec index d1a702642..ae7010186 100644 --- a/busybox.spec +++ b/busybox.spec | |||
@@ -1,5 +1,5 @@ | |||
1 | Name: busybox | 1 | Name: busybox |
2 | Version: 0.40 | 2 | Version: 0.41 |
3 | Release: 1 | 3 | Release: 1 |
4 | Group: System/Utilities | 4 | Group: System/Utilities |
5 | Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. | 5 | Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. |
@@ -21,7 +21,7 @@ embedded system. | |||
21 | %setup -q -n %{Name}-%{Version} | 21 | %setup -q -n %{Name}-%{Version} |
22 | 22 | ||
23 | %Build | 23 | %Build |
24 | BB_INIT_SCRIPT='\"/etc/rc.d/init.d/rcS\"' make | 24 | make |
25 | 25 | ||
26 | %Install | 26 | %Install |
27 | rm -rf $RPM_BUILD_ROOT | 27 | rm -rf $RPM_BUILD_ROOT |
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 9ea3b4ea0..dc245a18e 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c | |||
@@ -84,7 +84,7 @@ extern int mkdir_main(int argc, char **argv) | |||
84 | 84 | ||
85 | strcpy (buf, *argv); | 85 | strcpy (buf, *argv); |
86 | status=stat(buf, &statBuf); | 86 | status=stat(buf, &statBuf); |
87 | if (status != -1 && status != ENOENT ) { | 87 | if (parentFlag == FALSE && status != -1 && status != ENOENT ) { |
88 | fprintf(stderr, "%s: File exists\n", buf); | 88 | fprintf(stderr, "%s: File exists\n", buf); |
89 | exit( FALSE); | 89 | exit( FALSE); |
90 | } | 90 | } |
@@ -93,7 +93,7 @@ extern int mkdir_main(int argc, char **argv) | |||
93 | createPath(buf, mode); | 93 | createPath(buf, mode); |
94 | } | 94 | } |
95 | else { | 95 | else { |
96 | if (mkdir (buf, mode) != 0) { | 96 | if (mkdir (buf, mode) != 0 && parentFlag == FALSE) { |
97 | perror(buf); | 97 | perror(buf); |
98 | exit( FALSE); | 98 | exit( FALSE); |
99 | } | 99 | } |
diff --git a/docs/CommandList b/docs/CommandList index 39c72a17a..8c0a01e23 100644 --- a/docs/CommandList +++ b/docs/CommandList | |||
@@ -12,6 +12,9 @@ ________________________________________________________________________________ | |||
12 | BusyBox 0.38, Functions and the Arguments they Support | 12 | BusyBox 0.38, Functions and the Arguments they Support |
13 | 13 | ||
14 | 14 | ||
15 | New Apps that have been added to BusyBox since this document was written: | ||
16 | ping, hostname, mkfifo, free, tail, du, tee, head, sort, uniq, lsmod, rmmod, fbset, and loadacm. | ||
17 | |||
15 | 18 | ||
16 | 19 | ||
17 | ______________________________________________________________________________________________________ | 20 | ______________________________________________________________________________________________________ |
@@ -154,7 +157,7 @@ cp [option] fileA fileB | |||
154 | 157 | ||
155 | attributes group permissions and time information. | 158 | attributes group permissions and time information. |
156 | 159 | ||
157 | -R recursive Copy to the current location and all subdirectories in the tree. | 160 | -R recursive Copies directories recursively |
158 | 161 | ||
159 | 162 | ||
160 | 163 | ||
@@ -321,7 +324,7 @@ fsck.minix [-larvsmf] /dev/name | |||
321 | 324 | ||
322 | -r Perform interactive repairs. | 325 | -r Perform interactive repairs. |
323 | 326 | ||
324 | -q Perform automatic repairs | 327 | -a Perform automatic repairs |
325 | 328 | ||
326 | -v Verbose | 329 | -v Verbose |
327 | 330 | ||
@@ -712,29 +715,30 @@ ________________________________________________________________________________ | |||
712 | 715 | ||
713 | 716 | ||
714 | 717 | ||
715 | |||
716 | sed | 718 | sed |
719 | Usage: sed [-n] -e script [file...] | ||
717 | 720 | ||
718 | Sed scripts are subject to the following format: 's/regexp/replacement/[gp]' which attempts to | 721 | Allowed sed scripts come in the following form: |
719 | 722 | 'ADDR [!] COMMAND' | |
720 | to match regexp against the pattern space and if successful, replaces the matched portion with | ||
721 | |||
722 | replacement -r or -R Remove contents of directories recursively. | ||
723 | |||
724 | |||
725 | |||
726 | |||
727 | ________________________________________________________________________________________________________ | ||
728 | |||
729 | |||
730 | |||
731 | |||
732 | 723 | ||
733 | rmdir [OPTION] ... directory | 724 | where address ADDR can be: |
725 | NUMBER Match specified line number | ||
726 | $ Match last line | ||
727 | /REGEXP/ Match specified regexp | ||
728 | (! inverts the meaning of the match) | ||
734 | 729 | ||
735 | Remove directories if they are empty. | 730 | and COMMAND can be: |
731 | s/regexp/replacement/[igp] | ||
732 | which attempt to match regexp against the pattern space | ||
733 | and if successful replaces the matched portion with replacement. | ||
736 | 734 | ||
735 | aTEXT | ||
736 | which appends TEXT after the pattern space | ||
737 | Options: | ||
738 | -e add the script to the commands to be executed | ||
739 | -n suppress automatic printing of pattern space | ||
737 | 740 | ||
741 | This version of sed matches full regular expresions. | ||
738 | 742 | ||
739 | 743 | ||
740 | 744 | ||
@@ -744,51 +748,6 @@ ________________________________________________________________________________ | |||
744 | 748 | ||
745 | 749 | ||
746 | 750 | ||
747 | rmdir [OPTION] ... directory | ||
748 | |||
749 | Remove directories if they are empty. | ||
750 | |||
751 | |||
752 | |||
753 | |||
754 | ________________________________________________________________________________________________________ | ||
755 | |||
756 | |||
757 | |||
758 | |||
759 | |||
760 | sed | ||
761 | |||
762 | Sed scripts are subject to the following format: 's/regexp/replacement/[gp]' which attempts to | ||
763 | |||
764 | match regexp against the pattern space and if successful, replaces the matched portion with | ||
765 | |||
766 | replacement. This version of sed matches | ||
767 | |||
768 | full regular expressions. | ||
769 | |||
770 | -e Add the script to the commands to be executed. | ||
771 | |||
772 | -n Suppress automatic printing of pattern space.. | ||
773 | |||
774 | -e Add the script to the commands to be executed. | ||
775 | |||
776 | -n Suppress automatic printing of pattern space.. | ||
777 | |||
778 | -e Add the script to the commands to be executed. | ||
779 | |||
780 | -n Suppress automatic printing of pattern space. | ||
781 | |||
782 | |||
783 | |||
784 | |||
785 | |||
786 | ________________________________________________________________________________________________________ | ||
787 | |||
788 | |||
789 | |||
790 | |||
791 | |||
792 | sleep N | 751 | sleep N |
793 | 752 | ||
794 | Pause for N seconds. | 753 | Pause for N seconds. |
@@ -977,10 +936,14 @@ ________________________________________________________________________________ | |||
977 | 936 | ||
978 | zcat [options] files | 937 | zcat [options] files |
979 | 938 | ||
980 | Uncompress file from gzip, gunzip or compress command or standard input if file is '-'. | 939 | Usage: zcat [OPTION]... FILE |
981 | 940 | ||
982 | -c Write output to standard output. | 941 | Uncompress FILE (or standard input if FILE is '-'). |
942 | (When invoked as zcat, defaults to having -c turned on) | ||
983 | 943 | ||
944 | Options: | ||
945 | -c Write output to standard output | ||
946 | -t Test compressed file integrity | ||
984 | 947 | ||
985 | 948 | ||
986 | 949 | ||
@@ -991,7 +954,7 @@ ________________________________________________________________________________ | |||
991 | 954 | ||
992 | 955 | ||
993 | 956 | ||
994 | gunzip (Same as zcat) | 957 | gunzip (Same as zcat, but without the "-c" option.) |
995 | 958 | ||
996 | 959 | ||
997 | 960 | ||
@@ -1003,10 +966,13 @@ ________________________________________________________________________________ | |||
1003 | 966 | ||
1004 | 967 | ||
1005 | 968 | ||
969 | gzip [OPTION]... FILE | ||
1006 | 970 | ||
1007 | gzip (Same as zcat) | 971 | Compress FILE with maximum compression. |
1008 | 972 | When FILE is -, reads standard input. Implies -c. | |
1009 | 973 | ||
974 | Options: | ||
975 | -c Write output to standard output instead of FILE.gz | ||
1010 | 976 | ||
1011 | 977 | ||
1012 | 978 | ||
diff --git a/examples/busybox.spec b/examples/busybox.spec index d1a702642..ae7010186 100644 --- a/examples/busybox.spec +++ b/examples/busybox.spec | |||
@@ -1,5 +1,5 @@ | |||
1 | Name: busybox | 1 | Name: busybox |
2 | Version: 0.40 | 2 | Version: 0.41 |
3 | Release: 1 | 3 | Release: 1 |
4 | Group: System/Utilities | 4 | Group: System/Utilities |
5 | Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. | 5 | Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. |
@@ -21,7 +21,7 @@ embedded system. | |||
21 | %setup -q -n %{Name}-%{Version} | 21 | %setup -q -n %{Name}-%{Version} |
22 | 22 | ||
23 | %Build | 23 | %Build |
24 | BB_INIT_SCRIPT='\"/etc/rc.d/init.d/rcS\"' make | 24 | make |
25 | 25 | ||
26 | %Install | 26 | %Install |
27 | rm -rf $RPM_BUILD_ROOT | 27 | rm -rf $RPM_BUILD_ROOT |
@@ -331,7 +331,7 @@ static void console_init() | |||
331 | static pid_t run(char* command, | 331 | static pid_t run(char* command, |
332 | char *terminal, int get_enter) | 332 | char *terminal, int get_enter) |
333 | { | 333 | { |
334 | int i; | 334 | int i, fd; |
335 | pid_t pid; | 335 | pid_t pid; |
336 | char* tmpCmd; | 336 | char* tmpCmd; |
337 | char* cmd[255]; | 337 | char* cmd[255]; |
@@ -357,21 +357,20 @@ static pid_t run(char* command, | |||
357 | close(2); | 357 | close(2); |
358 | setsid(); | 358 | setsid(); |
359 | 359 | ||
360 | if (device_open(terminal, O_RDWR) < 0) { | ||
361 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); | ||
362 | exit(1); | ||
363 | } | ||
364 | dup(0); | ||
365 | dup(0); | ||
366 | tcsetpgrp (0, getpgrp()); | ||
367 | set_term(0); | ||
368 | |||
369 | /* Reset signal handlers set for parent process */ | 360 | /* Reset signal handlers set for parent process */ |
370 | signal(SIGUSR1, SIG_DFL); | 361 | signal(SIGUSR1, SIG_DFL); |
371 | signal(SIGUSR2, SIG_DFL); | 362 | signal(SIGUSR2, SIG_DFL); |
372 | signal(SIGINT, SIG_DFL); | 363 | signal(SIGINT, SIG_DFL); |
373 | signal(SIGTERM, SIG_DFL); | 364 | signal(SIGTERM, SIG_DFL); |
374 | 365 | ||
366 | if ((fd = device_open(terminal, O_RDWR)) < 0) { | ||
367 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); | ||
368 | exit(1); | ||
369 | } | ||
370 | dup(fd); | ||
371 | dup(fd); | ||
372 | tcsetpgrp (0, getpgrp()); | ||
373 | set_term(0); | ||
375 | 374 | ||
376 | if (get_enter==TRUE) { | 375 | if (get_enter==TRUE) { |
377 | /* | 376 | /* |
@@ -389,19 +388,21 @@ static pid_t run(char* command, | |||
389 | read(fileno(stdin), &c, 1); | 388 | read(fileno(stdin), &c, 1); |
390 | } | 389 | } |
391 | 390 | ||
391 | /* Log the process name and args */ | ||
392 | message(LOG|CONSOLE, "Starting pid %d, console %s: '", | ||
393 | shell_pgid, terminal, command); | ||
394 | |||
392 | /* Convert command (char*) into cmd (char**, one word per string) */ | 395 | /* Convert command (char*) into cmd (char**, one word per string) */ |
393 | for (tmpCmd=command, i=0; (tmpCmd=strsep(&command, " \t")) != NULL;) { | 396 | for (tmpCmd=command, i=0; (tmpCmd=strsep(&command, " \t")) != NULL;) { |
394 | if (*tmpCmd != '\0') { | 397 | if (*tmpCmd != '\0') { |
395 | cmd[i] = tmpCmd; | 398 | cmd[i] = tmpCmd; |
399 | message(LOG|CONSOLE, "%s ", tmpCmd); | ||
396 | tmpCmd++; | 400 | tmpCmd++; |
397 | i++; | 401 | i++; |
398 | } | 402 | } |
399 | } | 403 | } |
400 | cmd[i] = NULL; | 404 | cmd[i] = NULL; |
401 | 405 | message(LOG|CONSOLE, "'\r\n"); | |
402 | /* Log the process name and args */ | ||
403 | message(LOG, "Starting pid %d, console %s: '%s'\r\n", | ||
404 | shell_pgid, terminal, cmd[0]); | ||
405 | 406 | ||
406 | /* Now run it. The new program will take over this PID, | 407 | /* Now run it. The new program will take over this PID, |
407 | * so nothing further in init.c should be run. */ | 408 | * so nothing further in init.c should be run. */ |
@@ -540,8 +541,8 @@ void new_initAction (initActionEnum action, | |||
540 | } else | 541 | } else |
541 | strncpy(newAction->console, console, 255); | 542 | strncpy(newAction->console, console, 255); |
542 | newAction->pid = 0; | 543 | newAction->pid = 0; |
543 | // message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", | 544 | message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", |
544 | // newAction->process, newAction->action, newAction->console); | 545 | newAction->process, newAction->action, newAction->console); |
545 | } | 546 | } |
546 | 547 | ||
547 | void delete_initAction (initAction *action) | 548 | void delete_initAction (initAction *action) |
@@ -672,11 +673,8 @@ extern int init_main(int argc, char **argv) | |||
672 | usage( "init\n\nInit is the parent of all processes.\n\n" | 673 | usage( "init\n\nInit is the parent of all processes.\n\n" |
673 | "This version of init is designed to be run only by the kernel\n"); | 674 | "This version of init is designed to be run only by the kernel\n"); |
674 | } | 675 | } |
675 | 676 | /* Set up sig handlers -- be sure to | |
676 | /* from the controlling terminal */ | 677 | * clear all of these in run() */ |
677 | setsid(); | ||
678 | |||
679 | /* Set up sig handlers -- be sure to clear all of these in run() */ | ||
680 | signal(SIGUSR1, halt_signal); | 678 | signal(SIGUSR1, halt_signal); |
681 | signal(SIGUSR2, reboot_signal); | 679 | signal(SIGUSR2, reboot_signal); |
682 | signal(SIGINT, reboot_signal); | 680 | signal(SIGINT, reboot_signal); |
@@ -686,7 +684,7 @@ extern int init_main(int argc, char **argv) | |||
686 | * SIGINT on CAD so we can shut things down gracefully... */ | 684 | * SIGINT on CAD so we can shut things down gracefully... */ |
687 | reboot(RB_DISABLE_CAD); | 685 | reboot(RB_DISABLE_CAD); |
688 | #endif | 686 | #endif |
689 | 687 | ||
690 | /* Figure out where the default console should be */ | 688 | /* Figure out where the default console should be */ |
691 | console_init(); | 689 | console_init(); |
692 | 690 | ||
@@ -695,11 +693,11 @@ extern int init_main(int argc, char **argv) | |||
695 | close(1); | 693 | close(1); |
696 | close(2); | 694 | close(2); |
697 | set_term(0); | 695 | set_term(0); |
696 | setsid(); | ||
698 | 697 | ||
699 | /* Make sure PATH is set to something sane */ | 698 | /* Make sure PATH is set to something sane */ |
700 | putenv(_PATH_STDPATH); | 699 | putenv(_PATH_STDPATH); |
701 | 700 | ||
702 | |||
703 | /* Hello world */ | 701 | /* Hello world */ |
704 | #ifndef DEBUG_INIT | 702 | #ifndef DEBUG_INIT |
705 | message(LOG|CONSOLE, | 703 | message(LOG|CONSOLE, |
diff --git a/init/init.c b/init/init.c index 8a48380e9..b4ab1c751 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -331,7 +331,7 @@ static void console_init() | |||
331 | static pid_t run(char* command, | 331 | static pid_t run(char* command, |
332 | char *terminal, int get_enter) | 332 | char *terminal, int get_enter) |
333 | { | 333 | { |
334 | int i; | 334 | int i, fd; |
335 | pid_t pid; | 335 | pid_t pid; |
336 | char* tmpCmd; | 336 | char* tmpCmd; |
337 | char* cmd[255]; | 337 | char* cmd[255]; |
@@ -357,21 +357,20 @@ static pid_t run(char* command, | |||
357 | close(2); | 357 | close(2); |
358 | setsid(); | 358 | setsid(); |
359 | 359 | ||
360 | if (device_open(terminal, O_RDWR) < 0) { | ||
361 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); | ||
362 | exit(1); | ||
363 | } | ||
364 | dup(0); | ||
365 | dup(0); | ||
366 | tcsetpgrp (0, getpgrp()); | ||
367 | set_term(0); | ||
368 | |||
369 | /* Reset signal handlers set for parent process */ | 360 | /* Reset signal handlers set for parent process */ |
370 | signal(SIGUSR1, SIG_DFL); | 361 | signal(SIGUSR1, SIG_DFL); |
371 | signal(SIGUSR2, SIG_DFL); | 362 | signal(SIGUSR2, SIG_DFL); |
372 | signal(SIGINT, SIG_DFL); | 363 | signal(SIGINT, SIG_DFL); |
373 | signal(SIGTERM, SIG_DFL); | 364 | signal(SIGTERM, SIG_DFL); |
374 | 365 | ||
366 | if ((fd = device_open(terminal, O_RDWR)) < 0) { | ||
367 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); | ||
368 | exit(1); | ||
369 | } | ||
370 | dup(fd); | ||
371 | dup(fd); | ||
372 | tcsetpgrp (0, getpgrp()); | ||
373 | set_term(0); | ||
375 | 374 | ||
376 | if (get_enter==TRUE) { | 375 | if (get_enter==TRUE) { |
377 | /* | 376 | /* |
@@ -389,19 +388,21 @@ static pid_t run(char* command, | |||
389 | read(fileno(stdin), &c, 1); | 388 | read(fileno(stdin), &c, 1); |
390 | } | 389 | } |
391 | 390 | ||
391 | /* Log the process name and args */ | ||
392 | message(LOG|CONSOLE, "Starting pid %d, console %s: '", | ||
393 | shell_pgid, terminal, command); | ||
394 | |||
392 | /* Convert command (char*) into cmd (char**, one word per string) */ | 395 | /* Convert command (char*) into cmd (char**, one word per string) */ |
393 | for (tmpCmd=command, i=0; (tmpCmd=strsep(&command, " \t")) != NULL;) { | 396 | for (tmpCmd=command, i=0; (tmpCmd=strsep(&command, " \t")) != NULL;) { |
394 | if (*tmpCmd != '\0') { | 397 | if (*tmpCmd != '\0') { |
395 | cmd[i] = tmpCmd; | 398 | cmd[i] = tmpCmd; |
399 | message(LOG|CONSOLE, "%s ", tmpCmd); | ||
396 | tmpCmd++; | 400 | tmpCmd++; |
397 | i++; | 401 | i++; |
398 | } | 402 | } |
399 | } | 403 | } |
400 | cmd[i] = NULL; | 404 | cmd[i] = NULL; |
401 | 405 | message(LOG|CONSOLE, "'\r\n"); | |
402 | /* Log the process name and args */ | ||
403 | message(LOG, "Starting pid %d, console %s: '%s'\r\n", | ||
404 | shell_pgid, terminal, cmd[0]); | ||
405 | 406 | ||
406 | /* Now run it. The new program will take over this PID, | 407 | /* Now run it. The new program will take over this PID, |
407 | * so nothing further in init.c should be run. */ | 408 | * so nothing further in init.c should be run. */ |
@@ -540,8 +541,8 @@ void new_initAction (initActionEnum action, | |||
540 | } else | 541 | } else |
541 | strncpy(newAction->console, console, 255); | 542 | strncpy(newAction->console, console, 255); |
542 | newAction->pid = 0; | 543 | newAction->pid = 0; |
543 | // message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", | 544 | message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", |
544 | // newAction->process, newAction->action, newAction->console); | 545 | newAction->process, newAction->action, newAction->console); |
545 | } | 546 | } |
546 | 547 | ||
547 | void delete_initAction (initAction *action) | 548 | void delete_initAction (initAction *action) |
@@ -672,11 +673,8 @@ extern int init_main(int argc, char **argv) | |||
672 | usage( "init\n\nInit is the parent of all processes.\n\n" | 673 | usage( "init\n\nInit is the parent of all processes.\n\n" |
673 | "This version of init is designed to be run only by the kernel\n"); | 674 | "This version of init is designed to be run only by the kernel\n"); |
674 | } | 675 | } |
675 | 676 | /* Set up sig handlers -- be sure to | |
676 | /* from the controlling terminal */ | 677 | * clear all of these in run() */ |
677 | setsid(); | ||
678 | |||
679 | /* Set up sig handlers -- be sure to clear all of these in run() */ | ||
680 | signal(SIGUSR1, halt_signal); | 678 | signal(SIGUSR1, halt_signal); |
681 | signal(SIGUSR2, reboot_signal); | 679 | signal(SIGUSR2, reboot_signal); |
682 | signal(SIGINT, reboot_signal); | 680 | signal(SIGINT, reboot_signal); |
@@ -686,7 +684,7 @@ extern int init_main(int argc, char **argv) | |||
686 | * SIGINT on CAD so we can shut things down gracefully... */ | 684 | * SIGINT on CAD so we can shut things down gracefully... */ |
687 | reboot(RB_DISABLE_CAD); | 685 | reboot(RB_DISABLE_CAD); |
688 | #endif | 686 | #endif |
689 | 687 | ||
690 | /* Figure out where the default console should be */ | 688 | /* Figure out where the default console should be */ |
691 | console_init(); | 689 | console_init(); |
692 | 690 | ||
@@ -695,11 +693,11 @@ extern int init_main(int argc, char **argv) | |||
695 | close(1); | 693 | close(1); |
696 | close(2); | 694 | close(2); |
697 | set_term(0); | 695 | set_term(0); |
696 | setsid(); | ||
698 | 697 | ||
699 | /* Make sure PATH is set to something sane */ | 698 | /* Make sure PATH is set to something sane */ |
700 | putenv(_PATH_STDPATH); | 699 | putenv(_PATH_STDPATH); |
701 | 700 | ||
702 | |||
703 | /* Hello world */ | 701 | /* Hello world */ |
704 | #ifndef DEBUG_INIT | 702 | #ifndef DEBUG_INIT |
705 | message(LOG|CONSOLE, | 703 | message(LOG|CONSOLE, |
diff --git a/internal.h b/internal.h index 1b5c0bc92..49cfcf05c 100644 --- a/internal.h +++ b/internal.h | |||
@@ -125,6 +125,7 @@ extern int touch_main(int argc, char** argv); | |||
125 | extern int tput_main(int argc, char** argv); | 125 | extern int tput_main(int argc, char** argv); |
126 | extern int true_main(int argc, char** argv); | 126 | extern int true_main(int argc, char** argv); |
127 | extern int tryopen_main(int argc, char** argv); | 127 | extern int tryopen_main(int argc, char** argv); |
128 | extern int wc_main(int argc, char** argv); | ||
128 | extern int umount_main(int argc, char** argv); | 129 | extern int umount_main(int argc, char** argv); |
129 | extern int uniq_main(int argc, char** argv); | 130 | extern int uniq_main(int argc, char** argv); |
130 | extern int update_main(int argc, char** argv); | 131 | extern int update_main(int argc, char** argv); |
@@ -84,7 +84,7 @@ extern int mkdir_main(int argc, char **argv) | |||
84 | 84 | ||
85 | strcpy (buf, *argv); | 85 | strcpy (buf, *argv); |
86 | status=stat(buf, &statBuf); | 86 | status=stat(buf, &statBuf); |
87 | if (status != -1 && status != ENOENT ) { | 87 | if (parentFlag == FALSE && status != -1 && status != ENOENT ) { |
88 | fprintf(stderr, "%s: File exists\n", buf); | 88 | fprintf(stderr, "%s: File exists\n", buf); |
89 | exit( FALSE); | 89 | exit( FALSE); |
90 | } | 90 | } |
@@ -93,7 +93,7 @@ extern int mkdir_main(int argc, char **argv) | |||
93 | createPath(buf, mode); | 93 | createPath(buf, mode); |
94 | } | 94 | } |
95 | else { | 95 | else { |
96 | if (mkdir (buf, mode) != 0) { | 96 | if (mkdir (buf, mode) != 0 && parentFlag == FALSE) { |
97 | perror(buf); | 97 | perror(buf); |
98 | exit( FALSE); | 98 | exit( FALSE); |
99 | } | 99 | } |
diff --git a/reg_test.sh b/reg_test.sh index 2a73fc511..8177096a8 100755 --- a/reg_test.sh +++ b/reg_test.sh | |||
@@ -9,7 +9,7 @@ if ! eval diff -u tar.c testdir ; then | |||
9 | echo "Bummer. File copy failed." | 9 | echo "Bummer. File copy failed." |
10 | exit 0 | 10 | exit 0 |
11 | else | 11 | else |
12 | echo "Cool. File copy is ok." | 12 | echo "Cool. 'cp tar.c testdir' is ok." |
13 | fi | 13 | fi |
14 | 14 | ||
15 | rm -rf testdir | 15 | rm -rf testdir |
@@ -20,7 +20,7 @@ if ! eval diff -u tar.c testdir/foo/tar.c ; then | |||
20 | echo "Bummer. File copy to a directory failed." | 20 | echo "Bummer. File copy to a directory failed." |
21 | exit 0 | 21 | exit 0 |
22 | else | 22 | else |
23 | echo "Cool. File copy to a directory is ok." | 23 | echo "Cool. 'cp tar.c testdir/foo' is ok." |
24 | fi | 24 | fi |
25 | 25 | ||
26 | 26 | ||
@@ -32,7 +32,7 @@ if ! eval diff -u tar.c testdir/foo/tar.c ; then | |||
32 | echo "Bummer. File copy to a directory w/ a '/' failed." | 32 | echo "Bummer. File copy to a directory w/ a '/' failed." |
33 | exit 0 | 33 | exit 0 |
34 | else | 34 | else |
35 | echo "Cool. File copy to a directory w/ a '/' is ok." | 35 | echo "Cool. 'cp tar.c testdir/foo/' is ok." |
36 | fi | 36 | fi |
37 | 37 | ||
38 | 38 | ||
@@ -44,7 +44,7 @@ if ! eval diff -ur X11 testdir ; then | |||
44 | echo "Bummer. Local dir copy failed." | 44 | echo "Bummer. Local dir copy failed." |
45 | exit 0 | 45 | exit 0 |
46 | else | 46 | else |
47 | echo "Cool. Local dir copy is ok." | 47 | echo "Cool. 'cp -a X11 testdir' is ok." |
48 | fi | 48 | fi |
49 | 49 | ||
50 | rm -rf testdir X11 | 50 | rm -rf testdir X11 |
@@ -55,7 +55,7 @@ if ! eval diff -ur X11 testdir ; then | |||
55 | echo "Bummer. Local dir copy w/ a '/' failed." | 55 | echo "Bummer. Local dir copy w/ a '/' failed." |
56 | exit 0 | 56 | exit 0 |
57 | else | 57 | else |
58 | echo "Cool. Local dir copy w/ a '/' is ok." | 58 | echo "Cool. 'cp -a X11 testdir/' is ok." |
59 | fi | 59 | fi |
60 | 60 | ||
61 | rm -rf testdir X11 | 61 | rm -rf testdir X11 |
@@ -66,7 +66,7 @@ if ! eval diff -ur X11 testdir ; then | |||
66 | echo "Bummer. Local dir copy w/ a src '/' failed." | 66 | echo "Bummer. Local dir copy w/ a src '/' failed." |
67 | exit 0 | 67 | exit 0 |
68 | else | 68 | else |
69 | echo "Cool. Local dir copy w/ a src '/' is ok." | 69 | echo "Cool. 'cp -a X11/ testdir' is ok." |
70 | fi | 70 | fi |
71 | 71 | ||
72 | rm -rf testdir X11 | 72 | rm -rf testdir X11 |
@@ -77,7 +77,7 @@ if ! eval diff -ur X11 testdir ; then | |||
77 | echo "Bummer. Local dir copy w/ 2x '/'s failed." | 77 | echo "Bummer. Local dir copy w/ 2x '/'s failed." |
78 | exit 0 | 78 | exit 0 |
79 | else | 79 | else |
80 | echo "Cool. Local dir copy w/ 2x '/'s is ok." | 80 | echo "Cool. 'cp -a X11/ testdir/' is ok." |
81 | fi | 81 | fi |
82 | 82 | ||
83 | rm -rf testdir X11 | 83 | rm -rf testdir X11 |
@@ -86,7 +86,7 @@ if ! eval diff -ur /etc/X11 testdir ; then | |||
86 | echo "Bummer. Remote dir copy failed." | 86 | echo "Bummer. Remote dir copy failed." |
87 | exit 0 | 87 | exit 0 |
88 | else | 88 | else |
89 | echo "Cool. Remote dir copy is ok." | 89 | echo "Cool. 'cp -a /etc/X11 testdir' is ok." |
90 | fi | 90 | fi |
91 | 91 | ||
92 | 92 | ||
@@ -98,7 +98,7 @@ if ! eval diff -ur /etc/X11 testdir/foo ; then | |||
98 | echo "Bummer. Remote dir copy to a directory failed." | 98 | echo "Bummer. Remote dir copy to a directory failed." |
99 | exit 0 | 99 | exit 0 |
100 | else | 100 | else |
101 | echo "Cool. Remote dir copy to a directory is ok." | 101 | echo "Cool. 'cp -a /etc/X11 testdir/foo' is ok." |
102 | fi | 102 | fi |
103 | 103 | ||
104 | 104 | ||
@@ -110,7 +110,7 @@ if ! eval diff -ur /etc/X11 testdir/foo ; then | |||
110 | echo "Bummer. Remote dir copy to a directory w/ a '/' failed." | 110 | echo "Bummer. Remote dir copy to a directory w/ a '/' failed." |
111 | exit 0 | 111 | exit 0 |
112 | else | 112 | else |
113 | echo "Cool. Remote dir copy to a directory w/ a '/' is ok." | 113 | echo "Cool. 'cp -a /etc/X11 testdir/foo/' is ok." |
114 | fi | 114 | fi |
115 | 115 | ||
116 | rm -rf testdir | 116 | rm -rf testdir |
@@ -124,14 +124,24 @@ if ! eval ./busybox cp README foo ; then | |||
124 | echo "Bummer. cp README foo failed." | 124 | echo "Bummer. cp README foo failed." |
125 | exit 0 | 125 | exit 0 |
126 | else | 126 | else |
127 | echo "Cool. cp README foo is ok." | 127 | echo "Cool. 'cp README foo' is ok." |
128 | fi | 128 | fi |
129 | 129 | ||
130 | if ! eval ./busybox cp foo/README bar ; then | 130 | if ! eval ./busybox cp foo/README bar ; then |
131 | echo "Bummer. cp foo/README bar failed." | 131 | echo "Bummer. cp foo/README bar failed." |
132 | exit 0 | 132 | exit 0 |
133 | else | 133 | else |
134 | echo "Cool. cp foo/README bar is ok." | 134 | echo "Cool. 'cp foo/README bar' is ok." |
135 | fi | ||
136 | |||
137 | rm -f bar/README | ||
138 | ENVVAR1=foo | ||
139 | ENVVAR2=bar | ||
140 | if ! eval ./busybox cp $ENVVAR1/README $ENVVAR2 ; then | ||
141 | echo "Bummer. cp foo/README bar failed." | ||
142 | exit 0 | ||
143 | else | ||
144 | echo "Cool. 'cp \$ENVVAR1/README \$ENVVAR2' is ok." | ||
135 | fi | 145 | fi |
136 | 146 | ||
137 | rm -rf foo bar | 147 | rm -rf foo bar |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 43e83b191..0be9ded06 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -337,11 +337,13 @@ extern int syslogd_main(int argc, char **argv) | |||
337 | #ifdef BB_KLOGD | 337 | #ifdef BB_KLOGD |
338 | int startKlogd = TRUE; | 338 | int startKlogd = TRUE; |
339 | #endif | 339 | #endif |
340 | int stopDoingThat = FALSE; | ||
340 | char *p; | 341 | char *p; |
341 | char **argv1=argv; | 342 | char **argv1=argv; |
342 | 343 | ||
343 | while (--argc > 0 && **(++argv1) == '-') { | 344 | while (--argc > 0 && **(++argv1) == '-') { |
344 | while (*(++(*argv1))) { | 345 | stopDoingThat = FALSE; |
346 | while (stopDoingThat == FALSE && *(++(*argv1))) { | ||
345 | switch (**argv1) { | 347 | switch (**argv1) { |
346 | case 'm': | 348 | case 'm': |
347 | if (--argc == 0) { | 349 | if (--argc == 0) { |
@@ -362,6 +364,7 @@ extern int syslogd_main(int argc, char **argv) | |||
362 | usage(syslogd_usage); | 364 | usage(syslogd_usage); |
363 | } | 365 | } |
364 | logFilePath = *(++argv1); | 366 | logFilePath = *(++argv1); |
367 | stopDoingThat = TRUE; | ||
365 | break; | 368 | break; |
366 | default: | 369 | default: |
367 | usage(syslogd_usage); | 370 | usage(syslogd_usage); |
@@ -337,11 +337,13 @@ extern int syslogd_main(int argc, char **argv) | |||
337 | #ifdef BB_KLOGD | 337 | #ifdef BB_KLOGD |
338 | int startKlogd = TRUE; | 338 | int startKlogd = TRUE; |
339 | #endif | 339 | #endif |
340 | int stopDoingThat = FALSE; | ||
340 | char *p; | 341 | char *p; |
341 | char **argv1=argv; | 342 | char **argv1=argv; |
342 | 343 | ||
343 | while (--argc > 0 && **(++argv1) == '-') { | 344 | while (--argc > 0 && **(++argv1) == '-') { |
344 | while (*(++(*argv1))) { | 345 | stopDoingThat = FALSE; |
346 | while (stopDoingThat == FALSE && *(++(*argv1))) { | ||
345 | switch (**argv1) { | 347 | switch (**argv1) { |
346 | case 'm': | 348 | case 'm': |
347 | if (--argc == 0) { | 349 | if (--argc == 0) { |
@@ -362,6 +364,7 @@ extern int syslogd_main(int argc, char **argv) | |||
362 | usage(syslogd_usage); | 364 | usage(syslogd_usage); |
363 | } | 365 | } |
364 | logFilePath = *(++argv1); | 366 | logFilePath = *(++argv1); |
367 | stopDoingThat = TRUE; | ||
365 | break; | 368 | break; |
366 | default: | 369 | default: |
367 | usage(syslogd_usage); | 370 | usage(syslogd_usage); |
diff --git a/true_false.c b/true_false.c index feaa9297d..eb9466b7b 100644 --- a/true_false.c +++ b/true_false.c | |||
@@ -27,12 +27,12 @@ | |||
27 | extern int | 27 | extern int |
28 | true_main(int argc, char** argv) | 28 | true_main(int argc, char** argv) |
29 | { | 29 | { |
30 | return( TRUE); | 30 | exit( TRUE); |
31 | } | 31 | } |
32 | 32 | ||
33 | extern int | 33 | extern int |
34 | false_main(int argc, char** argv) | 34 | false_main(int argc, char** argv) |
35 | { | 35 | { |
36 | return( FALSE); | 36 | exit( FALSE); |
37 | } | 37 | } |
38 | 38 | ||
@@ -396,7 +396,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir | |||
396 | int (*dirAction) (const char *fileName, struct stat* statbuf)) | 396 | int (*dirAction) (const char *fileName, struct stat* statbuf)) |
397 | { | 397 | { |
398 | int status; | 398 | int status; |
399 | struct stat statbuf; | 399 | struct stat statbuf, statbuf1; |
400 | struct dirent *next; | 400 | struct dirent *next; |
401 | 401 | ||
402 | if (followLinks == TRUE) | 402 | if (followLinks == TRUE) |
@@ -404,6 +404,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir | |||
404 | else | 404 | else |
405 | status = lstat(fileName, &statbuf); | 405 | status = lstat(fileName, &statbuf); |
406 | 406 | ||
407 | status = lstat(fileName, &statbuf); | ||
407 | if (status < 0) { | 408 | if (status < 0) { |
408 | perror(fileName); | 409 | perror(fileName); |
409 | return (FALSE); | 410 | return (FALSE); |
@@ -424,8 +425,14 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir | |||
424 | return (TRUE); | 425 | return (TRUE); |
425 | } | 426 | } |
426 | } | 427 | } |
428 | |||
429 | status = lstat(fileName, &statbuf1); | ||
430 | if (status < 0) { | ||
431 | perror(fileName); | ||
432 | return (FALSE); | ||
433 | } | ||
427 | 434 | ||
428 | if (S_ISDIR(statbuf.st_mode)) { | 435 | if (S_ISDIR(statbuf.st_mode) && S_ISDIR(statbuf1.st_mode)) { |
429 | DIR *dir; | 436 | DIR *dir; |
430 | dir = opendir(fileName); | 437 | dir = opendir(fileName); |
431 | if (!dir) { | 438 | if (!dir) { |