More stuff.
[oweals/busybox.git] / applets / busybox.c
index f0258c36e56e9dbc201a4c54ed68b3331565d627..16ccce67ed0e35271174dc6d8865a58b32e6357c 100644 (file)
@@ -16,12 +16,10 @@ static const struct Applet applets[] = {
 #ifdef BB_CAT                  //bin
     {"cat", cat_more_main},
 #endif
-#ifdef BB_CHMOD                        //bin
-    {"chmod", chmod_main},
-#endif
-#ifdef BB_CHOWN                        //bin
-    {"chown", chown_main},
-    {"chgrp", chown_main},
+#ifdef BB_CHMOD_CHOWN_CHGRP    //bin
+    {"chmod", chmod_chown_chgrp_main},
+    {"chown", chmod_chown_chgrp_main},
+    {"chgrp", chmod_chown_chgrp_main},
 #endif
 #ifdef BB_CHROOT               //sbin
     {"chroot", chroot_main},
@@ -51,7 +49,7 @@ static const struct Applet applets[] = {
     {"false", false_main},
 #endif
 #ifdef BB_FDFLUSH              //bin
-    {"fdflush", monadic_main},
+    {"fdflush", fdflush_main},
 #endif
 #ifdef BB_FIND                 //usr/bin
     {"find", find_main},
@@ -72,14 +70,11 @@ static const struct Applet applets[] = {
     {"length", length_main},
 #endif
 #ifdef BB_LN                   //bin
-    {"ln", dyadic_main},
+    {"ln", ln_main},
 #endif
 #ifdef BB_LOADKMAP             //sbin
     {"loadkmap", loadkmap_main},
 #endif
-#ifdef BB_LOSETUP              //sbin
-    {"losetup", losetup_main},
-#endif
 #ifdef BB_LS                   //bin
     {"ls", ls_main},
 #endif
@@ -90,7 +85,7 @@ static const struct Applet applets[] = {
     {"math", math_main},
 #endif
 #ifdef BB_MKDIR                        //bin
-    {"mkdir", monadic_main},
+    {"mkdir", mkdir_main},
 #endif
 #ifdef BB_MKNOD                        //bin
     {"mknod", mknod_main},
@@ -126,7 +121,7 @@ static const struct Applet applets[] = {
     {"rm", rm_main},
 #endif
 #ifdef BB_RMDIR                        //bin
-    {"rmdir", monadic_main},
+    {"rmdir", rmdir_main},
 #endif
 #ifdef BB_SLEEP                        //bin
     {"sleep", sleep_main},
@@ -134,11 +129,9 @@ static const struct Applet applets[] = {
 #ifdef BB_TAR                  //bin
     {"tar", tar_main},
 #endif
-#ifdef BB_SWAPOFF              //sbin
-    {"swapoff", monadic_main},
-#endif
-#ifdef BB_SWAPON               //sbin
-    {"swapon", monadic_main},
+#ifdef BB_SWAPONOFF            //sbin
+    {"swapon", swap_on_off_main},
+    {"swapoff", swap_on_off_main},
 #endif
 #ifdef BB_SYNC                 //bin
     {"sync", sync_main},
@@ -150,7 +143,7 @@ static const struct Applet applets[] = {
     {"true", true_main},
 #endif
 #ifdef BB_UMOUNT               //bin
-    {"umount", umount_main},
+    {"umount",  umount_main},
 #endif
 #ifdef BB_UPDATE               //sbin
     {"update", update_main},
@@ -199,12 +192,7 @@ int busybox_main(int argc, char **argv)
     argc--;
     argv++;
 
-    /* If we've already been here once, exit now */
-    if (been_there_done_that == 1)
-       return -1;
-    been_there_done_that = 1;
-
-    if (argc < 1) {
+    if (been_there_done_that == 1 || argc < 1) {
        const struct Applet *a = applets;
        fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
                BB_VER, BB_BT);
@@ -224,6 +212,9 @@ int busybox_main(int argc, char **argv)
        }
        fprintf(stderr, "\n\n");
        exit(-1);
-    } else
+    } else {
+       /* If we've already been here once, exit now */
+       been_there_done_that = 1;
        return (main(argc, argv));
+    }
 }