diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-03-20 21:34:52 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-03-20 21:34:52 +0000 |
commit | 42094cdad5cf87a660c8c74ce101ce61353cfb10 (patch) | |
tree | fe836e929430c0310115ed9c417e7c872e1f3e4f | |
parent | 1dbe340ebab31aa85446e83e8bc42f184b59b25b (diff) | |
download | busybox-w32-42094cdad5cf87a660c8c74ce101ce61353cfb10.tar.gz busybox-w32-42094cdad5cf87a660c8c74ce101ce61353cfb10.tar.bz2 busybox-w32-42094cdad5cf87a660c8c74ce101ce61353cfb10.zip |
Fix bug in memory total checking.
-Erik
-rw-r--r-- | init.c | 81 | ||||
-rw-r--r-- | init/init.c | 81 |
2 files changed, 80 insertions, 82 deletions
@@ -28,51 +28,50 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "internal.h" | 30 | #include "internal.h" |
31 | #include <stdio.h> | 31 | #include <asm/types.h> |
32 | #include <string.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <stdarg.h> | ||
35 | #include <unistd.h> | ||
36 | #include <errno.h> | 32 | #include <errno.h> |
37 | #include <signal.h> | 33 | #include <linux/serial.h> /* for serial_struct */ |
38 | #include <termios.h> | 34 | #include <linux/version.h> |
39 | #include <paths.h> | 35 | #include <paths.h> |
40 | #include <sys/types.h> | 36 | #include <signal.h> |
41 | #include <sys/fcntl.h> | 37 | #include <stdarg.h> |
42 | #include <sys/wait.h> | 38 | #include <stdio.h> |
39 | #include <stdlib.h> | ||
43 | #include <string.h> | 40 | #include <string.h> |
41 | #include <sys/fcntl.h> | ||
42 | #include <sys/ioctl.h> | ||
43 | #include <sys/kdaemon.h> | ||
44 | #include <sys/mount.h> | 44 | #include <sys/mount.h> |
45 | #include <sys/reboot.h> | 45 | #include <sys/reboot.h> |
46 | #include <sys/kdaemon.h> | ||
47 | #include <sys/sysmacros.h> | ||
48 | #include <asm/types.h> | ||
49 | #include <linux/serial.h> /* for serial_struct */ | ||
50 | #include <sys/vt.h> /* for vt_stat */ | ||
51 | #include <sys/ioctl.h> | ||
52 | #include <sys/sysinfo.h> /* For check_free_memory() */ | 46 | #include <sys/sysinfo.h> /* For check_free_memory() */ |
53 | #include <linux/version.h> | ||
54 | #ifdef BB_SYSLOGD | 47 | #ifdef BB_SYSLOGD |
55 | #include <sys/syslog.h> | 48 | #include <sys/syslog.h> |
56 | #endif | 49 | #endif |
50 | #include <sys/sysmacros.h> | ||
51 | #include <sys/types.h> | ||
52 | #include <sys/vt.h> /* for vt_stat */ | ||
53 | #include <sys/wait.h> | ||
54 | #include <termios.h> | ||
55 | #include <unistd.h> | ||
57 | 56 | ||
58 | #ifndef KERNEL_VERSION | 57 | #ifndef KERNEL_VERSION |
59 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) | 58 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
60 | #endif | 59 | #endif |
61 | 60 | ||
62 | 61 | ||
63 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ | 62 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ |
64 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ | 63 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ |
65 | #define VT_LOG "/dev/tty3" /* Virtual console */ | 64 | #define VT_LOG "/dev/tty3" /* Virtual console */ |
66 | #define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */ | 65 | #define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */ |
67 | #define SERIAL_CON1 "/dev/ttyS1" /* Serial console */ | 66 | #define SERIAL_CON1 "/dev/ttyS1" /* Serial console */ |
68 | #define SHELL "/bin/sh" /* Default shell */ | 67 | #define SHELL "/bin/sh" /* Default shell */ |
69 | #define INITTAB "/etc/inittab" /* inittab file location */ | 68 | #define INITTAB "/etc/inittab" /* inittab file location */ |
70 | #ifndef INIT_SCRIPT | 69 | #ifndef INIT_SCRIPT |
71 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ | 70 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ |
72 | #endif | 71 | #endif |
73 | 72 | ||
74 | #define LOG 0x1 | 73 | #define LOG 0x1 |
75 | #define CONSOLE 0x2 | 74 | #define CONSOLE 0x2 |
76 | 75 | ||
77 | /* Allowed init action types */ | 76 | /* Allowed init action types */ |
78 | typedef enum { | 77 | typedef enum { |
@@ -84,7 +83,7 @@ typedef enum { | |||
84 | CTRLALTDEL | 83 | CTRLALTDEL |
85 | } initActionEnum; | 84 | } initActionEnum; |
86 | 85 | ||
87 | /* And now a list of the actions we support in the version of init */ | 86 | /* A mapping between "inittab" action name strings and action type codes. */ |
88 | typedef struct initActionType { | 87 | typedef struct initActionType { |
89 | const char *name; | 88 | const char *name; |
90 | initActionEnum action; | 89 | initActionEnum action; |
@@ -100,7 +99,7 @@ static const struct initActionType actions[] = { | |||
100 | {0} | 99 | {0} |
101 | }; | 100 | }; |
102 | 101 | ||
103 | /* Set up a linked list of initactions, to be read from inittab */ | 102 | /* Set up a linked list of initActions, to be read from inittab */ |
104 | typedef struct initActionTag initAction; | 103 | typedef struct initActionTag initAction; |
105 | struct initActionTag { | 104 | struct initActionTag { |
106 | pid_t pid; | 105 | pid_t pid; |
@@ -113,16 +112,17 @@ initAction *initActionList = NULL; | |||
113 | 112 | ||
114 | 113 | ||
115 | static char *secondConsole = VT_SECONDARY; | 114 | static char *secondConsole = VT_SECONDARY; |
116 | static char *log = VT_LOG; | 115 | static char *log = VT_LOG; |
117 | static int kernelVersion = 0; | 116 | static int kernelVersion = 0; |
118 | static char termType[32] = "TERM=linux"; | 117 | static char termType[32] = "TERM=linux"; |
119 | static char console[32] = _PATH_CONSOLE; | 118 | static char console[32] = _PATH_CONSOLE; |
119 | |||
120 | static void delete_initAction(initAction * action); | 120 | static void delete_initAction(initAction * action); |
121 | 121 | ||
122 | 122 | ||
123 | /* print a message to the specified device: | 123 | /* Print a message to the specified device. |
124 | * device may be bitwise-or'd from LOG | CONSOLE */ | 124 | * Device may be bitwise-or'd from LOG | CONSOLE */ |
125 | void message(int device, char *fmt, ...) | 125 | static void message(int device, char *fmt, ...) |
126 | { | 126 | { |
127 | va_list arguments; | 127 | va_list arguments; |
128 | int fd; | 128 | int fd; |
@@ -235,8 +235,7 @@ static int check_free_memory() | |||
235 | return -1; | 235 | return -1; |
236 | } | 236 | } |
237 | 237 | ||
238 | return(info.freeram/1024); | 238 | return((info.totalram+info.totalswap)/1024); |
239 | |||
240 | } | 239 | } |
241 | 240 | ||
242 | static void console_init() | 241 | static void console_init() |
@@ -738,7 +737,7 @@ void parse_inittab(void) | |||
738 | ++p; | 737 | ++p; |
739 | } | 738 | } |
740 | 739 | ||
741 | /* Now peal off the process field from the end | 740 | /* Now peel off the process field from the end |
742 | * of the string */ | 741 | * of the string */ |
743 | q = strrchr(p, ':'); | 742 | q = strrchr(p, ':'); |
744 | if (q == NULL || *(q + 1) == '\0') { | 743 | if (q == NULL || *(q + 1) == '\0') { |
@@ -749,7 +748,7 @@ void parse_inittab(void) | |||
749 | ++q; | 748 | ++q; |
750 | } | 749 | } |
751 | 750 | ||
752 | /* Now peal off the action field */ | 751 | /* Now peel off the action field */ |
753 | r = strrchr(p, ':'); | 752 | r = strrchr(p, ':'); |
754 | if (r == NULL || *(r + 1) == '\0') { | 753 | if (r == NULL || *(r + 1) == '\0') { |
755 | message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead); | 754 | message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead); |
@@ -788,7 +787,7 @@ void parse_inittab(void) | |||
788 | } | 787 | } |
789 | } | 788 | } |
790 | return; | 789 | return; |
791 | #endif | 790 | #endif /* BB_FEATURE_USE_INITTAB */ |
792 | } | 791 | } |
793 | 792 | ||
794 | 793 | ||
diff --git a/init/init.c b/init/init.c index f0124a225..de5e2c05f 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -28,51 +28,50 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "internal.h" | 30 | #include "internal.h" |
31 | #include <stdio.h> | 31 | #include <asm/types.h> |
32 | #include <string.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <stdarg.h> | ||
35 | #include <unistd.h> | ||
36 | #include <errno.h> | 32 | #include <errno.h> |
37 | #include <signal.h> | 33 | #include <linux/serial.h> /* for serial_struct */ |
38 | #include <termios.h> | 34 | #include <linux/version.h> |
39 | #include <paths.h> | 35 | #include <paths.h> |
40 | #include <sys/types.h> | 36 | #include <signal.h> |
41 | #include <sys/fcntl.h> | 37 | #include <stdarg.h> |
42 | #include <sys/wait.h> | 38 | #include <stdio.h> |
39 | #include <stdlib.h> | ||
43 | #include <string.h> | 40 | #include <string.h> |
41 | #include <sys/fcntl.h> | ||
42 | #include <sys/ioctl.h> | ||
43 | #include <sys/kdaemon.h> | ||
44 | #include <sys/mount.h> | 44 | #include <sys/mount.h> |
45 | #include <sys/reboot.h> | 45 | #include <sys/reboot.h> |
46 | #include <sys/kdaemon.h> | ||
47 | #include <sys/sysmacros.h> | ||
48 | #include <asm/types.h> | ||
49 | #include <linux/serial.h> /* for serial_struct */ | ||
50 | #include <sys/vt.h> /* for vt_stat */ | ||
51 | #include <sys/ioctl.h> | ||
52 | #include <sys/sysinfo.h> /* For check_free_memory() */ | 46 | #include <sys/sysinfo.h> /* For check_free_memory() */ |
53 | #include <linux/version.h> | ||
54 | #ifdef BB_SYSLOGD | 47 | #ifdef BB_SYSLOGD |
55 | #include <sys/syslog.h> | 48 | #include <sys/syslog.h> |
56 | #endif | 49 | #endif |
50 | #include <sys/sysmacros.h> | ||
51 | #include <sys/types.h> | ||
52 | #include <sys/vt.h> /* for vt_stat */ | ||
53 | #include <sys/wait.h> | ||
54 | #include <termios.h> | ||
55 | #include <unistd.h> | ||
57 | 56 | ||
58 | #ifndef KERNEL_VERSION | 57 | #ifndef KERNEL_VERSION |
59 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) | 58 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
60 | #endif | 59 | #endif |
61 | 60 | ||
62 | 61 | ||
63 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ | 62 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ |
64 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ | 63 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ |
65 | #define VT_LOG "/dev/tty3" /* Virtual console */ | 64 | #define VT_LOG "/dev/tty3" /* Virtual console */ |
66 | #define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */ | 65 | #define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */ |
67 | #define SERIAL_CON1 "/dev/ttyS1" /* Serial console */ | 66 | #define SERIAL_CON1 "/dev/ttyS1" /* Serial console */ |
68 | #define SHELL "/bin/sh" /* Default shell */ | 67 | #define SHELL "/bin/sh" /* Default shell */ |
69 | #define INITTAB "/etc/inittab" /* inittab file location */ | 68 | #define INITTAB "/etc/inittab" /* inittab file location */ |
70 | #ifndef INIT_SCRIPT | 69 | #ifndef INIT_SCRIPT |
71 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ | 70 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ |
72 | #endif | 71 | #endif |
73 | 72 | ||
74 | #define LOG 0x1 | 73 | #define LOG 0x1 |
75 | #define CONSOLE 0x2 | 74 | #define CONSOLE 0x2 |
76 | 75 | ||
77 | /* Allowed init action types */ | 76 | /* Allowed init action types */ |
78 | typedef enum { | 77 | typedef enum { |
@@ -84,7 +83,7 @@ typedef enum { | |||
84 | CTRLALTDEL | 83 | CTRLALTDEL |
85 | } initActionEnum; | 84 | } initActionEnum; |
86 | 85 | ||
87 | /* And now a list of the actions we support in the version of init */ | 86 | /* A mapping between "inittab" action name strings and action type codes. */ |
88 | typedef struct initActionType { | 87 | typedef struct initActionType { |
89 | const char *name; | 88 | const char *name; |
90 | initActionEnum action; | 89 | initActionEnum action; |
@@ -100,7 +99,7 @@ static const struct initActionType actions[] = { | |||
100 | {0} | 99 | {0} |
101 | }; | 100 | }; |
102 | 101 | ||
103 | /* Set up a linked list of initactions, to be read from inittab */ | 102 | /* Set up a linked list of initActions, to be read from inittab */ |
104 | typedef struct initActionTag initAction; | 103 | typedef struct initActionTag initAction; |
105 | struct initActionTag { | 104 | struct initActionTag { |
106 | pid_t pid; | 105 | pid_t pid; |
@@ -113,16 +112,17 @@ initAction *initActionList = NULL; | |||
113 | 112 | ||
114 | 113 | ||
115 | static char *secondConsole = VT_SECONDARY; | 114 | static char *secondConsole = VT_SECONDARY; |
116 | static char *log = VT_LOG; | 115 | static char *log = VT_LOG; |
117 | static int kernelVersion = 0; | 116 | static int kernelVersion = 0; |
118 | static char termType[32] = "TERM=linux"; | 117 | static char termType[32] = "TERM=linux"; |
119 | static char console[32] = _PATH_CONSOLE; | 118 | static char console[32] = _PATH_CONSOLE; |
119 | |||
120 | static void delete_initAction(initAction * action); | 120 | static void delete_initAction(initAction * action); |
121 | 121 | ||
122 | 122 | ||
123 | /* print a message to the specified device: | 123 | /* Print a message to the specified device. |
124 | * device may be bitwise-or'd from LOG | CONSOLE */ | 124 | * Device may be bitwise-or'd from LOG | CONSOLE */ |
125 | void message(int device, char *fmt, ...) | 125 | static void message(int device, char *fmt, ...) |
126 | { | 126 | { |
127 | va_list arguments; | 127 | va_list arguments; |
128 | int fd; | 128 | int fd; |
@@ -235,8 +235,7 @@ static int check_free_memory() | |||
235 | return -1; | 235 | return -1; |
236 | } | 236 | } |
237 | 237 | ||
238 | return(info.freeram/1024); | 238 | return((info.totalram+info.totalswap)/1024); |
239 | |||
240 | } | 239 | } |
241 | 240 | ||
242 | static void console_init() | 241 | static void console_init() |
@@ -738,7 +737,7 @@ void parse_inittab(void) | |||
738 | ++p; | 737 | ++p; |
739 | } | 738 | } |
740 | 739 | ||
741 | /* Now peal off the process field from the end | 740 | /* Now peel off the process field from the end |
742 | * of the string */ | 741 | * of the string */ |
743 | q = strrchr(p, ':'); | 742 | q = strrchr(p, ':'); |
744 | if (q == NULL || *(q + 1) == '\0') { | 743 | if (q == NULL || *(q + 1) == '\0') { |
@@ -749,7 +748,7 @@ void parse_inittab(void) | |||
749 | ++q; | 748 | ++q; |
750 | } | 749 | } |
751 | 750 | ||
752 | /* Now peal off the action field */ | 751 | /* Now peel off the action field */ |
753 | r = strrchr(p, ':'); | 752 | r = strrchr(p, ':'); |
754 | if (r == NULL || *(r + 1) == '\0') { | 753 | if (r == NULL || *(r + 1) == '\0') { |
755 | message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead); | 754 | message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead); |
@@ -788,7 +787,7 @@ void parse_inittab(void) | |||
788 | } | 787 | } |
789 | } | 788 | } |
790 | return; | 789 | return; |
791 | #endif | 790 | #endif /* BB_FEATURE_USE_INITTAB */ |
792 | } | 791 | } |
793 | 792 | ||
794 | 793 | ||