diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-09-05 20:18:15 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-09-05 20:18:15 +0000 |
commit | 1644db9a2bc153373a2c27e7622a5486bf648114 (patch) | |
tree | 2ac9e45b8b09398acee6bcaa30a8f9c706a126ca | |
parent | b9408504f5bc74a71435162e1c86ce7b60b9530b (diff) | |
download | busybox-w32-1644db9a2bc153373a2c27e7622a5486bf648114.tar.gz busybox-w32-1644db9a2bc153373a2c27e7622a5486bf648114.tar.bz2 busybox-w32-1644db9a2bc153373a2c27e7622a5486bf648114.zip |
Two patches from Magick <magick@linux-fan.com>:
1st makes init smaller, and fixes a bug with AskFirst. Reading from
/dev/null gives EOF.
2nd makes init run the command's in the order of inittab, as in
FIFO instead of LIFO.
-rw-r--r-- | Changelog | 3 | ||||
-rw-r--r-- | init.c | 43 | ||||
-rw-r--r-- | init/init.c | 43 |
3 files changed, 51 insertions, 38 deletions
@@ -19,6 +19,9 @@ | |||
19 | -- Fix sed s/[/]// handling (closes: #1208). | 19 | -- Fix sed s/[/]// handling (closes: #1208). |
20 | -- Fix `-/bin/sh' invocation (closes: #1209). | 20 | -- Fix `-/bin/sh' invocation (closes: #1209). |
21 | -- Fix ash exec (noted by Arne Bernin). | 21 | -- Fix ash exec (noted by Arne Bernin). |
22 | * Magick | ||
23 | -- maked init run inittab command's in inittab order ( | ||
24 | (i.e. FIFO instead of LIFO). | ||
22 | 25 | ||
23 | 26 | ||
24 | -Erik Andersen, --not yet released-- | 27 | -Erik Andersen, --not yet released-- |
@@ -203,9 +203,7 @@ static void message(int device, char *fmt, ...) | |||
203 | va_start(arguments, fmt); | 203 | va_start(arguments, fmt); |
204 | vsnprintf(msg, sizeof(msg), fmt, arguments); | 204 | vsnprintf(msg, sizeof(msg), fmt, arguments); |
205 | va_end(arguments); | 205 | va_end(arguments); |
206 | openlog(applet_name, 0, LOG_USER); | 206 | syslog_msg(LOG_USER, LOG_USER|LOG_INFO, msg); |
207 | syslog(LOG_USER|LOG_INFO, msg); | ||
208 | closelog(); | ||
209 | } | 207 | } |
210 | #else | 208 | #else |
211 | static int log_fd = -1; | 209 | static int log_fd = -1; |
@@ -703,6 +701,9 @@ static void ctrlaltdel_signal(int sig) | |||
703 | static void new_initAction(initActionEnum action, char *process, char *cons) | 701 | static void new_initAction(initActionEnum action, char *process, char *cons) |
704 | { | 702 | { |
705 | initAction *newAction; | 703 | initAction *newAction; |
704 | #ifdef BB_FEATURE_INIT_NORMAL_ORDER | ||
705 | initAction *a; | ||
706 | #endif | ||
706 | 707 | ||
707 | if (*cons == '\0') | 708 | if (*cons == '\0') |
708 | cons = console; | 709 | cons = console; |
@@ -714,14 +715,25 @@ static void new_initAction(initActionEnum action, char *process, char *cons) | |||
714 | if (secondConsole == NULL && strcmp(cons, console) | 715 | if (secondConsole == NULL && strcmp(cons, console) |
715 | && strcmp(cons, "/dev/null")) | 716 | && strcmp(cons, "/dev/null")) |
716 | return; | 717 | return; |
718 | if (strcmp(cons, "/dev/null") == 0 && action == ASKFIRST) | ||
719 | return; | ||
717 | 720 | ||
718 | newAction = calloc((size_t) (1), sizeof(initAction)); | 721 | newAction = calloc((size_t) (1), sizeof(initAction)); |
719 | if (!newAction) { | 722 | if (!newAction) { |
720 | message(LOG | CONSOLE, "Memory allocation failure\n"); | 723 | message(LOG | CONSOLE, "Memory allocation failure\n"); |
721 | loop_forever(); | 724 | loop_forever(); |
722 | } | 725 | } |
726 | #ifdef BB_FEATURE_INIT_NORMAL_ORDER | ||
727 | for (a = initActionList; a && a->nextPtr; a = a->nextPtr) ; | ||
728 | if (a) { | ||
729 | a->nextPtr = newAction; | ||
730 | } else { | ||
731 | initActionList = newAction; | ||
732 | } | ||
733 | #else | ||
723 | newAction->nextPtr = initActionList; | 734 | newAction->nextPtr = initActionList; |
724 | initActionList = newAction; | 735 | initActionList = newAction; |
736 | #endif | ||
725 | strncpy(newAction->process, process, 255); | 737 | strncpy(newAction->process, process, 255); |
726 | newAction->action = action; | 738 | newAction->action = action; |
727 | strncpy(newAction->console, cons, 255); | 739 | strncpy(newAction->console, cons, 255); |
@@ -770,10 +782,17 @@ static void parse_inittab(void) | |||
770 | #endif | 782 | #endif |
771 | /* Reboot on Ctrl-Alt-Del */ | 783 | /* Reboot on Ctrl-Alt-Del */ |
772 | new_initAction(CTRLALTDEL, "/sbin/reboot", console); | 784 | new_initAction(CTRLALTDEL, "/sbin/reboot", console); |
785 | #ifdef BB_FEATURE_INIT_NORMAL_ORDER | ||
786 | /* Umount all filesystems on halt/reboot */ | ||
787 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); | ||
788 | /* Swapoff on halt/reboot */ | ||
789 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); | ||
790 | #else | ||
773 | /* Swapoff on halt/reboot */ | 791 | /* Swapoff on halt/reboot */ |
774 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); | 792 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); |
775 | /* Umount all filesystems on halt/reboot */ | 793 | /* Umount all filesystems on halt/reboot */ |
776 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); | 794 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); |
795 | #endif | ||
777 | /* Askfirst shell on tty1 */ | 796 | /* Askfirst shell on tty1 */ |
778 | new_initAction(ASKFIRST, LOGIN_SHELL, console); | 797 | new_initAction(ASKFIRST, LOGIN_SHELL, console); |
779 | /* Askfirst shell on tty2 */ | 798 | /* Askfirst shell on tty2 */ |
@@ -960,23 +979,9 @@ extern int init_main(int argc, char **argv) | |||
960 | /* Now run everything that needs to be run */ | 979 | /* Now run everything that needs to be run */ |
961 | 980 | ||
962 | /* First run the sysinit command */ | 981 | /* First run the sysinit command */ |
963 | for (a = initActionList; a; a = tmp) { | 982 | run_actions(SYSINIT); |
964 | tmp = a->nextPtr; | ||
965 | if (a->action == SYSINIT) { | ||
966 | waitfor(a->process, a->console, FALSE); | ||
967 | /* Now remove the "sysinit" entry from the list */ | ||
968 | delete_initAction(a); | ||
969 | } | ||
970 | } | ||
971 | /* Next run anything that wants to block */ | 983 | /* Next run anything that wants to block */ |
972 | for (a = initActionList; a; a = tmp) { | 984 | run_actions(WAIT); |
973 | tmp = a->nextPtr; | ||
974 | if (a->action == WAIT) { | ||
975 | waitfor(a->process, a->console, FALSE); | ||
976 | /* Now remove the "wait" entry from the list */ | ||
977 | delete_initAction(a); | ||
978 | } | ||
979 | } | ||
980 | /* Next run anything to be run only once */ | 985 | /* Next run anything to be run only once */ |
981 | for (a = initActionList; a; a = tmp) { | 986 | for (a = initActionList; a; a = tmp) { |
982 | tmp = a->nextPtr; | 987 | tmp = a->nextPtr; |
diff --git a/init/init.c b/init/init.c index f397b7e0a..17273afcd 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -203,9 +203,7 @@ static void message(int device, char *fmt, ...) | |||
203 | va_start(arguments, fmt); | 203 | va_start(arguments, fmt); |
204 | vsnprintf(msg, sizeof(msg), fmt, arguments); | 204 | vsnprintf(msg, sizeof(msg), fmt, arguments); |
205 | va_end(arguments); | 205 | va_end(arguments); |
206 | openlog(applet_name, 0, LOG_USER); | 206 | syslog_msg(LOG_USER, LOG_USER|LOG_INFO, msg); |
207 | syslog(LOG_USER|LOG_INFO, msg); | ||
208 | closelog(); | ||
209 | } | 207 | } |
210 | #else | 208 | #else |
211 | static int log_fd = -1; | 209 | static int log_fd = -1; |
@@ -703,6 +701,9 @@ static void ctrlaltdel_signal(int sig) | |||
703 | static void new_initAction(initActionEnum action, char *process, char *cons) | 701 | static void new_initAction(initActionEnum action, char *process, char *cons) |
704 | { | 702 | { |
705 | initAction *newAction; | 703 | initAction *newAction; |
704 | #ifdef BB_FEATURE_INIT_NORMAL_ORDER | ||
705 | initAction *a; | ||
706 | #endif | ||
706 | 707 | ||
707 | if (*cons == '\0') | 708 | if (*cons == '\0') |
708 | cons = console; | 709 | cons = console; |
@@ -714,14 +715,25 @@ static void new_initAction(initActionEnum action, char *process, char *cons) | |||
714 | if (secondConsole == NULL && strcmp(cons, console) | 715 | if (secondConsole == NULL && strcmp(cons, console) |
715 | && strcmp(cons, "/dev/null")) | 716 | && strcmp(cons, "/dev/null")) |
716 | return; | 717 | return; |
718 | if (strcmp(cons, "/dev/null") == 0 && action == ASKFIRST) | ||
719 | return; | ||
717 | 720 | ||
718 | newAction = calloc((size_t) (1), sizeof(initAction)); | 721 | newAction = calloc((size_t) (1), sizeof(initAction)); |
719 | if (!newAction) { | 722 | if (!newAction) { |
720 | message(LOG | CONSOLE, "Memory allocation failure\n"); | 723 | message(LOG | CONSOLE, "Memory allocation failure\n"); |
721 | loop_forever(); | 724 | loop_forever(); |
722 | } | 725 | } |
726 | #ifdef BB_FEATURE_INIT_NORMAL_ORDER | ||
727 | for (a = initActionList; a && a->nextPtr; a = a->nextPtr) ; | ||
728 | if (a) { | ||
729 | a->nextPtr = newAction; | ||
730 | } else { | ||
731 | initActionList = newAction; | ||
732 | } | ||
733 | #else | ||
723 | newAction->nextPtr = initActionList; | 734 | newAction->nextPtr = initActionList; |
724 | initActionList = newAction; | 735 | initActionList = newAction; |
736 | #endif | ||
725 | strncpy(newAction->process, process, 255); | 737 | strncpy(newAction->process, process, 255); |
726 | newAction->action = action; | 738 | newAction->action = action; |
727 | strncpy(newAction->console, cons, 255); | 739 | strncpy(newAction->console, cons, 255); |
@@ -770,10 +782,17 @@ static void parse_inittab(void) | |||
770 | #endif | 782 | #endif |
771 | /* Reboot on Ctrl-Alt-Del */ | 783 | /* Reboot on Ctrl-Alt-Del */ |
772 | new_initAction(CTRLALTDEL, "/sbin/reboot", console); | 784 | new_initAction(CTRLALTDEL, "/sbin/reboot", console); |
785 | #ifdef BB_FEATURE_INIT_NORMAL_ORDER | ||
786 | /* Umount all filesystems on halt/reboot */ | ||
787 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); | ||
788 | /* Swapoff on halt/reboot */ | ||
789 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); | ||
790 | #else | ||
773 | /* Swapoff on halt/reboot */ | 791 | /* Swapoff on halt/reboot */ |
774 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); | 792 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); |
775 | /* Umount all filesystems on halt/reboot */ | 793 | /* Umount all filesystems on halt/reboot */ |
776 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); | 794 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); |
795 | #endif | ||
777 | /* Askfirst shell on tty1 */ | 796 | /* Askfirst shell on tty1 */ |
778 | new_initAction(ASKFIRST, LOGIN_SHELL, console); | 797 | new_initAction(ASKFIRST, LOGIN_SHELL, console); |
779 | /* Askfirst shell on tty2 */ | 798 | /* Askfirst shell on tty2 */ |
@@ -960,23 +979,9 @@ extern int init_main(int argc, char **argv) | |||
960 | /* Now run everything that needs to be run */ | 979 | /* Now run everything that needs to be run */ |
961 | 980 | ||
962 | /* First run the sysinit command */ | 981 | /* First run the sysinit command */ |
963 | for (a = initActionList; a; a = tmp) { | 982 | run_actions(SYSINIT); |
964 | tmp = a->nextPtr; | ||
965 | if (a->action == SYSINIT) { | ||
966 | waitfor(a->process, a->console, FALSE); | ||
967 | /* Now remove the "sysinit" entry from the list */ | ||
968 | delete_initAction(a); | ||
969 | } | ||
970 | } | ||
971 | /* Next run anything that wants to block */ | 983 | /* Next run anything that wants to block */ |
972 | for (a = initActionList; a; a = tmp) { | 984 | run_actions(WAIT); |
973 | tmp = a->nextPtr; | ||
974 | if (a->action == WAIT) { | ||
975 | waitfor(a->process, a->console, FALSE); | ||
976 | /* Now remove the "wait" entry from the list */ | ||
977 | delete_initAction(a); | ||
978 | } | ||
979 | } | ||
980 | /* Next run anything to be run only once */ | 985 | /* Next run anything to be run only once */ |
981 | for (a = initActionList; a; a = tmp) { | 986 | for (a = initActionList; a; a = tmp) { |
982 | tmp = a->nextPtr; | 987 | tmp = a->nextPtr; |