diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-12-05 23:24:55 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-12-05 23:24:55 +0000 |
commit | 0ecb54a0f3fece5e42f089036f059973bed8d87e (patch) | |
tree | e25c3d29c9c92fed488e03459b2aee558b1a8d25 | |
parent | 14ec6cf3c224d53219b2713b0040dfa03314d5b3 (diff) | |
download | busybox-w32-0ecb54a0f3fece5e42f089036f059973bed8d87e.tar.gz busybox-w32-0ecb54a0f3fece5e42f089036f059973bed8d87e.tar.bz2 busybox-w32-0ecb54a0f3fece5e42f089036f059973bed8d87e.zip |
Stuf
-rw-r--r-- | Changelog | 7 | ||||
-rw-r--r-- | busybox.def.h | 2 | ||||
-rw-r--r-- | init.c | 5 | ||||
-rw-r--r-- | init/init.c | 5 | ||||
-rw-r--r-- | mount.c | 5 | ||||
-rw-r--r-- | mtab.c | 15 | ||||
-rw-r--r-- | procps/ps.c | 3 | ||||
-rw-r--r-- | ps.c | 3 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 31 | ||||
-rw-r--r-- | syslogd.c | 31 | ||||
-rw-r--r-- | util-linux/mount.c | 5 | ||||
-rw-r--r-- | utility.c | 15 |
12 files changed, 66 insertions, 61 deletions
@@ -8,7 +8,12 @@ | |||
8 | was causing some confusing and unexpected behavior. | 8 | was causing some confusing and unexpected behavior. |
9 | * Added klogd to syslogd, so now the log will contain both system and | 9 | * Added klogd to syslogd, so now the log will contain both system and |
10 | kernel messages. | 10 | kernel messages. |
11 | 11 | * syslogd now creates the /dev/log socket to make sure it is there, and | |
12 | is actually a socket with the right permissions. | ||
13 | * I've taken a first step to making busybox not need the /proc filesystem. | ||
14 | Most apps don't need it. Those that _require_ it, will complain | ||
15 | if you enable them when you disable BB_FEATURE_USE_PROCFS. | ||
16 | |||
12 | -Erik Andrsen | 17 | -Erik Andrsen |
13 | 18 | ||
14 | 0.37 | 19 | 0.37 |
diff --git a/busybox.def.h b/busybox.def.h index bf8f54556..a1f55ffe6 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -74,6 +74,8 @@ | |||
74 | // pretty/useful). | 74 | // pretty/useful). |
75 | // | 75 | // |
76 | // | 76 | // |
77 | // enable features that use the /proc filesystem | ||
78 | #define BB_FEATURE_USE_PROCFS | ||
77 | //Enable init being called as /linuxrc | 79 | //Enable init being called as /linuxrc |
78 | #define BB_FEATURE_LINUXRC | 80 | #define BB_FEATURE_LINUXRC |
79 | // Use termios to manipulate the screen ('more' is prettier with this on) | 81 | // Use termios to manipulate the screen ('more' is prettier with this on) |
@@ -45,6 +45,11 @@ | |||
45 | #include <sys/syslog.h> | 45 | #include <sys/syslog.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #if ! defined BB_FEATURE_USE_PROCFS | ||
49 | #error Sorry, I depend on the /proc filesystem right now. | ||
50 | #endif | ||
51 | |||
52 | |||
48 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ | 53 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ |
49 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ | 54 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ |
50 | #define VT_LOG "/dev/tty3" /* Virtual console */ | 55 | #define VT_LOG "/dev/tty3" /* Virtual console */ |
diff --git a/init/init.c b/init/init.c index 088a890cc..84b558d84 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -45,6 +45,11 @@ | |||
45 | #include <sys/syslog.h> | 45 | #include <sys/syslog.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #if ! defined BB_FEATURE_USE_PROCFS | ||
49 | #error Sorry, I depend on the /proc filesystem right now. | ||
50 | #endif | ||
51 | |||
52 | |||
48 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ | 53 | #define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ |
49 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ | 54 | #define VT_SECONDARY "/dev/tty2" /* Virtual console */ |
50 | #define VT_LOG "/dev/tty3" /* Virtual console */ | 55 | #define VT_LOG "/dev/tty3" /* Virtual console */ |
@@ -163,6 +163,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, | |||
163 | 163 | ||
164 | char buf[255]; | 164 | char buf[255]; |
165 | 165 | ||
166 | #if defined BB_FEATURE_USE_PROCFS | ||
166 | if (strcmp(filesystemType, "auto") == 0) { | 167 | if (strcmp(filesystemType, "auto") == 0) { |
167 | FILE *f = fopen ("/proc/filesystems", "r"); | 168 | FILE *f = fopen ("/proc/filesystems", "r"); |
168 | 169 | ||
@@ -189,7 +190,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, | |||
189 | } | 190 | } |
190 | } | 191 | } |
191 | fclose (f); | 192 | fclose (f); |
192 | } else { | 193 | } else |
194 | #endif | ||
195 | { | ||
193 | status = do_mount (blockDevice, directory, filesystemType, | 196 | status = do_mount (blockDevice, directory, filesystemType, |
194 | flags | MS_MGC_VAL, string_flags, useMtab, | 197 | flags | MS_MGC_VAL, string_flags, useMtab, |
195 | fakeIt, mtab_opts); | 198 | fakeIt, mtab_opts); |
@@ -26,8 +26,14 @@ erase_mtab(const char * name) | |||
26 | FILE *mountTable = setmntent(mtab_file, "r"); | 26 | FILE *mountTable = setmntent(mtab_file, "r"); |
27 | struct mntent * m; | 27 | struct mntent * m; |
28 | 28 | ||
29 | if ( mountTable == 0 | 29 | /* Check if reading the mtab file failed */ |
30 | && (mountTable = setmntent("/proc/mounts", "r")) == 0 ) { | 30 | if ( mountTable == 0 |
31 | #if ! defined BB_FEATURE_USE_PROCFS | ||
32 | ) { | ||
33 | #else | ||
34 | /* Bummer. fall back on trying the /proc filesystem */ | ||
35 | && (mountTable = setmntent("/proc/mounts", "r")) == 0 ) { | ||
36 | #endif | ||
31 | perror(mtab_file); | 37 | perror(mtab_file); |
32 | return; | 38 | return; |
33 | } | 39 | } |
@@ -76,13 +82,14 @@ write_mtab(char* blockDevice, char* directory, | |||
76 | if ( length > 1 && directory[length - 1] == '/' ) | 82 | if ( length > 1 && directory[length - 1] == '/' ) |
77 | directory[length - 1] = '\0'; | 83 | directory[length - 1] = '\0'; |
78 | 84 | ||
85 | #ifdef BB_FEATURE_USE_PROCFS | ||
79 | if ( filesystemType == 0 ) { | 86 | if ( filesystemType == 0 ) { |
80 | struct mntent * p | 87 | struct mntent *p = findMountPoint(blockDevice, "/proc/mounts"); |
81 | = findMountPoint(blockDevice, "/proc/mounts"); | ||
82 | 88 | ||
83 | if ( p && p->mnt_type ) | 89 | if ( p && p->mnt_type ) |
84 | filesystemType = p->mnt_type; | 90 | filesystemType = p->mnt_type; |
85 | } | 91 | } |
92 | #endif | ||
86 | m.mnt_fsname = blockDevice; | 93 | m.mnt_fsname = blockDevice; |
87 | m.mnt_dir = directory; | 94 | m.mnt_dir = directory; |
88 | m.mnt_type = filesystemType ? filesystemType : "default"; | 95 | m.mnt_type = filesystemType ? filesystemType : "default"; |
diff --git a/procps/ps.c b/procps/ps.c index 1f6175318..4496faa31 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -28,6 +28,9 @@ | |||
28 | #include <fcntl.h> | 28 | #include <fcntl.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | #if ! defined BB_FEATURE_USE_PROCFS | ||
32 | #error Sorry, I depend on the /proc filesystem right now. | ||
33 | #endif | ||
31 | 34 | ||
32 | typedef struct proc_s { | 35 | typedef struct proc_s { |
33 | char | 36 | char |
@@ -28,6 +28,9 @@ | |||
28 | #include <fcntl.h> | 28 | #include <fcntl.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | #if ! defined BB_FEATURE_USE_PROCFS | ||
32 | #error Sorry, I depend on the /proc filesystem right now. | ||
33 | #endif | ||
31 | 34 | ||
32 | typedef struct proc_s { | 35 | typedef struct proc_s { |
33 | char | 36 | char |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index e3f45b62a..1f3e31225 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -57,13 +57,13 @@ static char LocalHostName[32]; | |||
57 | 57 | ||
58 | static const char syslogd_usage[] = | 58 | static const char syslogd_usage[] = |
59 | "syslogd [OPTION]...\n\n" | 59 | "syslogd [OPTION]...\n\n" |
60 | "Linux system logging utility.\n\n" | 60 | "Linux system and kernel (provides klogd) logging utility.\n" |
61 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" | ||
61 | "Options:\n" | 62 | "Options:\n" |
62 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" | 63 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" |
63 | "\t-n\tDo not fork into the background (for when run by init)\n" | 64 | "\t-n\tDo not fork into the background (for when run by init)\n" |
64 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; | 65 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; |
65 | 66 | ||
66 | static int kmsg; | ||
67 | 67 | ||
68 | /* try to open up the specified device */ | 68 | /* try to open up the specified device */ |
69 | static int device_open(char *device, int mode) | 69 | static int device_open(char *device, int mode) |
@@ -253,10 +253,9 @@ static void doSyslogd(void) | |||
253 | 253 | ||
254 | static void klogd_signal(int sig) | 254 | static void klogd_signal(int sig) |
255 | { | 255 | { |
256 | //ksyslog(7, NULL, 0); | 256 | ksyslog(7, NULL, 0); |
257 | //ksyslog(0, 0, 0); | 257 | ksyslog(0, 0, 0); |
258 | logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting."); | 258 | logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting."); |
259 | close( kmsg); | ||
260 | exit( TRUE); | 259 | exit( TRUE); |
261 | } | 260 | } |
262 | 261 | ||
@@ -264,7 +263,6 @@ static void klogd_signal(int sig) | |||
264 | static void doKlogd(void) | 263 | static void doKlogd(void) |
265 | { | 264 | { |
266 | int priority=LOG_INFO; | 265 | int priority=LOG_INFO; |
267 | struct stat sb; | ||
268 | char log_buffer[4096]; | 266 | char log_buffer[4096]; |
269 | char *logp; | 267 | char *logp; |
270 | 268 | ||
@@ -277,26 +275,10 @@ static void doKlogd(void) | |||
277 | "BusyBox v" BB_VER " (" BB_BT ")"); | 275 | "BusyBox v" BB_VER " (" BB_BT ")"); |
278 | 276 | ||
279 | ksyslog(1, NULL, 0); | 277 | ksyslog(1, NULL, 0); |
280 | if ( ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) || | 278 | |
281 | ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 ) ) { | ||
282 | char message[80]; | ||
283 | snprintf(message, 79, "klogd: Cannot open %s, " \ | ||
284 | "%d - %s.\n", _PATH_KLOG, errno, strerror(errno)); | ||
285 | logMessage(LOG_SYSLOG|LOG_ERR, message); | ||
286 | klogd_signal(0); | ||
287 | } | ||
288 | while (1) { | 279 | while (1) { |
280 | /* Use kernel syscalls */ | ||
289 | memset(log_buffer, '\0', sizeof(log_buffer)); | 281 | memset(log_buffer, '\0', sizeof(log_buffer)); |
290 | if ( read(kmsg, log_buffer, sizeof(log_buffer)-1) < 0 ) { | ||
291 | char message[80]; | ||
292 | if ( errno == EINTR ) | ||
293 | continue; | ||
294 | snprintf(message, 79, "klogd: Cannot read proc file system: %d - %s.\n", | ||
295 | errno, strerror(errno)); | ||
296 | logMessage(LOG_SYSLOG|LOG_ERR, message); | ||
297 | klogd_signal(0); | ||
298 | } | ||
299 | #if 0 | ||
300 | if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) { | 282 | if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) { |
301 | char message[80]; | 283 | char message[80]; |
302 | if ( errno == EINTR ) | 284 | if ( errno == EINTR ) |
@@ -306,7 +288,6 @@ static void doKlogd(void) | |||
306 | logMessage(LOG_SYSLOG|LOG_ERR, message); | 288 | logMessage(LOG_SYSLOG|LOG_ERR, message); |
307 | exit(1); | 289 | exit(1); |
308 | } | 290 | } |
309 | #endif | ||
310 | logp=log_buffer; | 291 | logp=log_buffer; |
311 | if ( *log_buffer == '<' ) | 292 | if ( *log_buffer == '<' ) |
312 | { | 293 | { |
@@ -57,13 +57,13 @@ static char LocalHostName[32]; | |||
57 | 57 | ||
58 | static const char syslogd_usage[] = | 58 | static const char syslogd_usage[] = |
59 | "syslogd [OPTION]...\n\n" | 59 | "syslogd [OPTION]...\n\n" |
60 | "Linux system logging utility.\n\n" | 60 | "Linux system and kernel (provides klogd) logging utility.\n" |
61 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" | ||
61 | "Options:\n" | 62 | "Options:\n" |
62 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" | 63 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" |
63 | "\t-n\tDo not fork into the background (for when run by init)\n" | 64 | "\t-n\tDo not fork into the background (for when run by init)\n" |
64 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; | 65 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; |
65 | 66 | ||
66 | static int kmsg; | ||
67 | 67 | ||
68 | /* try to open up the specified device */ | 68 | /* try to open up the specified device */ |
69 | static int device_open(char *device, int mode) | 69 | static int device_open(char *device, int mode) |
@@ -253,10 +253,9 @@ static void doSyslogd(void) | |||
253 | 253 | ||
254 | static void klogd_signal(int sig) | 254 | static void klogd_signal(int sig) |
255 | { | 255 | { |
256 | //ksyslog(7, NULL, 0); | 256 | ksyslog(7, NULL, 0); |
257 | //ksyslog(0, 0, 0); | 257 | ksyslog(0, 0, 0); |
258 | logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting."); | 258 | logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting."); |
259 | close( kmsg); | ||
260 | exit( TRUE); | 259 | exit( TRUE); |
261 | } | 260 | } |
262 | 261 | ||
@@ -264,7 +263,6 @@ static void klogd_signal(int sig) | |||
264 | static void doKlogd(void) | 263 | static void doKlogd(void) |
265 | { | 264 | { |
266 | int priority=LOG_INFO; | 265 | int priority=LOG_INFO; |
267 | struct stat sb; | ||
268 | char log_buffer[4096]; | 266 | char log_buffer[4096]; |
269 | char *logp; | 267 | char *logp; |
270 | 268 | ||
@@ -277,26 +275,10 @@ static void doKlogd(void) | |||
277 | "BusyBox v" BB_VER " (" BB_BT ")"); | 275 | "BusyBox v" BB_VER " (" BB_BT ")"); |
278 | 276 | ||
279 | ksyslog(1, NULL, 0); | 277 | ksyslog(1, NULL, 0); |
280 | if ( ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) || | 278 | |
281 | ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 ) ) { | ||
282 | char message[80]; | ||
283 | snprintf(message, 79, "klogd: Cannot open %s, " \ | ||
284 | "%d - %s.\n", _PATH_KLOG, errno, strerror(errno)); | ||
285 | logMessage(LOG_SYSLOG|LOG_ERR, message); | ||
286 | klogd_signal(0); | ||
287 | } | ||
288 | while (1) { | 279 | while (1) { |
280 | /* Use kernel syscalls */ | ||
289 | memset(log_buffer, '\0', sizeof(log_buffer)); | 281 | memset(log_buffer, '\0', sizeof(log_buffer)); |
290 | if ( read(kmsg, log_buffer, sizeof(log_buffer)-1) < 0 ) { | ||
291 | char message[80]; | ||
292 | if ( errno == EINTR ) | ||
293 | continue; | ||
294 | snprintf(message, 79, "klogd: Cannot read proc file system: %d - %s.\n", | ||
295 | errno, strerror(errno)); | ||
296 | logMessage(LOG_SYSLOG|LOG_ERR, message); | ||
297 | klogd_signal(0); | ||
298 | } | ||
299 | #if 0 | ||
300 | if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) { | 282 | if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) { |
301 | char message[80]; | 283 | char message[80]; |
302 | if ( errno == EINTR ) | 284 | if ( errno == EINTR ) |
@@ -306,7 +288,6 @@ static void doKlogd(void) | |||
306 | logMessage(LOG_SYSLOG|LOG_ERR, message); | 288 | logMessage(LOG_SYSLOG|LOG_ERR, message); |
307 | exit(1); | 289 | exit(1); |
308 | } | 290 | } |
309 | #endif | ||
310 | logp=log_buffer; | 291 | logp=log_buffer; |
311 | if ( *log_buffer == '<' ) | 292 | if ( *log_buffer == '<' ) |
312 | { | 293 | { |
diff --git a/util-linux/mount.c b/util-linux/mount.c index a9463afba..1ec9cbb5b 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -163,6 +163,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, | |||
163 | 163 | ||
164 | char buf[255]; | 164 | char buf[255]; |
165 | 165 | ||
166 | #if defined BB_FEATURE_USE_PROCFS | ||
166 | if (strcmp(filesystemType, "auto") == 0) { | 167 | if (strcmp(filesystemType, "auto") == 0) { |
167 | FILE *f = fopen ("/proc/filesystems", "r"); | 168 | FILE *f = fopen ("/proc/filesystems", "r"); |
168 | 169 | ||
@@ -189,7 +190,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, | |||
189 | } | 190 | } |
190 | } | 191 | } |
191 | fclose (f); | 192 | fclose (f); |
192 | } else { | 193 | } else |
194 | #endif | ||
195 | { | ||
193 | status = do_mount (blockDevice, directory, filesystemType, | 196 | status = do_mount (blockDevice, directory, filesystemType, |
194 | flags | MS_MGC_VAL, string_flags, useMtab, | 197 | flags | MS_MGC_VAL, string_flags, useMtab, |
195 | fakeIt, mtab_opts); | 198 | fakeIt, mtab_opts); |
@@ -36,12 +36,16 @@ | |||
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <ctype.h> | 37 | #include <ctype.h> |
38 | 38 | ||
39 | #ifdef BB_MTAB | ||
40 | const char mtab_file[] = "/etc/mtab"; | ||
41 | #else | ||
42 | #if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF | 39 | #if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF |
40 | # if defined BB_FEATURE_USE_PROCFS | ||
43 | const char mtab_file[] = "/proc/mounts"; | 41 | const char mtab_file[] = "/proc/mounts"; |
44 | #endif | 42 | # else |
43 | # if defined BB_MTAB | ||
44 | const char mtab_file[] = "/etc/mtab"; | ||
45 | # else | ||
46 | # error With (BB_MOUNT||BB_UMOUNT||BB_DF) defined, you must define either BB_MTAB or BB_FEATURE_USE_PROCFS | ||
47 | # endif | ||
48 | # endif | ||
45 | #endif | 49 | #endif |
46 | 50 | ||
47 | 51 | ||
@@ -56,6 +60,9 @@ extern void usage(const char *usage) | |||
56 | 60 | ||
57 | #if defined (BB_INIT) || defined (BB_PS) | 61 | #if defined (BB_INIT) || defined (BB_PS) |
58 | 62 | ||
63 | #if ! defined BB_FEATURE_USE_PROCFS | ||
64 | #error Sorry, I depend on the /proc filesystem right now. | ||
65 | #endif | ||
59 | /* Returns kernel version encoded as major*65536 + minor*256 + patch, | 66 | /* Returns kernel version encoded as major*65536 + minor*256 + patch, |
60 | * so, for example, to check if the kernel is greater than 2.2.11: | 67 | * so, for example, to check if the kernel is greater than 2.2.11: |
61 | * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } | 68 | * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } |