init: remove special-case code for machines with less tham 1 MB of RAM.
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 21 May 2013 14:36:51 +0000 (16:36 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 21 May 2013 14:36:51 +0000 (16:36 +0200)
function                                             old     new   delta
init_main                                            920     781    -139

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
init/init.c

index 15aad474f8d88733410eef119b9d2d866b1a9ab7..f3a35d5328df0f1701c4326d9767392eef8d90b6 100644 (file)
 
 /* Default sysinit script. */
 #ifndef INIT_SCRIPT
-#define INIT_SCRIPT  "/etc/init.d/rcS"
+# define INIT_SCRIPT  "/etc/init.d/rcS"
 #endif
 
 /* Each type of actions can appear many times. They will be
@@ -640,7 +640,7 @@ static void new_init_action(uint8_t action_type, const char *command, const char
 
 /* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined,
  * then parse_inittab() simply adds in some default
- * actions(i.e., runs INIT_SCRIPT and then starts a pair
+ * actions (i.e., runs INIT_SCRIPT and then starts a pair
  * of "askfirst" shells).  If CONFIG_FEATURE_USE_INITTAB
  * _is_ defined, but /etc/inittab is missing, this
  * results in the same set of default behaviors.
@@ -655,23 +655,22 @@ static void parse_inittab(void)
 #endif
        {
                /* No inittab file - set up some default behavior */
-               /* Reboot on Ctrl-Alt-Del */
-               new_init_action(CTRLALTDEL, "reboot", "");
-               /* Umount all filesystems on halt/reboot */
-               new_init_action(SHUTDOWN, "umount -a -r", "");
-               /* Swapoff on halt/reboot */
-               if (ENABLE_SWAPONOFF)
-                       new_init_action(SHUTDOWN, "swapoff -a", "");
-               /* Prepare to restart init when a QUIT is received */
-               new_init_action(RESTART, "init", "");
+               /* Sysinit */
+               new_init_action(SYSINIT, INIT_SCRIPT, "");
                /* Askfirst shell on tty1-4 */
                new_init_action(ASKFIRST, bb_default_login_shell, "");
 //TODO: VC_1 instead of ""? "" is console -> ctty problems -> angry users
                new_init_action(ASKFIRST, bb_default_login_shell, VC_2);
                new_init_action(ASKFIRST, bb_default_login_shell, VC_3);
                new_init_action(ASKFIRST, bb_default_login_shell, VC_4);
-               /* sysinit */
-               new_init_action(SYSINIT, INIT_SCRIPT, "");
+               /* Reboot on Ctrl-Alt-Del */
+               new_init_action(CTRLALTDEL, "reboot", "");
+               /* Umount all filesystems on halt/reboot */
+               new_init_action(SHUTDOWN, "umount -a -r", "");
+               /* Swapoff on halt/reboot */
+               new_init_action(SHUTDOWN, "swapoff -a", "");
+               /* Restart init when a QUIT is received */
+               new_init_action(RESTART, "init", "");
                return;
        }
 
@@ -1058,10 +1057,13 @@ int init_main(int argc UNUSED_PARAM, char **argv)
        message(L_CONSOLE | L_LOG, "init started: %s", bb_banner);
 #endif
 
+#if 0
+/* It's 2013, does anyone really still depend on this? */
+/* If you do, consider adding swapon to sysinot actions then! */
 /* struct sysinfo is linux-specific */
-#ifdef __linux__
+# ifdef __linux__
        /* Make sure there is enough memory to do something useful. */
-       if (ENABLE_SWAPONOFF) {
+       /*if (ENABLE_SWAPONOFF) - WRONG: we may have non-bbox swapon*/ {
                struct sysinfo info;
 
                if (sysinfo(&info) == 0
@@ -1075,6 +1077,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
                        run_actions(SYSINIT);   /* wait and removing */
                }
        }
+# endif
 #endif
 
        /* Check if we are supposed to be in single user mode */