Add in ifconfig and route
[oweals/busybox.git] / init.c
diff --git a/init.c b/init.c
index 75d2f33b987b25e25e449534080d6f7cff273141..a1c6aec3a0bfbe2b8bce1863169c01af89f33287 100644 (file)
--- a/init.c
+++ b/init.c
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
+#include <limits.h>
 #include <sys/fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
@@ -56,7 +57,7 @@ struct vt_stat {
        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 {
@@ -79,16 +80,15 @@ 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
+static const int RB_AUTOBOOT = 0x01234567;
 #if defined(__GLIBC__) || defined (__UCLIBC__)
 #include <sys/reboot.h>
   #define init_reboot(magic) reboot(magic)
 #else
-  extern int reboot __P ((int __howto));
   #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic)
 #endif
 #endif
@@ -115,6 +115,8 @@ struct serial_struct {
 #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__ */
 
@@ -132,8 +134,8 @@ static _syscall2(int, bdflush, int, func, int, data);
 #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 {
@@ -202,7 +204,7 @@ static void message(int device, char *fmt, ...)
                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();
        }
@@ -220,7 +222,6 @@ static void message(int device, char *fmt, ...)
                } 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;
                }
@@ -246,7 +247,6 @@ static void message(int device, char *fmt, ...)
                        fprintf(stderr, "Bummer, can't print: ");
                        va_start(arguments, fmt);
                        vfprintf(stderr, fmt, arguments);
-                       fflush(stderr);
                        va_end(arguments);
                }
        }
@@ -297,7 +297,7 @@ static int check_free_memory()
        unsigned int result, u, s=10;
 
        if (sysinfo(&info) != 0) {
-               perror_msg("Error checking free memory");
+               perror_msg("Error checking free memory");
                return -1;
        }
 
@@ -401,6 +401,10 @@ static pid_t run(char *command, char *terminal, int get_enter)
        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=/",
@@ -658,9 +662,9 @@ static void reboot_signal(int sig)
 
 #if defined BB_FEATURE_INIT_CHROOT
 
-#if ! defined BB_FEATURE_USE_PROCFS
-#error Sorry, I depend on the /proc filesystem right now.
-#endif
+#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.
 
 static void check_chroot(int sig)
 {
@@ -935,7 +939,7 @@ extern int init_main(int argc, char **argv)
        {
                        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() */
@@ -1016,7 +1020,7 @@ extern int init_main(int argc, char **argv)
        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 */