More stuff.
authorEric Andersen <andersen@codepoet.org>
Mon, 18 Oct 1999 22:28:26 +0000 (22:28 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 18 Oct 1999 22:28:26 +0000 (22:28 -0000)
 -Erik

61 files changed:
applets/busybox.c
busybox.c
busybox.def.h
cat.c
chroot.c
console-tools/loadkmap.c
coreutils/cat.c
coreutils/chroot.c
coreutils/cp.c
coreutils/date.c
coreutils/length.c
coreutils/ln.c
coreutils/ls.c
coreutils/mkdir.c
coreutils/mknod.c
coreutils/mv.c
coreutils/printf.c
coreutils/rm.c
coreutils/rmdir.c
coreutils/sleep.c
coreutils/sync.c
coreutils/touch.c
cp.c
date.c
dmesg.c
dutmp.c
fdflush.c
find.c
findutils/find.c
internal.h
kill.c
length.c
ln.c
loadkmap.c
ls.c
makedevs.c
miscutils/dutmp.c
miscutils/makedevs.c
miscutils/mt.c
mkdir.c
mknod.c
mkswap.c
more.c
mt.c
mv.c
printf.c
procps/kill.c
rm.c
rmdir.c
sleep.c
swaponoff.c
sync.c
touch.c
umount.c
util-linux/dmesg.c
util-linux/fdflush.c
util-linux/mkswap.c
util-linux/more.c
util-linux/swaponoff.c
util-linux/umount.c
utility.c

index 6bc223a..16ccce6 100644 (file)
@@ -75,9 +75,6 @@ static const struct Applet applets[] = {
 #ifdef BB_LOADKMAP             //sbin
     {"loadkmap", loadkmap_main},
 #endif
-#ifdef BB_LOSETUP              //sbin
-    {"losetup", losetup_main},
-#endif
 #ifdef BB_LS                   //bin
     {"ls", ls_main},
 #endif
index 6bc223a..16ccce6 100644 (file)
--- a/busybox.c
+++ b/busybox.c
@@ -75,9 +75,6 @@ static const struct Applet applets[] = {
 #ifdef BB_LOADKMAP             //sbin
     {"loadkmap", loadkmap_main},
 #endif
-#ifdef BB_LOSETUP              //sbin
-    {"losetup", losetup_main},
-#endif
 #ifdef BB_LS                   //bin
     {"ls", ls_main},
 #endif
index c278f4c..7ca522b 100644 (file)
 #define BB_FDFLUSH
 #define BB_FIND
 #define BB_GREP
-#define BB_HALT
+//#define BB_HALT
 #define BB_INIT
 #define BB_KILL
-#define BB_LENGTH
+//#define BB_LENGTH
 #define BB_LN
-//#define BB_LOADKMAP
-////#define BB_LOSETUP
+#define BB_LOADKMAP
 #define BB_LS
-//#define BB_MAKEDEVS
-#define BB_MATH
+#define BB_MAKEDEVS
+//#define BB_MATH
 #define BB_MKDIR
-//#define BB_MKNOD
-////#define BB_MKSWAP
+#define BB_MKNOD
+//#define BB_MKSWAP
 #define BB_MNC
 #define BB_MORE
 #define BB_MOUNT
-////#define BB_MT
+//#define BB_MT
 #define BB_MV
-//#define BB_PRINTF
+#define BB_PRINTF
 #define BB_PWD
 #define BB_REBOOT
 #define BB_RM
@@ -51,4 +50,4 @@
 #define BB_UPDATE
 #define BB_UTILITY
 #define BB_ZCAT
-//#define BB_GZIP
+#define BB_GZIP
diff --git a/cat.c b/cat.c
index 5c54c49..38078d5 100644 (file)
--- a/cat.c
+++ b/cat.c
@@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
     }
 
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: cat [file ...]\n");
-       exit(FALSE);
+       usage ("cat [file ...]\n");
     }
     argc--;
     argv++;
index 3b6fdae..15f4468 100644 (file)
--- a/chroot.c
+++ b/chroot.c
@@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
 int chroot_main(int argc, char **argv)
 {
     if ( (argc < 2) || (**(argv+1) == '-') ) {
-       fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
-       exit( FALSE);
+       usage( chroot_usage);
     }
     argc--;
     argv++;
index 0f092d1..eb5a5dd 100644 (file)
@@ -14,7 +14,7 @@ const char                    loadkmap_usage[] = "loadkmap\n"
 
 
 int
-loadkmap_main(struct FileInfo * info, int argc, char * * argv)
+loadkmap_main(int argc, char * * argv)
 { 
     struct kbentry ke;
     u_short *ibuff;
index 5c54c49..38078d5 100644 (file)
@@ -42,8 +42,7 @@ extern int cat_more_main(int argc, char **argv)
     }
 
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: cat [file ...]\n");
-       exit(FALSE);
+       usage ("cat [file ...]\n");
     }
     argc--;
     argv++;
index 3b6fdae..15f4468 100644 (file)
@@ -33,8 +33,7 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
 int chroot_main(int argc, char **argv)
 {
     if ( (argc < 2) || (**(argv+1) == '-') ) {
-       fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
-       exit( FALSE);
+       usage( chroot_usage);
     }
     argc--;
     argv++;
index c5e34d3..11c7682 100644 (file)
@@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
 {
 
     if (argc < 3) {
-       fprintf(stderr, "Usage: %s", cp_usage);
-       exit (FALSE);
+       usage (cp_usage);
     }
     argc--;
     argv++;
@@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
                recursiveFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", cp_usage);
-               exit(FALSE);
+               usage (cp_usage);
            }
        argc--;
        argv++;
index 2df9e0c..70d5dd5 100644 (file)
@@ -34,7 +34,7 @@
    an RFC 822 complient date output for shell scripting
    mail commands */
 
-const char     date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
+const char     date_usage[] = "date [OPTION]... [+FORMAT]\n"
 "  or:  date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
 "Display the current time in the given FORMAT, or set the system date.\n"
 "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
@@ -159,12 +159,6 @@ date_conv_ftime(struct tm *tm_time, const char *t_string) {
 }
 
 
-void
-date_err(void) {
-    fprintf (stderr, "%s\n", date_usage);
-    exit( FALSE);
-}
-
 int
 date_main(int argc, char * * argv)
 {
@@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
                break;
            case 's':
                set_time = 1;
-               if(date_str != NULL) date_err();
+               if(date_str != NULL) usage ( date_usage);
                date_str = optarg;
                break;
            case 'u':
@@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
                /* Look ma, no break.  Don't fix it either. */
            case 'd':
                use_arg = 1;
-               if(date_str != NULL) date_err();
+               if(date_str != NULL) usage ( date_usage);
                date_str = optarg;
                break;
            case '-':
-               date_err();
+               usage ( date_usage);
            }
        } else {
            if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
                set_time = 1;
                date_str=*argv;
            } else { 
-               date_err();
+               usage ( date_usage);
            }
        }
        i--;
index f2dadd2..46242b5 100644 (file)
@@ -7,8 +7,7 @@ extern int
 length_main(int argc, char * * argv)
 {
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: length string\n");
-       exit(FALSE);
+       usage("length string\n");
     }
     printf("%d\n", strlen(argv[1]));
     return( TRUE);
index cd3cb4e..8f7719f 100644 (file)
@@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
     char newdestName[NAME_MAX];
 
     if (argc < 3) {
-       fprintf(stderr, "Usage: %s", ln_usage);
-       exit (FALSE);
+       usage (ln_usage);
     }
     argc--;
     argv++;
@@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
                removeoldFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", ln_usage);
-               exit(FALSE);
+               usage (ln_usage);
            }
        argc--;
        argv++;
index 2e3d50e..0adc35d 100644 (file)
@@ -19,6 +19,8 @@
  *
  */
 
+// I started writing a newer small one, but it isn't done yet....
+//  -Erik
 #if fooBar
 
 #include <stdio.h>
@@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
                recursiveFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", ls_usage);
-               exit( FALSE);
+               usage (ls_usage);
        }
        argc--;
        argv++;
@@ -571,7 +572,7 @@ listerr:
        return 1;
 }
 
-const char     ls_usage[] = "Usage: ls [-1a"
+const char     ls_usage[] = "ls [-1a"
 #ifdef FEATURE_TIMESTAMPS
        "c"
 #endif
@@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
        exit( i);
 
 print_usage_message:
-       fprintf(stderr, "Usage: %s\n", ls_usage);
+       usage (ls_usage);
        exit( FALSE);
 }
 
index 61d35d5..b42899a 100644 (file)
@@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
                parentFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "%s\n", mkdir_usage);
-               exit(FALSE);
+               usage( mkdir_usage);
            }
        argc--;
        argv++;
@@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
 
 
     if (argc < 1) {
-       fprintf(stderr, "%s\n", mkdir_usage);
-       exit (FALSE);
+       usage( mkdir_usage);
     }
 
     while (--argc > 0) {
index b18394b..95d7de3 100644 (file)
@@ -1,4 +1,5 @@
 #include "internal.h"
+#include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
 "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
 
 int
-mknod_main(struct FileInfo * i, int argc, char * * argv)
+mknod_main(int argc, char** argv)
 {
        mode_t  mode = 0;
        dev_t   dev = 0;
@@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
                mode = S_IFIFO;
                break;
        default:
-               usage(mknod_usage);
-               return 1;
+               usage (mknod_usage);
        }
 
        if ( mode == S_IFCHR || mode == S_IFBLK ) {
                dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
                if ( argc != 5 ) {
-                       usage(mknod_usage);
-                       return 1;
+                   usage (mknod_usage);
                }
        }
 
        mode |= 0666;
 
        if ( mknod(argv[1], mode, dev) != 0 ) {
-               name_and_error(argv[1]);
-               return 1;
+               perror(argv[1]);
+               return( FALSE);
        }
-       return 0;
+       return( TRUE);
 }
index 2a7c8c1..ab3fc2b 100644 (file)
@@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
     char newdestName[NAME_MAX];
 
     if (argc < 3) {
-       fprintf(stderr, "Usage: %s", mv_usage);
-       exit (FALSE);
+       usage (mv_usage);
     }
     argc--;
     argv++;
index e79843c..4d44659 100644 (file)
@@ -1,8 +1,3 @@
-// I may still need some more cleaning...fix my error checking
-
-#include "internal.h"
-#ifdef BB_PRINTF
-
 /* printf - format and print data
    Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
 
@@ -51,6 +46,7 @@
 
 //   19990508 Busy Boxed! Dave Cinege
 
+#include "internal.h"
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
 /* The value to return to the calling program.  */
 static int exit_status;
 
-const char     printf_usage[] = "Usage: printf format [argument...]\n";
+const char     printf_usage[] = "printf format [argument...]\n";
 
 int
-printf_main(struct FileInfo * i, int argc, char * * argv)
+printf_main(int argc, char** argv)
 {
   char *format;
   int args_used;
 
   exit_status = 0;
+  if ( **(argv+1) == '-' ) {
+    usage (printf_usage);
+  }
 
   format = argv[1];
   argc -= 2;
@@ -528,4 +527,3 @@ verify (char *s, char *end)
     }
 }
 
-#endif
index 477d3af..dd8dfa4 100644 (file)
@@ -25,7 +25,7 @@
 #include <utime.h>
 #include <dirent.h>
 
-static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n"
+static const char* rm_usage = "rm [OPTION]... FILE...\n"
 "Remove (unlink) the FILE(s).\n\n"
 "\t-f\tremove existing destinations, never prompt\n"
 "\t-r\tremove the contents of directories recursively\n";
@@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
 {
 
     if (argc < 2) {
-       fprintf(stderr, "Usage: %s", rm_usage);
-       exit (FALSE);
+       usage( rm_usage);
     }
     argc--;
     argv++;
@@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
                forceFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", rm_usage);
-               exit(FALSE);
+               usage( rm_usage);
            }
        argc--;
        argv++;
index b4da03f..666e047 100644 (file)
@@ -27,8 +27,7 @@
 extern int rmdir_main(int argc, char **argv)
 {
     if ( argc==1 || **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
-       exit(FALSE);
+       usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
     }
 
     while (--argc > 0) {
index 53fe5a0..7e38a36 100644 (file)
@@ -8,8 +8,7 @@ extern int
 sleep_main(int argc, char * * argv)
 {
         if ( (argc < 2) || (**(argv+1) == '-') ) {
-           fprintf(stderr, "Usage: %s %s", *argv, sleep_usage);
-           exit(FALSE);
+           usage( sleep_usage );
        }
 
        if ( sleep(atoi(*(++argv))) != 0 ) {
index 572d749..8800f2e 100644 (file)
@@ -5,9 +5,8 @@ extern int
 sync_main(int argc, char * * argv)
 {
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n");
-       exit(FALSE);
+       usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
     }
-       return sync();
+    return sync();
 }
 
index 8dac102..c36ffca 100644 (file)
@@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
     int create=TRUE;
 
     if (argc < 2) {
-       fprintf(stderr, "Usage: %s %s", *argv, touch_usage);
-       exit( FALSE);
+       usage( touch_usage);
     }
     argc--;
     argv++;
diff --git a/cp.c b/cp.c
index c5e34d3..11c7682 100644 (file)
--- a/cp.c
+++ b/cp.c
@@ -60,8 +60,7 @@ extern int cp_main(int argc, char **argv)
 {
 
     if (argc < 3) {
-       fprintf(stderr, "Usage: %s", cp_usage);
-       exit (FALSE);
+       usage (cp_usage);
     }
     argc--;
     argv++;
@@ -85,8 +84,7 @@ extern int cp_main(int argc, char **argv)
                recursiveFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", cp_usage);
-               exit(FALSE);
+               usage (cp_usage);
            }
        argc--;
        argv++;
diff --git a/date.c b/date.c
index 2df9e0c..70d5dd5 100644 (file)
--- a/date.c
+++ b/date.c
@@ -34,7 +34,7 @@
    an RFC 822 complient date output for shell scripting
    mail commands */
 
-const char     date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
+const char     date_usage[] = "date [OPTION]... [+FORMAT]\n"
 "  or:  date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
 "Display the current time in the given FORMAT, or set the system date.\n"
 "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
@@ -159,12 +159,6 @@ date_conv_ftime(struct tm *tm_time, const char *t_string) {
 }
 
 
-void
-date_err(void) {
-    fprintf (stderr, "%s\n", date_usage);
-    exit( FALSE);
-}
-
 int
 date_main(int argc, char * * argv)
 {
@@ -190,7 +184,7 @@ date_main(int argc, char * * argv)
                break;
            case 's':
                set_time = 1;
-               if(date_str != NULL) date_err();
+               if(date_str != NULL) usage ( date_usage);
                date_str = optarg;
                break;
            case 'u':
@@ -202,11 +196,11 @@ date_main(int argc, char * * argv)
                /* Look ma, no break.  Don't fix it either. */
            case 'd':
                use_arg = 1;
-               if(date_str != NULL) date_err();
+               if(date_str != NULL) usage ( date_usage);
                date_str = optarg;
                break;
            case '-':
-               date_err();
+               usage ( date_usage);
            }
        } else {
            if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
@@ -215,7 +209,7 @@ date_main(int argc, char * * argv)
                set_time = 1;
                date_str=*argv;
            } else { 
-               date_err();
+               usage ( date_usage);
            }
        }
        i--;
diff --git a/dmesg.c b/dmesg.c
index 64265b4..e5d403f 100644 (file)
--- a/dmesg.c
+++ b/dmesg.c
@@ -93,6 +93,6 @@ int dmesg_main (int argc, char **argv)
     exit (TRUE);
 
   end:
-    fprintf (stderr, "Usage: %s\n", dmesg_usage);
+    usage( dmesg_usage);
     exit (FALSE);
 }
diff --git a/dutmp.c b/dutmp.c
index 2dad7d4..7dd5b91 100644 (file)
--- a/dutmp.c
+++ b/dutmp.c
@@ -26,8 +26,7 @@ extern int dutmp_fn (int argc, char **argv)
     struct utmp ut;
 
     if ((argc < 2) || (**(argv + 1) == '-')) {
-       fprintf (stderr, "Usage: %s %s\n", *argv, dutmp_usage);
-       exit (FALSE);
+       usage( dutmp_usage);
     }
 
     if ( **(++argv) == 0 ) {
index ce6870c..58b8b37 100644 (file)
--- a/fdflush.c
+++ b/fdflush.c
@@ -32,8 +32,7 @@ extern int fdflush_main(int argc, char **argv)
     int        value;
     int        fd;
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: fdflush device\n");
-       exit(FALSE);
+       usage( "fdflush device\n");
     }
 
     fd = open(*argv, 0);
diff --git a/find.c b/find.c
index 1fb2194..51b8707 100644 (file)
--- a/find.c
+++ b/find.c
@@ -100,8 +100,7 @@ int find_main(int argc, char **argv)
                        pattern=*(++argv);
                        stopit=-TRUE;
                    } else {
-                       fprintf(stderr, "Usage: %s\n", find_usage);
-                       exit( FALSE);
+                       usage (find_usage);
                    }
                }
                break;
@@ -109,8 +108,7 @@ int find_main(int argc, char **argv)
                /* Ignore all long options */
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", find_usage);
-               exit( FALSE);
+               usage (find_usage);
        }
        if (argc-- > 1)
            argv++;
index 1fb2194..51b8707 100644 (file)
@@ -100,8 +100,7 @@ int find_main(int argc, char **argv)
                        pattern=*(++argv);
                        stopit=-TRUE;
                    } else {
-                       fprintf(stderr, "Usage: %s\n", find_usage);
-                       exit( FALSE);
+                       usage (find_usage);
                    }
                }
                break;
@@ -109,8 +108,7 @@ int find_main(int argc, char **argv)
                /* Ignore all long options */
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", find_usage);
-               exit( FALSE);
+               usage (find_usage);
        }
        if (argc-- > 1)
            argv++;
index b676e5f..a77ac38 100644 (file)
@@ -130,6 +130,8 @@ const char* timeString(time_t timeVal);
 
 extern void createPath (const char *name, int mode);
 extern int parse_mode( const char* s, mode_t* theMode);
+extern volatile void usage(const char *usage);
+
 
 #endif
 
diff --git a/kill.c b/kill.c
index 58dc8a9..00f10f9 100644 (file)
--- a/kill.c
+++ b/kill.c
@@ -130,8 +130,7 @@ extern int kill_main (int argc, char **argv)
     }
     if (had_error) {
 end:
-       fprintf(stderr, "Usage: %s\n", kill_usage);
-       exit ( FALSE);
+       usage (kill_usage);
     }
     exit (TRUE);
 }
index f2dadd2..46242b5 100644 (file)
--- a/length.c
+++ b/length.c
@@ -7,8 +7,7 @@ extern int
 length_main(int argc, char * * argv)
 {
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: length string\n");
-       exit(FALSE);
+       usage("length string\n");
     }
     printf("%d\n", strlen(argv[1]));
     return( TRUE);
diff --git a/ln.c b/ln.c
index cd3cb4e..8f7719f 100644 (file)
--- a/ln.c
+++ b/ln.c
@@ -44,8 +44,7 @@ extern int ln_main(int argc, char **argv)
     char newdestName[NAME_MAX];
 
     if (argc < 3) {
-       fprintf(stderr, "Usage: %s", ln_usage);
-       exit (FALSE);
+       usage (ln_usage);
     }
     argc--;
     argv++;
@@ -61,8 +60,7 @@ extern int ln_main(int argc, char **argv)
                removeoldFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", ln_usage);
-               exit(FALSE);
+               usage (ln_usage);
            }
        argc--;
        argv++;
index 0f092d1..eb5a5dd 100644 (file)
@@ -14,7 +14,7 @@ const char                    loadkmap_usage[] = "loadkmap\n"
 
 
 int
-loadkmap_main(struct FileInfo * info, int argc, char * * argv)
+loadkmap_main(int argc, char * * argv)
 { 
     struct kbentry ke;
     u_short *ibuff;
diff --git a/ls.c b/ls.c
index 2e3d50e..0adc35d 100644 (file)
--- a/ls.c
+++ b/ls.c
@@ -19,6 +19,8 @@
  *
  */
 
+// I started writing a newer small one, but it isn't done yet....
+//  -Erik
 #if fooBar
 
 #include <stdio.h>
@@ -110,8 +112,7 @@ int ls_main(int argc, char **argv)
                recursiveFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", ls_usage);
-               exit( FALSE);
+               usage (ls_usage);
        }
        argc--;
        argv++;
@@ -571,7 +572,7 @@ listerr:
        return 1;
 }
 
-const char     ls_usage[] = "Usage: ls [-1a"
+const char     ls_usage[] = "ls [-1a"
 #ifdef FEATURE_TIMESTAMPS
        "c"
 #endif
@@ -668,7 +669,7 @@ ls_main(int argc, char * * argv)
        exit( i);
 
 print_usage_message:
-       fprintf(stderr, "Usage: %s\n", ls_usage);
+       usage (ls_usage);
        exit( FALSE);
 }
 
index 691236e..00f0066 100644 (file)
@@ -21,7 +21,7 @@ const char makedevs_usage[] =
 "\tmakedevs /dev/hda b 3 0 0 8 s         (hda,hda1-hda8)\n";
 
 int
-makedevs_main(struct FileInfo * i, int argc, char * * argv)
+makedevs_main(int argc, char * * argv)
 {
 
 const char *basedev = argv[1];
@@ -45,7 +45,7 @@ char buf[255];
                case 'f':
                        mode = S_IFIFO; break;
                default:
-                       usage(makedevs_usage);
+                       fprintf(stderr, "Usage: %s\n", makedevs_usage);
                        return 2;
        }       
        mode |= 0660; 
index 2dad7d4..7dd5b91 100644 (file)
@@ -26,8 +26,7 @@ extern int dutmp_fn (int argc, char **argv)
     struct utmp ut;
 
     if ((argc < 2) || (**(argv + 1) == '-')) {
-       fprintf (stderr, "Usage: %s %s\n", *argv, dutmp_usage);
-       exit (FALSE);
+       usage( dutmp_usage);
     }
 
     if ( **(++argv) == 0 ) {
index 691236e..00f0066 100644 (file)
@@ -21,7 +21,7 @@ const char makedevs_usage[] =
 "\tmakedevs /dev/hda b 3 0 0 8 s         (hda,hda1-hda8)\n";
 
 int
-makedevs_main(struct FileInfo * i, int argc, char * * argv)
+makedevs_main(int argc, char * * argv)
 {
 
 const char *basedev = argv[1];
@@ -45,7 +45,7 @@ char buf[255];
                case 'f':
                        mode = S_IFIFO; break;
                default:
-                       usage(makedevs_usage);
+                       fprintf(stderr, "Usage: %s\n", makedevs_usage);
                        return 2;
        }       
        mode |= 0660; 
index 7d75fbd..a61ad5a 100644 (file)
@@ -50,7 +50,7 @@ static const struct mt_opcodes        opcodes[] = {
 };
 
 extern int
-mt_main(struct FileInfo * i, int argc, char * * argv)
+mt_main(int argc, char** argv)
 {
        const char *                            file = "/dev/tape";
        const struct mt_opcodes *       code = opcodes;
@@ -59,8 +59,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
        
        if ( strcmp(argv[1], "-f") == 0 ) {
                if ( argc < 4 ) {
-                       usage(mt_usage);
-                       return 1;
+                   usage (mt_usage);
                }
                file = argv[2];
                argv += 2;
@@ -75,7 +74,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
 
        if ( code->name == 0 ) {
                fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
-               return 1;
+               return( FALSE);
        }
 
        op.mt_op = code->value;
@@ -85,14 +84,14 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
                op.mt_count = 1; /* One, not zero, right? */
 
        if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
-               name_and_error(file);
-               return 1;
+               perror(file);
+               return( FALSE);
        }
 
        if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {
-               name_and_error(file);
-               return 1;
+               perror(file);
+               return( FALSE);
        }
 
-       return 0;
+       return( TRUE);
 }
diff --git a/mkdir.c b/mkdir.c
index 61d35d5..b42899a 100644 (file)
--- a/mkdir.c
+++ b/mkdir.c
@@ -51,8 +51,7 @@ extern int mkdir_main(int argc, char **argv)
                parentFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "%s\n", mkdir_usage);
-               exit(FALSE);
+               usage( mkdir_usage);
            }
        argc--;
        argv++;
@@ -60,8 +59,7 @@ extern int mkdir_main(int argc, char **argv)
 
 
     if (argc < 1) {
-       fprintf(stderr, "%s\n", mkdir_usage);
-       exit (FALSE);
+       usage( mkdir_usage);
     }
 
     while (--argc > 0) {
diff --git a/mknod.c b/mknod.c
index b18394b..95d7de3 100644 (file)
--- a/mknod.c
+++ b/mknod.c
@@ -1,4 +1,5 @@
 #include "internal.h"
+#include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -13,7 +14,7 @@ const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
 "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
 
 int
-mknod_main(struct FileInfo * i, int argc, char * * argv)
+mknod_main(int argc, char** argv)
 {
        mode_t  mode = 0;
        dev_t   dev = 0;
@@ -30,23 +31,21 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
                mode = S_IFIFO;
                break;
        default:
-               usage(mknod_usage);
-               return 1;
+               usage (mknod_usage);
        }
 
        if ( mode == S_IFCHR || mode == S_IFBLK ) {
                dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
                if ( argc != 5 ) {
-                       usage(mknod_usage);
-                       return 1;
+                   usage (mknod_usage);
                }
        }
 
        mode |= 0666;
 
        if ( mknod(argv[1], mode, dev) != 0 ) {
-               name_and_error(argv[1]);
-               return 1;
+               perror(argv[1]);
+               return( FALSE);
        }
-       return 0;
+       return( TRUE);
 }
index f797d13..8c0c4de 100644 (file)
--- a/mkswap.c
+++ b/mkswap.c
@@ -83,7 +83,7 @@ static int bit_test_and_clear (unsigned int *addr, unsigned int nr)
 volatile void fatal_error(const char * fmt_string)
 {
        fprintf(stderr,fmt_string,program_name,device_name);
-       exit(1);
+       exit(FALSE);
 }
 
 #define die(str) fatal_error("%s: " str "\n")
@@ -170,7 +170,7 @@ static int get_size(const char  *file)
 }
 
 int
-mkswap(char *device_name, int pages, int check)
+mkswap(const char *device_name, int pages, int check)
   {
        struct stat statbuf;
        int goodpages;
@@ -219,10 +219,10 @@ mkswap(char *device_name, int pages, int check)
                die("unable to write signature page");
 
        close(DEV);
-       return 0;
+       return (TRUE);
 }
 
-int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv)
+int mkswap_main(int argc, char ** argv)
 {
        char * tmp;
        long int pages=0;
@@ -237,17 +237,16 @@ int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv)
                        if (device_name) {
                                pages = strtol(argv[0],&tmp,0)>>(PAGE_SHIFT-10);
                                if (*tmp) {
-                                       usage(mkswap_usage);
-                                       exit(1);
+                                   usage (mkswap_usage);
                                }
                        } else
                                device_name = argv[0];
                else while (*++argv[0])
                        switch (argv[0][0]) {
                                case 'c': check=1; break;
-                               default: usage(mkswap_usage);
-                                       exit(1);
+                               default: usage (mkswap_usage);
+                                       exit( TRUE);
                        }
        }
-       return mkswap(device_name, pages, check);
+       exit( mkswap(device_name, pages, check));
 }
diff --git a/more.c b/more.c
index a56ce97..53437ed 100644 (file)
--- a/more.c
+++ b/more.c
@@ -59,8 +59,7 @@ extern int more_main(int argc, char **argv)
     FILE *file = stdin;
 
     if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
-       fprintf(stderr, "Usage: %s %s", *argv, more_usage);
-       exit(FALSE);
+       usage (more_usage);
     }
     argc--;
     argv++;
diff --git a/mt.c b/mt.c
index 7d75fbd..a61ad5a 100644 (file)
--- a/mt.c
+++ b/mt.c
@@ -50,7 +50,7 @@ static const struct mt_opcodes        opcodes[] = {
 };
 
 extern int
-mt_main(struct FileInfo * i, int argc, char * * argv)
+mt_main(int argc, char** argv)
 {
        const char *                            file = "/dev/tape";
        const struct mt_opcodes *       code = opcodes;
@@ -59,8 +59,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
        
        if ( strcmp(argv[1], "-f") == 0 ) {
                if ( argc < 4 ) {
-                       usage(mt_usage);
-                       return 1;
+                   usage (mt_usage);
                }
                file = argv[2];
                argv += 2;
@@ -75,7 +74,7 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
 
        if ( code->name == 0 ) {
                fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
-               return 1;
+               return( FALSE);
        }
 
        op.mt_op = code->value;
@@ -85,14 +84,14 @@ mt_main(struct FileInfo * i, int argc, char * * argv)
                op.mt_count = 1; /* One, not zero, right? */
 
        if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
-               name_and_error(file);
-               return 1;
+               perror(file);
+               return( FALSE);
        }
 
        if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {
-               name_and_error(file);
-               return 1;
+               perror(file);
+               return( FALSE);
        }
 
-       return 0;
+       return( TRUE);
 }
diff --git a/mv.c b/mv.c
index 2a7c8c1..ab3fc2b 100644 (file)
--- a/mv.c
+++ b/mv.c
@@ -42,8 +42,7 @@ extern int mv_main(int argc, char **argv)
     char newdestName[NAME_MAX];
 
     if (argc < 3) {
-       fprintf(stderr, "Usage: %s", mv_usage);
-       exit (FALSE);
+       usage (mv_usage);
     }
     argc--;
     argv++;
index e79843c..4d44659 100644 (file)
--- a/printf.c
+++ b/printf.c
@@ -1,8 +1,3 @@
-// I may still need some more cleaning...fix my error checking
-
-#include "internal.h"
-#ifdef BB_PRINTF
-
 /* printf - format and print data
    Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
 
@@ -51,6 +46,7 @@
 
 //   19990508 Busy Boxed! Dave Cinege
 
+#include "internal.h"
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -140,15 +136,18 @@ static void verify __P ((char *s, char *end));
 /* The value to return to the calling program.  */
 static int exit_status;
 
-const char     printf_usage[] = "Usage: printf format [argument...]\n";
+const char     printf_usage[] = "printf format [argument...]\n";
 
 int
-printf_main(struct FileInfo * i, int argc, char * * argv)
+printf_main(int argc, char** argv)
 {
   char *format;
   int args_used;
 
   exit_status = 0;
+  if ( **(argv+1) == '-' ) {
+    usage (printf_usage);
+  }
 
   format = argv[1];
   argc -= 2;
@@ -528,4 +527,3 @@ verify (char *s, char *end)
     }
 }
 
-#endif
index 58dc8a9..00f10f9 100644 (file)
@@ -130,8 +130,7 @@ extern int kill_main (int argc, char **argv)
     }
     if (had_error) {
 end:
-       fprintf(stderr, "Usage: %s\n", kill_usage);
-       exit ( FALSE);
+       usage (kill_usage);
     }
     exit (TRUE);
 }
diff --git a/rm.c b/rm.c
index 477d3af..dd8dfa4 100644 (file)
--- a/rm.c
+++ b/rm.c
@@ -25,7 +25,7 @@
 #include <utime.h>
 #include <dirent.h>
 
-static const char* rm_usage = "Usage: rm [OPTION]... FILE...\n"
+static const char* rm_usage = "rm [OPTION]... FILE...\n"
 "Remove (unlink) the FILE(s).\n\n"
 "\t-f\tremove existing destinations, never prompt\n"
 "\t-r\tremove the contents of directories recursively\n";
@@ -58,8 +58,7 @@ extern int rm_main(int argc, char **argv)
 {
 
     if (argc < 2) {
-       fprintf(stderr, "Usage: %s", rm_usage);
-       exit (FALSE);
+       usage( rm_usage);
     }
     argc--;
     argv++;
@@ -75,8 +74,7 @@ extern int rm_main(int argc, char **argv)
                forceFlag = TRUE;
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", rm_usage);
-               exit(FALSE);
+               usage( rm_usage);
            }
        argc--;
        argv++;
diff --git a/rmdir.c b/rmdir.c
index b4da03f..666e047 100644 (file)
--- a/rmdir.c
+++ b/rmdir.c
@@ -27,8 +27,7 @@
 extern int rmdir_main(int argc, char **argv)
 {
     if ( argc==1 || **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
-       exit(FALSE);
+       usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
     }
 
     while (--argc > 0) {
diff --git a/sleep.c b/sleep.c
index 53fe5a0..7e38a36 100644 (file)
--- a/sleep.c
+++ b/sleep.c
@@ -8,8 +8,7 @@ extern int
 sleep_main(int argc, char * * argv)
 {
         if ( (argc < 2) || (**(argv+1) == '-') ) {
-           fprintf(stderr, "Usage: %s %s", *argv, sleep_usage);
-           exit(FALSE);
+           usage( sleep_usage );
        }
 
        if ( sleep(atoi(*(++argv))) != 0 ) {
index 56f93b3..5a2d735 100644 (file)
@@ -33,10 +33,10 @@ static int whichApp;
 static const char* appName;
 
 static const char swapoff_usage[] = 
-"Usage: swapoff device\n"
+"swapoff device\n"
 "\nStop swapping virtual memory pages on the given device.\n";
 static const char swapon_usage[] = 
-"Usage: swapon device\n"
+"swapon device\n"
 "\nStart swapping virtual memory pages on the given device.\n";
 
 
@@ -112,10 +112,10 @@ swap_on_off_main(int argc, char * * argv)
        }
     }
     swap_enable_disable(*argv);
-    //exit( TRUE);
+    exit( TRUE);
 
 usage_and_exit:
-    fprintf(stderr, "Usage: %s", (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage);
-    exit(FALSE);
+    usage( (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage);
+    exit( FALSE);
 }
 
diff --git a/sync.c b/sync.c
index 572d749..8800f2e 100644 (file)
--- a/sync.c
+++ b/sync.c
@@ -5,9 +5,8 @@ extern int
 sync_main(int argc, char * * argv)
 {
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: sync\nWrite all buffered filesystem blocks to disk.\n");
-       exit(FALSE);
+       usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
     }
-       return sync();
+    return sync();
 }
 
diff --git a/touch.c b/touch.c
index 8dac102..c36ffca 100644 (file)
--- a/touch.c
+++ b/touch.c
@@ -40,8 +40,7 @@ touch_main(int argc, char **argv)
     int create=TRUE;
 
     if (argc < 2) {
-       fprintf(stderr, "Usage: %s %s", *argv, touch_usage);
-       exit( FALSE);
+       usage( touch_usage);
     }
     argc--;
     argv++;
index a83a508..625fcfa 100644 (file)
--- a/umount.c
+++ b/umount.c
@@ -71,8 +71,7 @@ umount_main(int argc, char * * argv)
 {
 
     if (argc < 2) {
-       fprintf(stderr, "Usage: %s", umount_usage);
-       exit(FALSE);
+       usage( umount_usage); 
     }
     argc--;
     argv++;
@@ -84,8 +83,7 @@ umount_main(int argc, char * * argv)
                exit ( umount_all() );
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", umount_usage);
-               exit( FALSE);
+               usage( umount_usage);
        }
     }
     if ( umount(*argv) == 0 )
index 64265b4..e5d403f 100644 (file)
@@ -93,6 +93,6 @@ int dmesg_main (int argc, char **argv)
     exit (TRUE);
 
   end:
-    fprintf (stderr, "Usage: %s\n", dmesg_usage);
+    usage( dmesg_usage);
     exit (FALSE);
 }
index ce6870c..58b8b37 100644 (file)
@@ -32,8 +32,7 @@ extern int fdflush_main(int argc, char **argv)
     int        value;
     int        fd;
     if ( **(argv+1) == '-' ) {
-       fprintf(stderr, "Usage: fdflush device\n");
-       exit(FALSE);
+       usage( "fdflush device\n");
     }
 
     fd = open(*argv, 0);
index f797d13..8c0c4de 100644 (file)
@@ -83,7 +83,7 @@ static int bit_test_and_clear (unsigned int *addr, unsigned int nr)
 volatile void fatal_error(const char * fmt_string)
 {
        fprintf(stderr,fmt_string,program_name,device_name);
-       exit(1);
+       exit(FALSE);
 }
 
 #define die(str) fatal_error("%s: " str "\n")
@@ -170,7 +170,7 @@ static int get_size(const char  *file)
 }
 
 int
-mkswap(char *device_name, int pages, int check)
+mkswap(const char *device_name, int pages, int check)
   {
        struct stat statbuf;
        int goodpages;
@@ -219,10 +219,10 @@ mkswap(char *device_name, int pages, int check)
                die("unable to write signature page");
 
        close(DEV);
-       return 0;
+       return (TRUE);
 }
 
-int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv)
+int mkswap_main(int argc, char ** argv)
 {
        char * tmp;
        long int pages=0;
@@ -237,17 +237,16 @@ int mkswap_main(struct FileInfo * unnecessary, int argc, char ** argv)
                        if (device_name) {
                                pages = strtol(argv[0],&tmp,0)>>(PAGE_SHIFT-10);
                                if (*tmp) {
-                                       usage(mkswap_usage);
-                                       exit(1);
+                                   usage (mkswap_usage);
                                }
                        } else
                                device_name = argv[0];
                else while (*++argv[0])
                        switch (argv[0][0]) {
                                case 'c': check=1; break;
-                               default: usage(mkswap_usage);
-                                       exit(1);
+                               default: usage (mkswap_usage);
+                                       exit( TRUE);
                        }
        }
-       return mkswap(device_name, pages, check);
+       exit( mkswap(device_name, pages, check));
 }
index a56ce97..53437ed 100644 (file)
@@ -59,8 +59,7 @@ extern int more_main(int argc, char **argv)
     FILE *file = stdin;
 
     if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
-       fprintf(stderr, "Usage: %s %s", *argv, more_usage);
-       exit(FALSE);
+       usage (more_usage);
     }
     argc--;
     argv++;
index 56f93b3..5a2d735 100644 (file)
@@ -33,10 +33,10 @@ static int whichApp;
 static const char* appName;
 
 static const char swapoff_usage[] = 
-"Usage: swapoff device\n"
+"swapoff device\n"
 "\nStop swapping virtual memory pages on the given device.\n";
 static const char swapon_usage[] = 
-"Usage: swapon device\n"
+"swapon device\n"
 "\nStart swapping virtual memory pages on the given device.\n";
 
 
@@ -112,10 +112,10 @@ swap_on_off_main(int argc, char * * argv)
        }
     }
     swap_enable_disable(*argv);
-    //exit( TRUE);
+    exit( TRUE);
 
 usage_and_exit:
-    fprintf(stderr, "Usage: %s", (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage);
-    exit(FALSE);
+    usage( (whichApp==SWAPON_APP)? swapon_usage : swapoff_usage);
+    exit( FALSE);
 }
 
index a83a508..625fcfa 100644 (file)
@@ -71,8 +71,7 @@ umount_main(int argc, char * * argv)
 {
 
     if (argc < 2) {
-       fprintf(stderr, "Usage: %s", umount_usage);
-       exit(FALSE);
+       usage( umount_usage); 
     }
     argc--;
     argv++;
@@ -84,8 +83,7 @@ umount_main(int argc, char * * argv)
                exit ( umount_all() );
                break;
            default:
-               fprintf(stderr, "Usage: %s\n", umount_usage);
-               exit( FALSE);
+               usage( umount_usage);
        }
     }
     if ( umount(*argv) == 0 )
index c6121cb..f86216e 100644 (file)
--- a/utility.c
+++ b/utility.c
 #include <unistd.h>
 
 
+/* volatile so gcc knows this is the enod of the line */
+volatile void usage(const char *usage)
+{
+    fprintf(stderr, "Usage: %s\n", usage);
+    exit(FALSE);
+}
+
+
 
 #if defined (BB_CP) || defined (BB_MV)
 /*