#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <limits.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
unsigned short v_signal; /* signal to send */
unsigned short v_state; /* vt bitmask */
};
-#define VT_GETSTATE 0x5603 /* get global vt state info */
+static const int VT_GETSTATE = 0x5603; /* get global vt state info */
/* From <linux/serial.h> */
struct serial_struct {
#ifndef RB_HALT_SYSTEM
-#define RB_HALT_SYSTEM 0xcdef0123
-#define RB_ENABLE_CAD 0x89abcdef
-#define RB_DISABLE_CAD 0
+static const int RB_HALT_SYSTEM = 0xcdef0123;
+static const int RB_ENABLE_CAD = 0x89abcdef;
+static const int RB_DISABLE_CAD = 0;
#define RB_POWER_OFF 0x4321fedc
-#define RB_AUTOBOOT 0x01234567
-#if defined(__GLIBC__)
+static const int RB_AUTOBOOT = 0x01234567;
+#if defined(__GLIBC__) || defined (__UCLIBC__)
#include <sys/reboot.h>
#define init_reboot(magic) reboot(magic)
#else
#if defined(__GLIBC__)
#include <sys/kdaemon.h>
#else
+#include <sys/syscall.h>
+#include <linux/unistd.h>
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */
#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
#endif
-#define LOG 0x1
-#define CONSOLE 0x2
+static const int LOG = 0x1;
+static const int CONSOLE = 0x2;
/* Allowed init action types */
typedef enum {
va_start(arguments, fmt);
vsnprintf(msg, sizeof(msg), fmt, arguments);
va_end(arguments);
- openlog("init", 0, LOG_USER);
+ openlog(applet_name, 0, LOG_USER);
syslog(LOG_USER|LOG_INFO, msg);
closelog();
}
} else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
log_fd = -2;
fprintf(stderr, "Bummer, can't write to log on %s!\r\n", log);
- fflush(stderr);
log = NULL;
device = CONSOLE;
}
fprintf(stderr, "Bummer, can't print: ");
va_start(arguments, fmt);
vfprintf(stderr, fmt, arguments);
- fflush(stderr);
va_end(arguments);
}
}
unsigned int result, u, s=10;
if (sysinfo(&info) != 0) {
- perror_msg("Error checking free memory: ");
+ perror_msg("Error checking free memory");
return -1;
}
char buf[255];
static const char press_enter[] =
+#ifdef CUSTOMIZED_BANNER
+#include CUSTOMIZED_BANNER
+#endif
+
"\nPlease press Enter to activate this console. ";
char *environment[] = {
"HOME=/",
#if defined BB_FEATURE_INIT_CHROOT
+#warning BB_FEATURE_INIT_CHROOT is out of date and should be rewritten to us
+#warning pivot root instead. Do not even bother till this work is done...
+#warning You have been warned.
+
#if ! defined BB_FEATURE_USE_PROCFS
#error Sorry, I depend on the /proc filesystem right now.
#endif
{
usage("init\n\nInit is the parent of all processes.\n\n"
"This version of init is designed to be run only "
- "by the kernel.\n");
+ "by the kernel.");
}
/* Set up sig handlers -- be sure to
* clear all of these in run() */
argv[0]="init";
if (argc > 1)
- strncpy(argv[1], "\0", strlen(argv[1])+1);
+ argv[1][0]=0;
/* Now run everything that needs to be run */