Patch from Shaun Jackman to set environment variable RUNLEVEL equal to

init's argv[1], so if you append "single" to your kernel command line and
the kernel doesn't parse it, RUNLELEL=single.

Plus a few unrelated header cleanups while I was in the area...
This commit is contained in:
Rob Landley 2006-07-09 17:28:17 +00:00
parent acf448d4f6
commit cba1b96735

View File

@ -10,35 +10,19 @@
*/ */
#include "busybox.h" #include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <paths.h> #include <paths.h>
#include <signal.h> #include <signal.h>
#include <stdarg.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <limits.h>
#include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/reboot.h> #include <sys/reboot.h>
#include "init_shared.h" #include "init_shared.h"
#ifdef CONFIG_SYSLOGD #ifdef CONFIG_SYSLOGD
# include <sys/syslog.h> # include <sys/syslog.h>
#endif #endif
#ifdef CONFIG_SELINUX
# include <selinux/selinux.h>
#endif /* CONFIG_SELINUX */
#define INIT_BUFFS_SIZE 256 #define INIT_BUFFS_SIZE 256
/* From <linux/vt.h> */ /* From <linux/vt.h> */
@ -72,7 +56,6 @@ struct serial_struct {
int reserved[1]; int reserved[1];
}; };
#ifndef _PATH_STDPATH #ifndef _PATH_STDPATH
#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
#endif #endif
@ -88,8 +71,6 @@ struct serial_struct {
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#define INITTAB "/etc/inittab" /* inittab file location */ #define INITTAB "/etc/inittab" /* inittab file location */
#ifndef INIT_SCRIPT #ifndef INIT_SCRIPT
#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
@ -1046,6 +1027,9 @@ int init_main(int argc, char **argv)
for(e = environment; *e; e++) for(e = environment; *e; e++)
putenv((char *) *e); putenv((char *) *e);
} }
if (argc > 1) setenv("RUNLEVEL", argv[1], 1);
/* Hello world */ /* Hello world */
message(MAYBE_CONSOLE | LOG, "init started: %s", bb_msg_full_version); message(MAYBE_CONSOLE | LOG, "init started: %s", bb_msg_full_version);