aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-07 11:40:44 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-07 11:40:44 +0000
commit96e2abd0849c1980dad10013ef0d17027554ef9f (patch)
treeb4313983e7883b477552c881868bc6709f9857d0
parent286b0de74da3cba56b8cc7961a19044eb45969b2 (diff)
downloadbusybox-w32-96e2abd0849c1980dad10013ef0d17027554ef9f.tar.gz
busybox-w32-96e2abd0849c1980dad10013ef0d17027554ef9f.tar.bz2
busybox-w32-96e2abd0849c1980dad10013ef0d17027554ef9f.zip
Init is now even more perfect then before.
-Erik
-rw-r--r--Makefile6
-rw-r--r--busybox.def.h13
-rw-r--r--busybox.spec2
-rw-r--r--examples/busybox.spec2
-rw-r--r--init.c46
-rw-r--r--init/init.c46
-rwxr-xr-xreg_test.sh40
7 files changed, 74 insertions, 81 deletions
diff --git a/Makefile b/Makefile
index 73aa2fc90..6f49f0a52 100644
--- a/Makefile
+++ b/Makefile
@@ -80,12 +80,8 @@ LIBRARIES=
80OBJECTS=$(shell ./busybox.sh) 80OBJECTS=$(shell ./busybox.sh)
81CFLAGS+= -DBB_VER='"$(VERSION)"' 81CFLAGS+= -DBB_VER='"$(VERSION)"'
82CFLAGS+= -DBB_BT='"$(BUILDTIME)"' 82CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
83ifdef BB_INIT_RC_EXIT_CMD
84 CFLAGS += -DBB_INIT_CMD_IF_RC_SCRIPT_EXITS=${BB_INIT_RC_EXIT_CMD}
85endif
86
87ifdef BB_INIT_SCRIPT 83ifdef BB_INIT_SCRIPT
88 CFLAGS += -DBB_INIT_SCRIPT=${BB_INIT_SCRIPT} 84 CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT}
89endif 85endif
90 86
91all: busybox busybox.links 87all: busybox busybox.links
diff --git a/busybox.def.h b/busybox.def.h
index 032146519..834555302 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -88,6 +88,12 @@
88// 88//
89// 89//
90// 90//
91// Don't turn BB_UTILITY off. It contains support code
92// that compiles to 0 if everything else if turned off.
93#define BB_UTILITY
94//
95//
96//
91// This is where feature definitions go. Generally speaking, 97// This is where feature definitions go. Generally speaking,
92// turning this stuff off makes things a bit smaller (and less 98// turning this stuff off makes things a bit smaller (and less
93// pretty/useful). 99// pretty/useful).
@@ -113,10 +119,3 @@
113//Enable init being called as /linuxrc 119//Enable init being called as /linuxrc
114#define BB_FEATURE_LINUXRC 120#define BB_FEATURE_LINUXRC
115// 121//
116//
117//
118// Don't turn BB_UTILITY off. It contains support code
119// that compiles to 0 if everything else if turned off.
120#define BB_UTILITY
121//
122//
diff --git a/busybox.spec b/busybox.spec
index a8520074e..d1a702642 100644
--- a/busybox.spec
+++ b/busybox.spec
@@ -21,7 +21,7 @@ embedded system.
21%setup -q -n %{Name}-%{Version} 21%setup -q -n %{Name}-%{Version}
22 22
23%Build 23%Build
24BB_INIT_RC_EXIT_CMD=\"/bin/sh\" BB_INIT_SCRIPT=\"/etc/rc.d/init.d/rcS\" make 24BB_INIT_SCRIPT='\"/etc/rc.d/init.d/rcS\"' make
25 25
26%Install 26%Install
27rm -rf $RPM_BUILD_ROOT 27rm -rf $RPM_BUILD_ROOT
diff --git a/examples/busybox.spec b/examples/busybox.spec
index a8520074e..d1a702642 100644
--- a/examples/busybox.spec
+++ b/examples/busybox.spec
@@ -21,7 +21,7 @@ embedded system.
21%setup -q -n %{Name}-%{Version} 21%setup -q -n %{Name}-%{Version}
22 22
23%Build 23%Build
24BB_INIT_RC_EXIT_CMD=\"/bin/sh\" BB_INIT_SCRIPT=\"/etc/rc.d/init.d/rcS\" make 24BB_INIT_SCRIPT='\"/etc/rc.d/init.d/rcS\"' make
25 25
26%Install 26%Install
27rm -rf $RPM_BUILD_ROOT 27rm -rf $RPM_BUILD_ROOT
diff --git a/init.c b/init.c
index 0472208c5..88b8ed1c1 100644
--- a/init.c
+++ b/init.c
@@ -61,9 +61,11 @@
61#define VT_LOG "/dev/tty3" /* Virtual console */ 61#define VT_LOG "/dev/tty3" /* Virtual console */
62#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */ 62#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */
63#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */ 63#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */
64#define SHELL "-sh" /* Default shell */ 64#define SHELL "/bin/sh" /* Default shell */
65#define INITTAB "/etc/inittab" /* inittab file location */ 65#define INITTAB "/etc/inittab" /* inittab file location */
66#ifndef INIT_SCRIPT
66#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ 67#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
68#endif
67 69
68#define LOG 0x1 70#define LOG 0x1
69#define CONSOLE 0x2 71#define CONSOLE 0x2
@@ -330,6 +332,7 @@ static pid_t run(char* command,
330 "\nPlease press Enter to activate this console. "; 332 "\nPlease press Enter to activate this console. ";
331 333
332 if ((pid = fork()) == 0) { 334 if ((pid = fork()) == 0) {
335 int fd;
333 pid_t shell_pgid = getpid (); 336 pid_t shell_pgid = getpid ();
334 337
335 /* Clean up */ 338 /* Clean up */
@@ -338,17 +341,14 @@ static pid_t run(char* command,
338 close(2); 341 close(2);
339 setsid(); 342 setsid();
340 343
341 if (device_open(terminal, O_RDWR) < 0) { 344 if ((fd=device_open(terminal, O_RDWR)) < 0) {
342 message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); 345 message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal);
343 exit(1); 346 exit(1);
344 } 347 }
345 dup(0); 348 dup(fd);
346 dup(0); 349 dup(fd);
347 /* Grab control of the terminal. */ 350 set_term(fd);
348 if (tcsetpgrp (0, getpgrp()) < 0) { 351 tcsetpgrp (fd, getpgrp());
349 message(LOG|CONSOLE, "tcsetpgrp error: %s\r\n", strerror(errno));
350 }
351 set_term(0);
352 352
353 /* Reset signal handlers set for parent process */ 353 /* Reset signal handlers set for parent process */
354 signal(SIGUSR1, SIG_DFL); 354 signal(SIGUSR1, SIG_DFL);
@@ -497,7 +497,7 @@ static void reboot_signal(int sig)
497 497
498#endif 498#endif
499 499
500void new_initAction (const struct initActionType *a, 500void new_initAction (initActionEnum action,
501 char* process, char* cons) 501 char* process, char* cons)
502{ 502{
503 initAction* newAction; 503 initAction* newAction;
@@ -517,7 +517,7 @@ void new_initAction (const struct initActionType *a,
517 newAction->nextPtr = initActionList; 517 newAction->nextPtr = initActionList;
518 initActionList = newAction; 518 initActionList = newAction;
519 strncpy( newAction->process, process, 255); 519 strncpy( newAction->process, process, 255);
520 newAction->action = a->action; 520 newAction->action = action;
521 if (*cons != '\0') { 521 if (*cons != '\0') {
522 strncpy(newAction->console, cons, 255); 522 strncpy(newAction->console, cons, 255);
523 } else 523 } else
@@ -561,12 +561,12 @@ void parse_inittab(void)
561 /* No inittab file -- set up some default behavior */ 561 /* No inittab file -- set up some default behavior */
562#endif 562#endif
563 /* Askfirst shell on tty1 */ 563 /* Askfirst shell on tty1 */
564 new_initAction( &(actions[3]), SHELL, console ); 564 new_initAction( ASKFIRST, SHELL, console );
565 /* Askfirst shell on tty2 */ 565 /* Askfirst shell on tty2 */
566 if (second_console != NULL) 566 if (second_console != NULL)
567 new_initAction( &(actions[3]), SHELL, second_console ); 567 new_initAction( ASKFIRST, SHELL, second_console );
568 /* sysinit */ 568 /* sysinit */
569 new_initAction( &(actions[0]), INIT_SCRIPT, console ); 569 new_initAction( SYSINIT, INIT_SCRIPT, console );
570 570
571 return; 571 return;
572#ifdef BB_FEATURE_USE_INITTAB 572#ifdef BB_FEATURE_USE_INITTAB
@@ -584,7 +584,6 @@ void parse_inittab(void)
584 584
585 /* Keep a copy around for posterity's sake (and error msgs) */ 585 /* Keep a copy around for posterity's sake (and error msgs) */
586 strcpy(lineAsRead, buf); 586 strcpy(lineAsRead, buf);
587message(LOG|CONSOLE, "read='%s'\n", lineAsRead);
588 587
589 /* Grab the ID field */ 588 /* Grab the ID field */
590 s=p; 589 s=p;
@@ -628,7 +627,7 @@ message(LOG|CONSOLE, "read='%s'\n", lineAsRead);
628 } 627 }
629 s = tmpConsole; 628 s = tmpConsole;
630 } 629 }
631 new_initAction( a, q, s); 630 new_initAction( a->action, q, s);
632 foundIt=TRUE; 631 foundIt=TRUE;
633 } 632 }
634 a++; 633 a++;
@@ -712,9 +711,9 @@ extern int init_main(int argc, char **argv)
712 { 711 {
713 /* Ask first then start a shell on tty2 */ 712 /* Ask first then start a shell on tty2 */
714 if (second_console != NULL) 713 if (second_console != NULL)
715 new_initAction( &(actions[3]), SHELL, second_console); 714 new_initAction( ASKFIRST, SHELL, second_console);
716 /* Ask first then start a shell on tty1 */ 715 /* Ask first then start a shell on tty1 */
717 new_initAction( &(actions[3]), SHELL, console); 716 new_initAction( ASKFIRST, SHELL, console);
718 } else { 717 } else {
719 /* Not in single user mode -- see what inittab says */ 718 /* Not in single user mode -- see what inittab says */
720 719
@@ -731,7 +730,7 @@ extern int init_main(int argc, char **argv)
731 /* First run the sysinit command */ 730 /* First run the sysinit command */
732 for( a=initActionList ; a; a=a->nextPtr) { 731 for( a=initActionList ; a; a=a->nextPtr) {
733 if (a->action == SYSINIT) { 732 if (a->action == SYSINIT) {
734 waitfor(a->process, console, FALSE); 733 waitfor(a->process, a->console, FALSE);
735 /* Now remove the "sysinit" entry from the list */ 734 /* Now remove the "sysinit" entry from the list */
736 delete_initAction( a); 735 delete_initAction( a);
737 } 736 }
@@ -739,7 +738,7 @@ extern int init_main(int argc, char **argv)
739 /* Next run anything that wants to block */ 738 /* Next run anything that wants to block */
740 for( a=initActionList ; a; a=a->nextPtr) { 739 for( a=initActionList ; a; a=a->nextPtr) {
741 if (a->action == WAIT) { 740 if (a->action == WAIT) {
742 waitfor(a->process, console, FALSE); 741 waitfor(a->process, a->console, FALSE);
743 /* Now remove the "wait" entry from the list */ 742 /* Now remove the "wait" entry from the list */
744 delete_initAction( a); 743 delete_initAction( a);
745 } 744 }
@@ -747,7 +746,7 @@ extern int init_main(int argc, char **argv)
747 /* Next run anything to be run only once */ 746 /* Next run anything to be run only once */
748 for( a=initActionList ; a; a=a->nextPtr) { 747 for( a=initActionList ; a; a=a->nextPtr) {
749 if (a->action == ONCE) { 748 if (a->action == ONCE) {
750 run(a->process, console, FALSE); 749 run(a->process, a->console, FALSE);
751 /* Now remove the "once" entry from the list */ 750 /* Now remove the "once" entry from the list */
752 delete_initAction( a); 751 delete_initAction( a);
753 } 752 }
@@ -760,7 +759,6 @@ extern int init_main(int argc, char **argv)
760 759
761 /* Now run the looping stuff for the rest of forever */ 760 /* Now run the looping stuff for the rest of forever */
762 while (1) { 761 while (1) {
763 message(LOG|CONSOLE, "Looping\n");
764 for( a=initActionList ; a; a=a->nextPtr) { 762 for( a=initActionList ; a; a=a->nextPtr) {
765 /* Only run stuff with pid==0. If they have 763 /* Only run stuff with pid==0. If they have
766 * a pid, that means they are still running */ 764 * a pid, that means they are still running */
@@ -768,11 +766,11 @@ extern int init_main(int argc, char **argv)
768 switch(a->action) { 766 switch(a->action) {
769 case RESPAWN: 767 case RESPAWN:
770 /* run the respawn stuff */ 768 /* run the respawn stuff */
771 a->pid = run(a->process, console, FALSE); 769 a->pid = run(a->process, a->console, FALSE);
772 break; 770 break;
773 case ASKFIRST: 771 case ASKFIRST:
774 /* run the askfirst stuff */ 772 /* run the askfirst stuff */
775 a->pid = run(a->process, console, TRUE); 773 a->pid = run(a->process, a->console, TRUE);
776 break; 774 break;
777 /* silence the compiler's incessant whining */ 775 /* silence the compiler's incessant whining */
778 default: 776 default:
diff --git a/init/init.c b/init/init.c
index 0472208c5..88b8ed1c1 100644
--- a/init/init.c
+++ b/init/init.c
@@ -61,9 +61,11 @@
61#define VT_LOG "/dev/tty3" /* Virtual console */ 61#define VT_LOG "/dev/tty3" /* Virtual console */
62#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */ 62#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */
63#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */ 63#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */
64#define SHELL "-sh" /* Default shell */ 64#define SHELL "/bin/sh" /* Default shell */
65#define INITTAB "/etc/inittab" /* inittab file location */ 65#define INITTAB "/etc/inittab" /* inittab file location */
66#ifndef INIT_SCRIPT
66#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ 67#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
68#endif
67 69
68#define LOG 0x1 70#define LOG 0x1
69#define CONSOLE 0x2 71#define CONSOLE 0x2
@@ -330,6 +332,7 @@ static pid_t run(char* command,
330 "\nPlease press Enter to activate this console. "; 332 "\nPlease press Enter to activate this console. ";
331 333
332 if ((pid = fork()) == 0) { 334 if ((pid = fork()) == 0) {
335 int fd;
333 pid_t shell_pgid = getpid (); 336 pid_t shell_pgid = getpid ();
334 337
335 /* Clean up */ 338 /* Clean up */
@@ -338,17 +341,14 @@ static pid_t run(char* command,
338 close(2); 341 close(2);
339 setsid(); 342 setsid();
340 343
341 if (device_open(terminal, O_RDWR) < 0) { 344 if ((fd=device_open(terminal, O_RDWR)) < 0) {
342 message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); 345 message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal);
343 exit(1); 346 exit(1);
344 } 347 }
345 dup(0); 348 dup(fd);
346 dup(0); 349 dup(fd);
347 /* Grab control of the terminal. */ 350 set_term(fd);
348 if (tcsetpgrp (0, getpgrp()) < 0) { 351 tcsetpgrp (fd, getpgrp());
349 message(LOG|CONSOLE, "tcsetpgrp error: %s\r\n", strerror(errno));
350 }
351 set_term(0);
352 352
353 /* Reset signal handlers set for parent process */ 353 /* Reset signal handlers set for parent process */
354 signal(SIGUSR1, SIG_DFL); 354 signal(SIGUSR1, SIG_DFL);
@@ -497,7 +497,7 @@ static void reboot_signal(int sig)
497 497
498#endif 498#endif
499 499
500void new_initAction (const struct initActionType *a, 500void new_initAction (initActionEnum action,
501 char* process, char* cons) 501 char* process, char* cons)
502{ 502{
503 initAction* newAction; 503 initAction* newAction;
@@ -517,7 +517,7 @@ void new_initAction (const struct initActionType *a,
517 newAction->nextPtr = initActionList; 517 newAction->nextPtr = initActionList;
518 initActionList = newAction; 518 initActionList = newAction;
519 strncpy( newAction->process, process, 255); 519 strncpy( newAction->process, process, 255);
520 newAction->action = a->action; 520 newAction->action = action;
521 if (*cons != '\0') { 521 if (*cons != '\0') {
522 strncpy(newAction->console, cons, 255); 522 strncpy(newAction->console, cons, 255);
523 } else 523 } else
@@ -561,12 +561,12 @@ void parse_inittab(void)
561 /* No inittab file -- set up some default behavior */ 561 /* No inittab file -- set up some default behavior */
562#endif 562#endif
563 /* Askfirst shell on tty1 */ 563 /* Askfirst shell on tty1 */
564 new_initAction( &(actions[3]), SHELL, console ); 564 new_initAction( ASKFIRST, SHELL, console );
565 /* Askfirst shell on tty2 */ 565 /* Askfirst shell on tty2 */
566 if (second_console != NULL) 566 if (second_console != NULL)
567 new_initAction( &(actions[3]), SHELL, second_console ); 567 new_initAction( ASKFIRST, SHELL, second_console );
568 /* sysinit */ 568 /* sysinit */
569 new_initAction( &(actions[0]), INIT_SCRIPT, console ); 569 new_initAction( SYSINIT, INIT_SCRIPT, console );
570 570
571 return; 571 return;
572#ifdef BB_FEATURE_USE_INITTAB 572#ifdef BB_FEATURE_USE_INITTAB
@@ -584,7 +584,6 @@ void parse_inittab(void)
584 584
585 /* Keep a copy around for posterity's sake (and error msgs) */ 585 /* Keep a copy around for posterity's sake (and error msgs) */
586 strcpy(lineAsRead, buf); 586 strcpy(lineAsRead, buf);
587message(LOG|CONSOLE, "read='%s'\n", lineAsRead);
588 587
589 /* Grab the ID field */ 588 /* Grab the ID field */
590 s=p; 589 s=p;
@@ -628,7 +627,7 @@ message(LOG|CONSOLE, "read='%s'\n", lineAsRead);
628 } 627 }
629 s = tmpConsole; 628 s = tmpConsole;
630 } 629 }
631 new_initAction( a, q, s); 630 new_initAction( a->action, q, s);
632 foundIt=TRUE; 631 foundIt=TRUE;
633 } 632 }
634 a++; 633 a++;
@@ -712,9 +711,9 @@ extern int init_main(int argc, char **argv)
712 { 711 {
713 /* Ask first then start a shell on tty2 */ 712 /* Ask first then start a shell on tty2 */
714 if (second_console != NULL) 713 if (second_console != NULL)
715 new_initAction( &(actions[3]), SHELL, second_console); 714 new_initAction( ASKFIRST, SHELL, second_console);
716 /* Ask first then start a shell on tty1 */ 715 /* Ask first then start a shell on tty1 */
717 new_initAction( &(actions[3]), SHELL, console); 716 new_initAction( ASKFIRST, SHELL, console);
718 } else { 717 } else {
719 /* Not in single user mode -- see what inittab says */ 718 /* Not in single user mode -- see what inittab says */
720 719
@@ -731,7 +730,7 @@ extern int init_main(int argc, char **argv)
731 /* First run the sysinit command */ 730 /* First run the sysinit command */
732 for( a=initActionList ; a; a=a->nextPtr) { 731 for( a=initActionList ; a; a=a->nextPtr) {
733 if (a->action == SYSINIT) { 732 if (a->action == SYSINIT) {
734 waitfor(a->process, console, FALSE); 733 waitfor(a->process, a->console, FALSE);
735 /* Now remove the "sysinit" entry from the list */ 734 /* Now remove the "sysinit" entry from the list */
736 delete_initAction( a); 735 delete_initAction( a);
737 } 736 }
@@ -739,7 +738,7 @@ extern int init_main(int argc, char **argv)
739 /* Next run anything that wants to block */ 738 /* Next run anything that wants to block */
740 for( a=initActionList ; a; a=a->nextPtr) { 739 for( a=initActionList ; a; a=a->nextPtr) {
741 if (a->action == WAIT) { 740 if (a->action == WAIT) {
742 waitfor(a->process, console, FALSE); 741 waitfor(a->process, a->console, FALSE);
743 /* Now remove the "wait" entry from the list */ 742 /* Now remove the "wait" entry from the list */
744 delete_initAction( a); 743 delete_initAction( a);
745 } 744 }
@@ -747,7 +746,7 @@ extern int init_main(int argc, char **argv)
747 /* Next run anything to be run only once */ 746 /* Next run anything to be run only once */
748 for( a=initActionList ; a; a=a->nextPtr) { 747 for( a=initActionList ; a; a=a->nextPtr) {
749 if (a->action == ONCE) { 748 if (a->action == ONCE) {
750 run(a->process, console, FALSE); 749 run(a->process, a->console, FALSE);
751 /* Now remove the "once" entry from the list */ 750 /* Now remove the "once" entry from the list */
752 delete_initAction( a); 751 delete_initAction( a);
753 } 752 }
@@ -760,7 +759,6 @@ extern int init_main(int argc, char **argv)
760 759
761 /* Now run the looping stuff for the rest of forever */ 760 /* Now run the looping stuff for the rest of forever */
762 while (1) { 761 while (1) {
763 message(LOG|CONSOLE, "Looping\n");
764 for( a=initActionList ; a; a=a->nextPtr) { 762 for( a=initActionList ; a; a=a->nextPtr) {
765 /* Only run stuff with pid==0. If they have 763 /* Only run stuff with pid==0. If they have
766 * a pid, that means they are still running */ 764 * a pid, that means they are still running */
@@ -768,11 +766,11 @@ extern int init_main(int argc, char **argv)
768 switch(a->action) { 766 switch(a->action) {
769 case RESPAWN: 767 case RESPAWN:
770 /* run the respawn stuff */ 768 /* run the respawn stuff */
771 a->pid = run(a->process, console, FALSE); 769 a->pid = run(a->process, a->console, FALSE);
772 break; 770 break;
773 case ASKFIRST: 771 case ASKFIRST:
774 /* run the askfirst stuff */ 772 /* run the askfirst stuff */
775 a->pid = run(a->process, console, TRUE); 773 a->pid = run(a->process, a->console, TRUE);
776 break; 774 break;
777 /* silence the compiler's incessant whining */ 775 /* silence the compiler's incessant whining */
778 default: 776 default:
diff --git a/reg_test.sh b/reg_test.sh
index 0a30ae305..2a73fc511 100755
--- a/reg_test.sh
+++ b/reg_test.sh
@@ -6,26 +6,22 @@ rm -rf testdir
6./busybox cp tar.c testdir 6./busybox cp tar.c testdir
7 7
8if ! eval diff -u tar.c testdir ; then 8if ! eval diff -u tar.c testdir ; then
9 echo " "
10 echo "Bummer. File copy failed." 9 echo "Bummer. File copy failed."
11 exit 0 10 exit 0
12else 11else
13 echo "Cool. File copy is ok." 12 echo "Cool. File copy is ok."
14fi 13fi
15echo " "
16 14
17rm -rf testdir 15rm -rf testdir
18mkdir -p testdir/foo 16mkdir -p testdir/foo
19./busybox cp tar.c testdir/foo 17./busybox cp tar.c testdir/foo
20 18
21if ! eval diff -u tar.c testdir/foo/tar.c ; then 19if ! eval diff -u tar.c testdir/foo/tar.c ; then
22 echo " "
23 echo "Bummer. File copy to a directory failed." 20 echo "Bummer. File copy to a directory failed."
24 exit 0 21 exit 0
25else 22else
26 echo "Cool. File copy to a directory is ok." 23 echo "Cool. File copy to a directory is ok."
27fi 24fi
28echo " "
29 25
30 26
31rm -rf testdir 27rm -rf testdir
@@ -33,13 +29,11 @@ mkdir -p testdir/foo
33./busybox cp tar.c testdir/foo/ 29./busybox cp tar.c testdir/foo/
34 30
35if ! eval diff -u tar.c testdir/foo/tar.c ; then 31if ! eval diff -u tar.c testdir/foo/tar.c ; then
36 echo " "
37 echo "Bummer. File copy to a directory w/ a '/' failed." 32 echo "Bummer. File copy to a directory w/ a '/' failed."
38 exit 0 33 exit 0
39else 34else
40 echo "Cool. File copy to a directory w/ a '/' is ok." 35 echo "Cool. File copy to a directory w/ a '/' is ok."
41fi 36fi
42echo " "
43 37
44 38
45rm -rf testdir X11 39rm -rf testdir X11
@@ -47,63 +41,53 @@ cp -a /etc/X11 .
47./busybox cp -a X11 testdir 41./busybox cp -a X11 testdir
48 42
49if ! eval diff -ur X11 testdir ; then 43if ! eval diff -ur X11 testdir ; then
50 echo " "
51 echo "Bummer. Local dir copy failed." 44 echo "Bummer. Local dir copy failed."
52 exit 0 45 exit 0
53else 46else
54 echo "Cool. Local dir copy is ok." 47 echo "Cool. Local dir copy is ok."
55fi 48fi
56echo " "
57 49
58rm -rf testdir X11 50rm -rf testdir X11
59cp -a /etc/X11 . 51cp -a /etc/X11 .
60./busybox cp -a X11 testdir/ 52./busybox cp -a X11 testdir/
61 53
62if ! eval diff -ur X11 testdir ; then 54if ! eval diff -ur X11 testdir ; then
63 echo " "
64 echo "Bummer. Local dir copy w/ a '/' failed." 55 echo "Bummer. Local dir copy w/ a '/' failed."
65 exit 0 56 exit 0
66else 57else
67 echo "Cool. Local dir copy w/ a '/' is ok." 58 echo "Cool. Local dir copy w/ a '/' is ok."
68fi 59fi
69echo " "
70 60
71rm -rf testdir X11 61rm -rf testdir X11
72cp -a /etc/X11 . 62cp -a /etc/X11 .
73./busybox cp -a X11/ testdir 63./busybox cp -a X11/ testdir
74 64
75if ! eval diff -ur X11 testdir ; then 65if ! eval diff -ur X11 testdir ; then
76 echo " "
77 echo "Bummer. Local dir copy w/ a src '/' failed." 66 echo "Bummer. Local dir copy w/ a src '/' failed."
78 exit 0 67 exit 0
79else 68else
80 echo "Cool. Local dir copy w/ a src '/' is ok." 69 echo "Cool. Local dir copy w/ a src '/' is ok."
81fi 70fi
82echo " "
83 71
84rm -rf testdir X11 72rm -rf testdir X11
85cp -a /etc/X11 . 73cp -a /etc/X11 .
86./busybox cp -a X11/ testdir/ 74./busybox cp -a X11/ testdir/
87 75
88if ! eval diff -ur X11 testdir ; then 76if ! eval diff -ur X11 testdir ; then
89 echo " "
90 echo "Bummer. Local dir copy w/ 2x '/'s failed." 77 echo "Bummer. Local dir copy w/ 2x '/'s failed."
91 exit 0 78 exit 0
92else 79else
93 echo "Cool. Local dir copy w/ 2x '/'s is ok." 80 echo "Cool. Local dir copy w/ 2x '/'s is ok."
94fi 81fi
95echo " "
96 82
97rm -rf testdir X11 83rm -rf testdir X11
98./busybox cp -a /etc/X11 testdir 84./busybox cp -a /etc/X11 testdir
99if ! eval diff -ur /etc/X11 testdir ; then 85if ! eval diff -ur /etc/X11 testdir ; then
100 echo " "
101 echo "Bummer. Remote dir copy failed." 86 echo "Bummer. Remote dir copy failed."
102 exit 0 87 exit 0
103else 88else
104 echo "Cool. Remote dir copy is ok." 89 echo "Cool. Remote dir copy is ok."
105fi 90fi
106echo " "
107 91
108 92
109rm -rf testdir X11 93rm -rf testdir X11
@@ -111,13 +95,11 @@ mkdir -p testdir/foo
111 95
112./busybox cp -a /etc/X11 testdir/foo 96./busybox cp -a /etc/X11 testdir/foo
113if ! eval diff -ur /etc/X11 testdir/foo ; then 97if ! eval diff -ur /etc/X11 testdir/foo ; then
114 echo " "
115 echo "Bummer. Remote dir copy to a directory failed." 98 echo "Bummer. Remote dir copy to a directory failed."
116 exit 0 99 exit 0
117else 100else
118 echo "Cool. Remote dir copy to a directory is ok." 101 echo "Cool. Remote dir copy to a directory is ok."
119fi 102fi
120echo " "
121 103
122 104
123rm -rf testdir X11 105rm -rf testdir X11
@@ -125,7 +107,6 @@ mkdir -p testdir/foo
125 107
126./busybox cp -a /etc/X11 testdir/foo/ 108./busybox cp -a /etc/X11 testdir/foo/
127if ! eval diff -ur /etc/X11 testdir/foo ; then 109if ! eval diff -ur /etc/X11 testdir/foo ; then
128 echo " "
129 echo "Bummer. Remote dir copy to a directory w/ a '/' failed." 110 echo "Bummer. Remote dir copy to a directory w/ a '/' failed."
130 exit 0 111 exit 0
131else 112else
@@ -134,3 +115,24 @@ fi
134 115
135rm -rf testdir 116rm -rf testdir
136 117
118
119rm -rf foo bar
120mkdir foo
121mkdir bar
122
123if ! eval ./busybox cp README foo ; then
124 echo "Bummer. cp README foo failed."
125 exit 0
126else
127 echo "Cool. cp README foo is ok."
128fi
129
130if ! eval ./busybox cp foo/README bar ; then
131 echo "Bummer. cp foo/README bar failed."
132 exit 0
133else
134 echo "Cool. cp foo/README bar is ok."
135fi
136
137rm -rf foo bar
138