summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog7
-rw-r--r--busybox.def.h2
-rw-r--r--init.c5
-rw-r--r--init/init.c5
-rw-r--r--mount.c5
-rw-r--r--mtab.c15
-rw-r--r--procps/ps.c3
-rw-r--r--ps.c3
-rw-r--r--sysklogd/syslogd.c31
-rw-r--r--syslogd.c31
-rw-r--r--util-linux/mount.c5
-rw-r--r--utility.c15
12 files changed, 66 insertions, 61 deletions
diff --git a/Changelog b/Changelog
index 378b698..668695f 100644
--- a/Changelog
+++ b/Changelog
@@ -8,7 +8,12 @@
was causing some confusing and unexpected behavior.
* Added klogd to syslogd, so now the log will contain both system and
kernel messages.
-
+ * syslogd now creates the /dev/log socket to make sure it is there, and
+ is actually a socket with the right permissions.
+ * I've taken a first step to making busybox not need the /proc filesystem.
+ Most apps don't need it. Those that _require_ it, will complain
+ if you enable them when you disable BB_FEATURE_USE_PROCFS.
+
-Erik Andrsen
0.37
diff --git a/busybox.def.h b/busybox.def.h
index bf8f545..a1f55ff 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -74,6 +74,8 @@
// pretty/useful).
//
//
+// enable features that use the /proc filesystem
+#define BB_FEATURE_USE_PROCFS
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
// Use termios to manipulate the screen ('more' is prettier with this on)
diff --git a/init.c b/init.c
index 088a890..84b558d 100644
--- a/init.c
+++ b/init.c
@@ -45,6 +45,11 @@
#include <sys/syslog.h>
#endif
+#if ! defined BB_FEATURE_USE_PROCFS
+#error Sorry, I depend on the /proc filesystem right now.
+#endif
+
+
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
#define VT_LOG "/dev/tty3" /* Virtual console */
diff --git a/init/init.c b/init/init.c
index 088a890..84b558d 100644
--- a/init/init.c
+++ b/init/init.c
@@ -45,6 +45,11 @@
#include <sys/syslog.h>
#endif
+#if ! defined BB_FEATURE_USE_PROCFS
+#error Sorry, I depend on the /proc filesystem right now.
+#endif
+
+
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
#define VT_LOG "/dev/tty3" /* Virtual console */
diff --git a/mount.c b/mount.c
index a9463af..1ec9cbb 100644
--- a/mount.c
+++ b/mount.c
@@ -163,6 +163,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
char buf[255];
+#if defined BB_FEATURE_USE_PROCFS
if (strcmp(filesystemType, "auto") == 0) {
FILE *f = fopen ("/proc/filesystems", "r");
@@ -189,7 +190,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
}
}
fclose (f);
- } else {
+ } else
+#endif
+ {
status = do_mount (blockDevice, directory, filesystemType,
flags | MS_MGC_VAL, string_flags, useMtab,
fakeIt, mtab_opts);
diff --git a/mtab.c b/mtab.c
index e855717..98e42a3 100644
--- a/mtab.c
+++ b/mtab.c
@@ -26,8 +26,14 @@ erase_mtab(const char * name)
FILE *mountTable = setmntent(mtab_file, "r");
struct mntent * m;
- if ( mountTable == 0
- && (mountTable = setmntent("/proc/mounts", "r")) == 0 ) {
+ /* Check if reading the mtab file failed */
+ if ( mountTable == 0
+#if ! defined BB_FEATURE_USE_PROCFS
+ ) {
+#else
+ /* Bummer. fall back on trying the /proc filesystem */
+ && (mountTable = setmntent("/proc/mounts", "r")) == 0 ) {
+#endif
perror(mtab_file);
return;
}
@@ -76,13 +82,14 @@ write_mtab(char* blockDevice, char* directory,
if ( length > 1 && directory[length - 1] == '/' )
directory[length - 1] = '\0';
+#ifdef BB_FEATURE_USE_PROCFS
if ( filesystemType == 0 ) {
- struct mntent * p
- = findMountPoint(blockDevice, "/proc/mounts");
+ struct mntent *p = findMountPoint(blockDevice, "/proc/mounts");
if ( p && p->mnt_type )
filesystemType = p->mnt_type;
}
+#endif
m.mnt_fsname = blockDevice;
m.mnt_dir = directory;
m.mnt_type = filesystemType ? filesystemType : "default";
diff --git a/procps/ps.c b/procps/ps.c
index 1f61753..4496faa 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -28,6 +28,9 @@
#include <fcntl.h>
#include <ctype.h>
+#if ! defined BB_FEATURE_USE_PROCFS
+#error Sorry, I depend on the /proc filesystem right now.
+#endif
typedef struct proc_s {
char
diff --git a/ps.c b/ps.c
index 1f61753..4496faa 100644
--- a/ps.c
+++ b/ps.c
@@ -28,6 +28,9 @@
#include <fcntl.h>
#include <ctype.h>
+#if ! defined BB_FEATURE_USE_PROCFS
+#error Sorry, I depend on the /proc filesystem right now.
+#endif
typedef struct proc_s {
char
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index e3f45b6..1f3e312 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -57,13 +57,13 @@ static char LocalHostName[32];
static const char syslogd_usage[] =
"syslogd [OPTION]...\n\n"
- "Linux system logging utility.\n\n"
+ "Linux system and kernel (provides klogd) logging utility.\n"
+ "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
"Options:\n"
"\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
"\t-n\tDo not fork into the background (for when run by init)\n"
"\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
-static int kmsg;
/* try to open up the specified device */
static int device_open(char *device, int mode)
@@ -253,10 +253,9 @@ static void doSyslogd(void)
static void klogd_signal(int sig)
{
- //ksyslog(7, NULL, 0);
- //ksyslog(0, 0, 0);
+ ksyslog(7, NULL, 0);
+ ksyslog(0, 0, 0);
logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting.");
- close( kmsg);
exit( TRUE);
}
@@ -264,7 +263,6 @@ static void klogd_signal(int sig)
static void doKlogd(void)
{
int priority=LOG_INFO;
- struct stat sb;
char log_buffer[4096];
char *logp;
@@ -277,26 +275,10 @@ static void doKlogd(void)
"BusyBox v" BB_VER " (" BB_BT ")");
ksyslog(1, NULL, 0);
- if ( ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) ||
- ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 ) ) {
- char message[80];
- snprintf(message, 79, "klogd: Cannot open %s, " \
- "%d - %s.\n", _PATH_KLOG, errno, strerror(errno));
- logMessage(LOG_SYSLOG|LOG_ERR, message);
- klogd_signal(0);
- }
+
while (1) {
+ /* Use kernel syscalls */
memset(log_buffer, '\0', sizeof(log_buffer));
- if ( read(kmsg, log_buffer, sizeof(log_buffer)-1) < 0 ) {
- char message[80];
- if ( errno == EINTR )
- continue;
- snprintf(message, 79, "klogd: Cannot read proc file system: %d - %s.\n",
- errno, strerror(errno));
- logMessage(LOG_SYSLOG|LOG_ERR, message);
- klogd_signal(0);
- }
-#if 0
if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) {
char message[80];
if ( errno == EINTR )
@@ -306,7 +288,6 @@ static void doKlogd(void)
logMessage(LOG_SYSLOG|LOG_ERR, message);
exit(1);
}
-#endif
logp=log_buffer;
if ( *log_buffer == '<' )
{
diff --git a/syslogd.c b/syslogd.c
index e3f45b6..1f3e312 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -57,13 +57,13 @@ static char LocalHostName[32];
static const char syslogd_usage[] =
"syslogd [OPTION]...\n\n"
- "Linux system logging utility.\n\n"
+ "Linux system and kernel (provides klogd) logging utility.\n"
+ "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
"Options:\n"
"\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
"\t-n\tDo not fork into the background (for when run by init)\n"
"\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
-static int kmsg;
/* try to open up the specified device */
static int device_open(char *device, int mode)
@@ -253,10 +253,9 @@ static void doSyslogd(void)
static void klogd_signal(int sig)
{
- //ksyslog(7, NULL, 0);
- //ksyslog(0, 0, 0);
+ ksyslog(7, NULL, 0);
+ ksyslog(0, 0, 0);
logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting.");
- close( kmsg);
exit( TRUE);
}
@@ -264,7 +263,6 @@ static void klogd_signal(int sig)
static void doKlogd(void)
{
int priority=LOG_INFO;
- struct stat sb;
char log_buffer[4096];
char *logp;
@@ -277,26 +275,10 @@ static void doKlogd(void)
"BusyBox v" BB_VER " (" BB_BT ")");
ksyslog(1, NULL, 0);
- if ( ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) ||
- ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 ) ) {
- char message[80];
- snprintf(message, 79, "klogd: Cannot open %s, " \
- "%d - %s.\n", _PATH_KLOG, errno, strerror(errno));
- logMessage(LOG_SYSLOG|LOG_ERR, message);
- klogd_signal(0);
- }
+
while (1) {
+ /* Use kernel syscalls */
memset(log_buffer, '\0', sizeof(log_buffer));
- if ( read(kmsg, log_buffer, sizeof(log_buffer)-1) < 0 ) {
- char message[80];
- if ( errno == EINTR )
- continue;
- snprintf(message, 79, "klogd: Cannot read proc file system: %d - %s.\n",
- errno, strerror(errno));
- logMessage(LOG_SYSLOG|LOG_ERR, message);
- klogd_signal(0);
- }
-#if 0
if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) {
char message[80];
if ( errno == EINTR )
@@ -306,7 +288,6 @@ static void doKlogd(void)
logMessage(LOG_SYSLOG|LOG_ERR, message);
exit(1);
}
-#endif
logp=log_buffer;
if ( *log_buffer == '<' )
{
diff --git a/util-linux/mount.c b/util-linux/mount.c
index a9463af..1ec9cbb 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -163,6 +163,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
char buf[255];
+#if defined BB_FEATURE_USE_PROCFS
if (strcmp(filesystemType, "auto") == 0) {
FILE *f = fopen ("/proc/filesystems", "r");
@@ -189,7 +190,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
}
}
fclose (f);
- } else {
+ } else
+#endif
+ {
status = do_mount (blockDevice, directory, filesystemType,
flags | MS_MGC_VAL, string_flags, useMtab,
fakeIt, mtab_opts);
diff --git a/utility.c b/utility.c
index a38ef86..81bff18 100644
--- a/utility.c
+++ b/utility.c
@@ -36,12 +36,16 @@
#include <unistd.h>
#include <ctype.h>
-#ifdef BB_MTAB
-const char mtab_file[] = "/etc/mtab";
-#else
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
+# if defined BB_FEATURE_USE_PROCFS
const char mtab_file[] = "/proc/mounts";
-#endif
+# else
+# if defined BB_MTAB
+const char mtab_file[] = "/etc/mtab";
+# else
+# error With (BB_MOUNT||BB_UMOUNT||BB_DF) defined, you must define either BB_MTAB or BB_FEATURE_USE_PROCFS
+# endif
+# endif
#endif
@@ -56,6 +60,9 @@ extern void usage(const char *usage)
#if defined (BB_INIT) || defined (BB_PS)
+#if ! defined BB_FEATURE_USE_PROCFS
+#error Sorry, I depend on the /proc filesystem right now.
+#endif
/* Returns kernel version encoded as major*65536 + minor*256 + patch,
* so, for example, to check if the kernel is greater than 2.2.11:
* if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }