#include <sys/reboot.h>
#include <sys/sysinfo.h> /* For check_free_memory() */
#ifdef BB_SYSLOGD
-#include <sys/syslog.h>
+# include <sys/syslog.h>
#endif
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
+
+#if defined BB_FEATURE_INIT_COREDUMPS
+/*
+ * When a file named CORE_ENABLE_FLAG_FILE exists, setrlimit is called
+ * before processes are spawned to set core file size as unlimited.
+ * This is for debugging only. Don't use this is production, unless
+ * you want core dumps lying about....
+ */
+#define CORE_ENABLE_FLAG_FILE "/.init_enable_core"
+#include <sys/resource.h>
+#include <sys/time.h>
+#endif
+
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
/* Print a message to the specified device.
* Device may be bitwise-or'd from LOG | CONSOLE */
+static void message(int device, char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
static void message(int device, char *fmt, ...)
{
va_list arguments;
cmd[i] = NULL;
}
+#if defined BB_FEATURE_INIT_COREDUMPS
+ {
+ struct stat sb;
+ if (stat (CORE_ENABLE_FLAG_FILE, &sb) == 0) {
+ struct rlimit limit;
+ limit.rlim_cur = RLIM_INFINITY;
+ limit.rlim_max = RLIM_INFINITY;
+ setrlimit(RLIMIT_CORE, &limit);
+ }
+ }
+#endif
+
/* Now run it. The new program will take over this PID,
* so nothing further in init.c should be run. */
execve(cmd[0], cmd, environment);
return;
if (stat("/etc/fstab", &statBuf) == 0) {
+ /* swapon -a requires /proc typically */
+ waitfor("mount proc /proc -t proc", console, FALSE);
/* Try to turn on swap */
- system("/sbin/swapon -a");
+ waitfor("swapon -a", console, FALSE);
if (check_free_memory() < 1000)
goto goodnight;
} else
reboot(RB_DISABLE_CAD);
#endif
+ /* Figure out what kernel this is running */
+ kernelVersion = get_kernel_revision();
+
/* Figure out where the default console should be */
console_init();
close(1);
close(2);
set_term(0);
+ chdir("/");
setsid();
/* Make sure PATH is set to something sane */
* of "askfirst" shells */
parse_inittab();
}
-
+
/* Fix up argv[0] to be certain we claim to be init */
strncpy(argv[0], "init", strlen(argv[0])+1);
if (argc > 1)