diff options
-rw-r--r-- | Changelog | 9 | ||||
-rw-r--r-- | applets/busybox.c | 8 | ||||
-rw-r--r-- | archival/tar.c | 51 | ||||
-rw-r--r-- | busybox.c | 8 | ||||
-rw-r--r-- | busybox.def.h | 25 | ||||
-rw-r--r-- | chmod_chown_chgrp.c | 24 | ||||
-rw-r--r-- | chroot.c | 2 | ||||
-rw-r--r-- | chvt.c | 2 | ||||
-rw-r--r-- | console-tools/chvt.c | 2 | ||||
-rw-r--r-- | console-tools/deallocvt.c | 6 | ||||
-rw-r--r-- | coreutils/chroot.c | 2 | ||||
-rw-r--r-- | coreutils/cp.c | 2 | ||||
-rw-r--r-- | coreutils/date.c | 2 | ||||
-rw-r--r-- | coreutils/dd.c | 5 | ||||
-rw-r--r-- | coreutils/ln.c | 6 | ||||
-rw-r--r-- | coreutils/mkdir.c | 7 | ||||
-rw-r--r-- | coreutils/mknod.c | 6 | ||||
-rw-r--r-- | coreutils/mv.c | 2 | ||||
-rw-r--r-- | coreutils/rm.c | 3 | ||||
-rw-r--r-- | coreutils/rmdir.c | 2 | ||||
-rw-r--r-- | coreutils/sleep.c | 4 | ||||
-rw-r--r-- | coreutils/sync.c | 2 | ||||
-rw-r--r-- | coreutils/touch.c | 4 | ||||
-rw-r--r-- | coreutils/uname.c | 5 | ||||
-rw-r--r-- | cp.c | 2 | ||||
-rw-r--r-- | date.c | 2 | ||||
-rw-r--r-- | dd.c | 5 | ||||
-rw-r--r-- | deallocvt.c | 6 | ||||
-rw-r--r-- | editors/sed.c | 14 | ||||
-rw-r--r-- | find.c | 15 | ||||
-rw-r--r-- | findutils/find.c | 15 | ||||
-rw-r--r-- | findutils/grep.c | 7 | ||||
-rw-r--r-- | fsck_minix.c | 14 | ||||
-rw-r--r-- | grep.c | 7 | ||||
-rw-r--r-- | init.c | 7 | ||||
-rw-r--r-- | init/init.c | 7 | ||||
-rw-r--r-- | internal.h | 2 | ||||
-rw-r--r-- | ln.c | 6 | ||||
-rw-r--r-- | mkdir.c | 7 | ||||
-rw-r--r-- | mkfs_minix.c | 13 | ||||
-rw-r--r-- | mknod.c | 6 | ||||
-rw-r--r-- | mkswap.c | 9 | ||||
-rw-r--r-- | more.c | 2 | ||||
-rw-r--r-- | mount.c | 21 | ||||
-rw-r--r-- | mv.c | 2 | ||||
-rw-r--r-- | procps/ps.c | 2 | ||||
-rw-r--r-- | ps.c | 2 | ||||
-rw-r--r-- | rm.c | 3 | ||||
-rw-r--r-- | rmdir.c | 2 | ||||
-rw-r--r-- | sed.c | 14 | ||||
-rw-r--r-- | sleep.c | 4 | ||||
-rw-r--r-- | sync.c | 2 | ||||
-rw-r--r-- | tar.c | 51 | ||||
-rw-r--r-- | touch.c | 4 | ||||
-rw-r--r-- | umount.c | 6 | ||||
-rw-r--r-- | uname.c | 5 | ||||
-rw-r--r-- | util-linux/fsck_minix.c | 14 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 13 | ||||
-rw-r--r-- | util-linux/mkswap.c | 9 | ||||
-rw-r--r-- | util-linux/more.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 21 | ||||
-rw-r--r-- | util-linux/umount.c | 6 | ||||
-rw-r--r-- | utility.c | 2 |
63 files changed, 290 insertions, 230 deletions
@@ -1,3 +1,12 @@ +0.35 + * Fixed tar so it now works as expected (it had TRUE/FALSE backwards) + * tar now accepts --help + * chmod, chown, and chgrp usage now works + * General usage cleanups in most apps + * umount now parses options correctly + + -Erik Andersen + 0.34 * ls -l now displays link names outside the current directory, Patch thanks to Eric Delaunay diff --git a/applets/busybox.c b/applets/busybox.c index 29a112b..c45d0c7 100644 --- a/applets/busybox.c +++ b/applets/busybox.c @@ -220,12 +220,12 @@ int busybox_main(int argc, char **argv) if (been_there_done_that == 1 || argc < 1) { const struct Applet *a = applets; - fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n", + fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); - fprintf(stderr, "\nUsage:\t[function] [arguments]...\n"); - fprintf(stderr, "\tbusybox [function] [arguments]...\n"); + fprintf(stderr, "Usage: busybox [function] [arguments]...\n"); + fprintf(stderr, " or: [function] [arguments]...\n\n"); fprintf(stderr, - "\n\tMost people will create a symlink to busybox for each\n" + "\tMost people will create a symlink to busybox for each\n" "\tfunction name, and busybox will act like whatever you invoke it as.\n"); fprintf(stderr, "\nCurrently defined functions:\n"); diff --git a/archival/tar.c b/archival/tar.c index c238059..ed6f3b6 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -35,22 +35,13 @@ #include <signal.h> #include <time.h> -/* Note that tar.c expects TRUE and FALSE to be defined - * exactly the opposite of how they are used everywhere else. - * Some time this should be integrated a bit better, but this - * does the job for now. - */ -//#undef FALSE -//#undef TRUE -//#define FALSE ((int) 0) -//#define TRUE ((int) 1) - static const char tar_usage[] = - "tar -[cxtvOf] [tarFileName] [FILE] ...\n" - "Create, extract, or list files from a tar file\n\n" - "\tc=create, x=extract, t=list contents, v=verbose,\n" - "\tO=extract to stdout, f=tarfile or \"-\" for stdin\n"; +"tar -[cxtvOf] [tarFileName] [FILE] ...\n\n" +"Create, extract, or list files from a tar file\n\n" +"Options:\n" +"\tc=create, x=extract, t=list contents, v=verbose,\n" +"\tO=extract to stdout, f=tarfile or \"-\" for stdin\n"; @@ -96,18 +87,18 @@ typedef struct { /* * Static data. */ -static int listFlag; // -static int extractFlag; // -static int createFlag; // -static int verboseFlag; // -static int tostdoutFlag; // +static int listFlag; +static int extractFlag; +static int createFlag; +static int verboseFlag; +static int tostdoutFlag; static int inHeader; // <- check me -static int badHeader; // -static int errorFlag; // -static int skipFileFlag; // -static int warnedRoot; // -static int eofFlag; // +static int badHeader; +static int errorFlag; +static int skipFileFlag; +static int warnedRoot; +static int eofFlag; static long dataCc; static int outFd; static char outName[TAR_NAME_SIZE]; @@ -136,7 +127,7 @@ static void readHeader (const TarHeader * hp, /* * Local procedures to save files into a tar file. */ -static void saveFile (const char *fileName, int seeLinks); // +static void saveFile (const char *fileName, int seeLinks); static void saveRegularFile (const char *fileName, const struct stat *statbuf); @@ -145,13 +136,13 @@ static void saveDirectory (const char *fileName, const struct stat *statbuf); static int wantFileName (const char *fileName, - int fileCount, char **fileTable); // + int fileCount, char **fileTable); static void writeHeader (const char *fileName, const struct stat *statbuf); static void writeTarFile (int fileCount, char **fileTable); static void writeTarBlock (const char *buf, int len); -static int putOctal (char *cp, int len, long value); // +static int putOctal (char *cp, int len, long value); extern int tar_main (int argc, char **argv) @@ -217,10 +208,13 @@ extern int tar_main (int argc, char **argv) break; case '-': + usage( tar_usage); break; default: - fprintf (stderr, "Unknown tar flag '%c'\n", *options); + fprintf (stderr, "Unknown tar flag '%c'\n" + "Try `tar --help' for more information\n", + *options); exit (FALSE); } @@ -230,7 +224,6 @@ extern int tar_main (int argc, char **argv) /* * Validate the options. */ - fprintf(stderr, "TRUE=%d FALSE=%d\n", TRUE, FALSE); if (extractFlag + listFlag + createFlag != (TRUE+FALSE+FALSE)) { fprintf (stderr, "Exactly one of 'c', 'x' or 't' must be specified\n"); @@ -220,12 +220,12 @@ int busybox_main(int argc, char **argv) if (been_there_done_that == 1 || argc < 1) { const struct Applet *a = applets; - fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n", + fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); - fprintf(stderr, "\nUsage:\t[function] [arguments]...\n"); - fprintf(stderr, "\tbusybox [function] [arguments]...\n"); + fprintf(stderr, "Usage: busybox [function] [arguments]...\n"); + fprintf(stderr, " or: [function] [arguments]...\n\n"); fprintf(stderr, - "\n\tMost people will create a symlink to busybox for each\n" + "\tMost people will create a symlink to busybox for each\n" "\tfunction name, and busybox will act like whatever you invoke it as.\n"); fprintf(stderr, "\nCurrently defined functions:\n"); diff --git a/busybox.def.h b/busybox.def.h index 615289b..79cbb27 100644 --- a/busybox.def.h +++ b/busybox.def.h @@ -2,6 +2,7 @@ * This file is parsed by sed. You MUST use single line comments. * IE //#define BB_BLAH */ + #define BB_BUSYBOX #define BB_CAT #define BB_CHMOD_CHOWN_CHGRP @@ -12,48 +13,48 @@ #define BB_DD #define BB_DF #define BB_DMESG -#define BB_DUTMP -#define BB_FDFLUSH +//#define BB_DUTMP +//#define BB_FDFLUSH #define BB_FIND #define BB_FSCK_MINIX #define BB_MKFS_MINIX #define BB_CHVT #define BB_DEALLOCVT #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_LOADFONT #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_MNC +//#define BB_MNC #define BB_MORE #define BB_MOUNT -#define BB_MT -#define BB_MTAB +//#define BB_MT +//#define BB_MTAB #define BB_MV -#define BB_PRINTF +//#define BB_PRINTF #define BB_PS #define BB_PWD #define BB_REGEXP #define BB_REBOOT #define BB_RM #define BB_RMDIR -#define BB_SFDISK +//#define BB_SFDISK #define BB_SED #define BB_SLEEP #define BB_SWAPONOFF #define BB_SYNC #define BB_TAR #define BB_TOUCH -#define BB_TRUE_FALSE +//#define BB_TRUE_FALSE // Supplied by ash #define BB_UMOUNT #define BB_UPDATE #define BB_UNAME diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index da3ba8d..e9704ff 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c @@ -38,16 +38,16 @@ static mode_t mode=0644; #define CHOWN_APP 2 #define CHMOD_APP 3 -static const char chgrp_usage[] = "[OPTION]... GROUP FILE...\n" +static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n\n" "Change the group membership of each FILE to GROUP.\n" - "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; -static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\n" + "\nOptions:\n\t-R\tchange files and directories recursively\n"; +static const char chown_usage[] = "chown [OPTION]... OWNER[.[GROUP] FILE...\n\n" "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" - "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; -static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n" + "\nOptions:\n\t-R\tchange files and directories recursively\n"; +static const char chmod_usage[] = "chmod [-R] MODE[,MODE]... FILE...\n\n" "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n" "one or more of the letters rwxst.\n\n" - "\t-R\tchange files and directories recursively.\n"; + "\nOptions:\n\t-R\tchange files and directories recursively.\n"; static int fileAction(const char *fileName, struct stat* statbuf) @@ -73,14 +73,14 @@ int chmod_chown_chgrp_main(int argc, char **argv) { int recursiveFlag=FALSE; char *groupName; + const char *appUsage; whichApp = (strcmp(*argv, "chown")==0)? CHOWN_APP : (strcmp(*argv, "chmod")==0)? CHMOD_APP : CHGRP_APP; - if (argc < 2) { - fprintf(stderr, "Usage: %s %s", *argv, - (whichApp==TRUE)? chown_usage : chgrp_usage); - exit( FALSE); - } + appUsage = (whichApp==CHOWN_APP)? chown_usage : (whichApp==CHMOD_APP)? chmod_usage : chgrp_usage; + + if (argc < 2) + usage( appUsage); invocationName=*argv; argc--; argv++; @@ -93,7 +93,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) break; default: fprintf(stderr, "Unknown option: %c\n", **argv); - exit( FALSE); + usage( appUsage); } argc--; argv++; @@ -27,7 +27,7 @@ #include <errno.h> -static const char chroot_usage[] = "NEWROOT [COMMAND...]\n" +static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n" "Run COMMAND with root directory set to NEWROOT.\n"; @@ -19,7 +19,7 @@ chvt_main(int argc, char** argv) int fd, num; if ( ( argc != 2) || (**(argv+1) == '-' ) ) { - usage ("chvt </dev/ttyN>\n"); + usage ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n"); } fd = get_console_fd("/dev/console"); num = atoi(argv[1]); diff --git a/console-tools/chvt.c b/console-tools/chvt.c index 81d1995..bea00ea 100644 --- a/console-tools/chvt.c +++ b/console-tools/chvt.c @@ -19,7 +19,7 @@ chvt_main(int argc, char** argv) int fd, num; if ( ( argc != 2) || (**(argv+1) == '-' ) ) { - usage ("chvt </dev/ttyN>\n"); + usage ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n"); } fd = get_console_fd("/dev/console"); num = atoi(argv[1]); diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index ae4dbb5..1e13ff6 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c @@ -17,8 +17,10 @@ int deallocvt_main(int argc, char *argv[]) { int fd, num, i; - if (argc < 1) /* unlikely */ - exit(1); + if ( ( argc != 2) || (**(argv+1) == '-' ) ) { + usage ("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n"); + } + progname = argv[0]; fd = get_console_fd("/dev/console"); diff --git a/coreutils/chroot.c b/coreutils/chroot.c index 8e432b3..16524d9 100644 --- a/coreutils/chroot.c +++ b/coreutils/chroot.c @@ -27,7 +27,7 @@ #include <errno.h> -static const char chroot_usage[] = "NEWROOT [COMMAND...]\n" +static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n" "Run COMMAND with root directory set to NEWROOT.\n"; diff --git a/coreutils/cp.c b/coreutils/cp.c index 9dac2af..57158c8 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -28,7 +28,7 @@ #include <dirent.h> static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n" - " or: cp [OPTION]... SOURCE... DIRECTORY\n" + " or: cp [OPTION]... SOURCE... DIRECTORY\n\n" "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n" "\n" "\t-a\tsame as -dpR\n" diff --git a/coreutils/date.c b/coreutils/date.c index 501ccc2..6be89df 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -35,7 +35,7 @@ mail commands */ static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" -" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" +" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\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" "\t-s\t\tset time described by STRING\n" diff --git a/coreutils/dd.c b/coreutils/dd.c index 33c4594..800ed59 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -34,7 +34,7 @@ #include <errno.h> static const char dd_usage[] = -"dd [if=name] [of=name] [bs=n] [count=n]\n" +"dd [if=name] [of=name] [bs=n] [count=n]\n\n" "Copy a file, converting and formatting according to options\n\n" "\tif=FILE\tread from FILE instead of stdin\n" "\tof=FILE\twrite to FILE instead of stout\n" @@ -227,8 +227,7 @@ extern int dd_main (int argc, char **argv) exit( TRUE); usage: - fprintf (stderr, "%s", dd_usage); - exit( FALSE); + usage( dd_usage); } diff --git a/coreutils/ln.c b/coreutils/ln.c index 62496fb..60fe394 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -27,9 +27,9 @@ #include <errno.h> -static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n" -"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n" -"\nOptions:\n" +static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n" +"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n" +"Options:\n" "\t-s\tmake symbolic links instead of hard links\n" "\t-f\tremove existing destination files\n"; diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 0d0a90e..4c7ebed 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -26,10 +26,11 @@ #include <errno.h> #include <sys/param.h> -static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n" +static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n\n" "Create the DIRECTORY(ies), if they do not already exist\n\n" -"-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" -"-p\tno error if existing, make parent directories as needed\n"; +"Options:\n" +"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" +"\t-p\tno error if existing, make parent directories as needed\n"; static int parentFlag = FALSE; diff --git a/coreutils/mknod.c b/coreutils/mknod.c index 81c846b..c3389cc 100644 --- a/coreutils/mknod.c +++ b/coreutils/mknod.c @@ -27,9 +27,9 @@ #include <fcntl.h> #include <unistd.h> -static const char mknod_usage[] = "mknod file b|c|u|p major minor\n" -"\tMake special files.\n" -"\n" +static const char mknod_usage[] = "mknod [OPTION]... NAME TYPE MAJOR MINOR\n\n" +"Make block or character special files.\n\n" +"Options:\n" "\tb:\tMake a block (buffered) device.\n" "\tc or u:\tMake a character (un-buffered) device.\n" "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; diff --git a/coreutils/mv.c b/coreutils/mv.c index e502250..b861ab7 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c @@ -29,7 +29,7 @@ static const char mv_usage[] = "mv SOURCE DEST\n" -" or: mv SOURCE... DIRECTORY\n" +" or: mv SOURCE... DIRECTORY\n\n" "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"; diff --git a/coreutils/rm.c b/coreutils/rm.c index 077e792..e6132ab 100644 --- a/coreutils/rm.c +++ b/coreutils/rm.c @@ -27,8 +27,9 @@ #include <utime.h> #include <dirent.h> -static const char* rm_usage = "rm [OPTION]... FILE...\n" +static const char* rm_usage = "rm [OPTION]... FILE...\n\n" "Remove (unlink) the FILE(s).\n\n" +"Options:\n" "\t-f\tremove existing destinations, never prompt\n" "\t-r\tremove the contents of directories recursively\n"; diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c index 56b8387..013fef1 100644 --- a/coreutils/rmdir.c +++ b/coreutils/rmdir.c @@ -29,7 +29,7 @@ extern int rmdir_main(int argc, char **argv) { if ( argc==1 || **(argv+1) == '-' ) { - usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty."); + usage( "rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n"); } while (--argc > 0) { diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 8266978..bfbb78f 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c @@ -23,8 +23,8 @@ #include "internal.h" #include <stdio.h> -const char sleep_usage[] = " NUMBER\n" -"Pause for NUMBER seconds.\n"; +const char sleep_usage[] = "sleep N\n\n" +"Pause for N seconds.\n"; extern int sleep_main(int argc, char * * argv) diff --git a/coreutils/sync.c b/coreutils/sync.c index cb4690c..145ed1e 100644 --- a/coreutils/sync.c +++ b/coreutils/sync.c @@ -27,7 +27,7 @@ extern int sync_main(int argc, char * * argv) { if ( argc>1 && **(argv+1) == '-' ) { - usage( "sync\nWrite all buffered filesystem blocks to disk.\n"); + usage( "sync\n\nWrite all buffered filesystem blocks to disk.\n"); } exit( sync()); } diff --git a/coreutils/touch.c b/coreutils/touch.c index b98a2e4..d2d3e94 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -31,7 +31,7 @@ static const char touch_usage[] = "touch [-c] file [file ...]\n\n" -"\tUpdate the last-modified date on the given file[s].\n"; +"Update the last-modified date on the given file[s].\n"; @@ -54,7 +54,7 @@ touch_main(int argc, char **argv) create = FALSE; break; default: - fprintf(stderr, "Unknown option: %c\n", **argv); + usage( touch_usage); exit( FALSE); } argc--; diff --git a/coreutils/uname.c b/coreutils/uname.c index b54deb3..9083edb 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c @@ -41,8 +41,9 @@ static const char uname_usage[] = - "uname [OPTION]...\n" - "Print certain system information. With no OPTION, same as -s.\n" + "uname [OPTION]...\n\n" + "Print certain system information. With no OPTION, same as -s.\n\n" + "Options:\n" "\t-a\tprint all information\n" "\t-m\tthe machine (hardware) type\n" "\t-n\tprint the machine's network node hostname\n" @@ -28,7 +28,7 @@ #include <dirent.h> static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n" - " or: cp [OPTION]... SOURCE... DIRECTORY\n" + " or: cp [OPTION]... SOURCE... DIRECTORY\n\n" "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n" "\n" "\t-a\tsame as -dpR\n" @@ -35,7 +35,7 @@ mail commands */ static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" -" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" +" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\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" "\t-s\t\tset time described by STRING\n" @@ -34,7 +34,7 @@ #include <errno.h> static const char dd_usage[] = -"dd [if=name] [of=name] [bs=n] [count=n]\n" +"dd [if=name] [of=name] [bs=n] [count=n]\n\n" "Copy a file, converting and formatting according to options\n\n" "\tif=FILE\tread from FILE instead of stdin\n" "\tof=FILE\twrite to FILE instead of stout\n" @@ -227,8 +227,7 @@ extern int dd_main (int argc, char **argv) exit( TRUE); usage: - fprintf (stderr, "%s", dd_usage); - exit( FALSE); + usage( dd_usage); } diff --git a/deallocvt.c b/deallocvt.c index ae4dbb5..1e13ff6 100644 --- a/deallocvt.c +++ b/deallocvt.c @@ -17,8 +17,10 @@ int deallocvt_main(int argc, char *argv[]) { int fd, num, i; - if (argc < 1) /* unlikely */ - exit(1); + if ( ( argc != 2) || (**(argv+1) == '-' ) ) { + usage ("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n"); + } + progname = argv[0]; fd = get_console_fd("/dev/console"); diff --git a/editors/sed.c b/editors/sed.c index 34756e0..4dfc024 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -32,18 +32,18 @@ #include <ctype.h> static const char sed_usage[] = -"sed [-n] [-e script] [file...]\n" -"Allowed scripts come in the following form:\n\n" -"'s/regexp/replacement/[gp]'\n" -"\tattempt to match regexp against the pattern space\n" -"\tand if successful replaces the matched portion with replacement.\n\n" +"sed [-n] [-e script] [file...]\n\n" +"Allowed sed scripts come in the following form:\n" +"\t's/regexp/replacement/[gp]'\n" +"which attempt to match regexp against the pattern space\n" +"and if successful replaces the matched portion with replacement.\n\n" "Options:\n" "-e\tadd the script to the commands to be executed\n" "-n\tsuppress automatic printing of pattern space\n\n" #if defined BB_REGEXP -"This version of sed matches full regexps.\n"; +"This version of sed matches full regular expresions.\n"; #else -"This version of sed matches strings (not full regexps).\n"; +"This version of sed matches strings (not full regular expresions).\n"; #endif @@ -32,9 +32,18 @@ static char* pattern=NULL; static char* directory="."; static int dereferenceFlag=FALSE; -static const char find_usage[] = "find [path...] [expression]\n" -"default path is the current directory; default expression is -print\n" -"expression may consist of:\n"; +static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n" +"Search for files in a directory hierarchy. The default PATH is\n" +"the current directory; default EXPRESSION is '-print'\n\n" +"\nEXPRESSION may consist of:\n" +"\t-follow\n\t\tDereference symbolic links.\n" +"\t-name PATTERN\n\t\tFile name (with leading directories removed) matches PATTERN.\n" +"\t-print\n\t\tprint the full file name followed by a newline to stdout.\n\n" +#if defined BB_REGEXP +"This version of find matches full regular expresions.\n"; +#else +"This version of find matches strings (not regular expresions).\n"; +#endif diff --git a/findutils/find.c b/findutils/find.c index ab9ebf4..0f1f5f1 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -32,9 +32,18 @@ static char* pattern=NULL; static char* directory="."; static int dereferenceFlag=FALSE; -static const char find_usage[] = "find [path...] [expression]\n" -"default path is the current directory; default expression is -print\n" -"expression may consist of:\n"; +static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n" +"Search for files in a directory hierarchy. The default PATH is\n" +"the current directory; default EXPRESSION is '-print'\n\n" +"\nEXPRESSION may consist of:\n" +"\t-follow\n\t\tDereference symbolic links.\n" +"\t-name PATTERN\n\t\tFile name (with leading directories removed) matches PATTERN.\n" +"\t-print\n\t\tprint the full file name followed by a newline to stdout.\n\n" +#if defined BB_REGEXP +"This version of find matches full regular expresions.\n"; +#else +"This version of find matches strings (not regular expresions).\n"; +#endif diff --git a/findutils/grep.c b/findutils/grep.c index 8dcff05..84bb996 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -32,15 +32,16 @@ #include <ctype.h> static const char grep_usage[] = -"grep [-ihn]... PATTERN [FILE]...\n" +"grep [OPTIONS]... PATTERN [FILE]...\n\n" "Search for PATTERN in each FILE or standard input.\n\n" +"OPTIONS:\n" "\t-h\tsuppress the prefixing filename on output\n" "\t-i\tignore case distinctions\n" "\t-n\tprint line number with output lines\n\n" #if defined BB_REGEXP -"This version of grep matches full regexps.\n"; +"This version of grep matches full regular expresions.\n"; #else -"This version of grep matches strings (not regexps).\n"; +"This version of grep matches strings (not regular expresions).\n"; #endif diff --git a/fsck_minix.c b/fsck_minix.c index 1252747..d31de20 100644 --- a/fsck_minix.c +++ b/fsck_minix.c @@ -191,9 +191,17 @@ static void leave(int status) } static void show_usage(void) { - fprintf(stderr, - "Usage: %s [-larvsmf] /dev/name\n", - program_name); + fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); + fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name); + fprintf(stderr, "Performs a consistency check for MINIX filesystems.\n\n"); + fprintf(stderr, "OPTIONS:\n"); + fprintf(stderr, "\t-l\tLists all filenames\n"); + fprintf(stderr, "\t-r\tPerform interactive repairs\n"); + fprintf(stderr, "\t-a\tPerform automatic repairs\n"); + fprintf(stderr, "\t-v\tverbose\n"); + fprintf(stderr, "\t-s\tOutputs super-block information\n"); + fprintf(stderr, "\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n"); + fprintf(stderr, "\t-f\tForce file system check.\n\n"); leave(16); } @@ -32,15 +32,16 @@ #include <ctype.h> static const char grep_usage[] = -"grep [-ihn]... PATTERN [FILE]...\n" +"grep [OPTIONS]... PATTERN [FILE]...\n\n" "Search for PATTERN in each FILE or standard input.\n\n" +"OPTIONS:\n" "\t-h\tsuppress the prefixing filename on output\n" "\t-i\tignore case distinctions\n" "\t-n\tprint line number with output lines\n\n" #if defined BB_REGEXP -"This version of grep matches full regexps.\n"; +"This version of grep matches full regular expresions.\n"; #else -"This version of grep matches strings (not regexps).\n"; +"This version of grep matches strings (not regular expresions).\n"; #endif @@ -430,6 +430,13 @@ extern int init_main(int argc, char **argv) #endif +#ifndef DEBUG_INIT + if (getpid() != 1) { + 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"); + } +#endif + /* Check if we are supposed to be in single user mode */ if ( argc > 1 && (!strcmp(argv[1], "single") || !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) { diff --git a/init/init.c b/init/init.c index a354f8a..e70d5a1 100644 --- a/init/init.c +++ b/init/init.c @@ -430,6 +430,13 @@ extern int init_main(int argc, char **argv) #endif +#ifndef DEBUG_INIT + if (getpid() != 1) { + 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"); + } +#endif + /* Check if we are supposed to be in single user mode */ if ( argc > 1 && (!strcmp(argv[1], "single") || !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) { @@ -138,7 +138,7 @@ 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); +extern void usage(const char *usage) __attribute__ ((noreturn)); extern uid_t my_getpwnam(char *name); extern gid_t my_getgrnam(char *name); @@ -27,9 +27,9 @@ #include <errno.h> -static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n" -"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n" -"\nOptions:\n" +static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n" +"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n" +"Options:\n" "\t-s\tmake symbolic links instead of hard links\n" "\t-f\tremove existing destination files\n"; @@ -26,10 +26,11 @@ #include <errno.h> #include <sys/param.h> -static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n" +static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n\n" "Create the DIRECTORY(ies), if they do not already exist\n\n" -"-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" -"-p\tno error if existing, make parent directories as needed\n"; +"Options:\n" +"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" +"\t-p\tno error if existing, make parent directories as needed\n"; static int parentFlag = FALSE; diff --git a/mkfs_minix.c b/mkfs_minix.c index 926a023..b90d3a7 100644 --- a/mkfs_minix.c +++ b/mkfs_minix.c @@ -171,10 +171,15 @@ static volatile void die(char *str) { static volatile void show_usage() { - fprintf(stderr, "%s\n", program_name); - fprintf(stderr, - "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", - program_name); + fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); + fprintf(stderr, "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n", program_name); + fprintf(stderr, "Make a MINIX filesystem.\n\n"); + fprintf(stderr, "OPTIONS:\n"); + fprintf(stderr, "\t-c\t\tCheck the device for bad blocks\n"); + fprintf(stderr, "\t-n [14|30]\tSpecify the maximum length of filenames\n"); + fprintf(stderr, "\t-i\t\tSpecify the number of inodes for the filesystem\n"); + fprintf(stderr, "\t-l FILENAME\tRead the bad blocks list from FILENAME\n"); + fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n"); exit(16); } @@ -27,9 +27,9 @@ #include <fcntl.h> #include <unistd.h> -static const char mknod_usage[] = "mknod file b|c|u|p major minor\n" -"\tMake special files.\n" -"\n" +static const char mknod_usage[] = "mknod [OPTION]... NAME TYPE MAJOR MINOR\n\n" +"Make block or character special files.\n\n" +"Options:\n" "\tb:\tMake a block (buffered) device.\n" "\tc or u:\tMake a character (un-buffered) device.\n" "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; @@ -47,11 +47,12 @@ /* we also get PAGE_SIZE via getpagesize() */ -static const char mkswap_usage[] = "mkswap [-c] [-v0|-v1] device [block-count]\n" +static const char mkswap_usage[] = "mkswap [-c] [-v0|-v1] device [block-count]\n\n" "Prepare a disk partition to be used as a swap partition.\n\n" -"\t-c\tCheck for read-ability.\n" -"\t-v0\tMake version 0 swap [max 128 Megs].\n" -"\t-v1\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n" +"Options:\n" +"\t-c\t\tCheck for read-ability.\n" +"\t-v0\t\tMake version 0 swap [max 128 Megs].\n" +"\t-v1\t\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n" "\tblock-count\tNumber of block to use (default is entire partition).\n"; @@ -37,7 +37,7 @@ #include <signal.h> #include <sys/ioctl.h> -static const char more_usage[] = "[file ...]"; +static const char more_usage[] = "more [file ...]\n"; /* ED: sparc termios is broken: revert back to old termio handling. */ #ifdef BB_FEATURE_USE_TERMIOS @@ -43,7 +43,7 @@ extern const char mtab_file[]; /* Defined in utility.c */ -static const char mount_usage[] = "Usage:\tmount [flags]\n" +static const char mount_usage[] = "\tmount [flags]\n" "\tmount [flags] device directory [-o options,more-options]\n" "\n" "Flags:\n" @@ -248,8 +248,7 @@ extern int mount_main (int argc, char **argv) while (i>0 && *++(*argv)) switch (**argv) { case 'o': if (--i == 0) { - fprintf (stderr, "%s\n", mount_usage); - exit( FALSE); + goto goodbye; } parse_mount_options (*(++argv), &flags, string_flags); --i; @@ -260,8 +259,7 @@ extern int mount_main (int argc, char **argv) break; case 't': if (--i == 0) { - fprintf (stderr, "%s\n", mount_usage); - exit( FALSE); + goto goodbye; } filesystemType = *(++argv); --i; @@ -284,9 +282,7 @@ extern int mount_main (int argc, char **argv) case 'v': case 'h': case '-': - fprintf (stderr, "%s\n", mount_usage); - exit( TRUE); - break; + goto goodbye; } } else { if (device == NULL) @@ -294,8 +290,7 @@ extern int mount_main (int argc, char **argv) else if (directory == NULL) directory=*argv; else { - fprintf (stderr, "%s\n", mount_usage); - exit( TRUE); + goto goodbye; } } i--; @@ -331,9 +326,11 @@ extern int mount_main (int argc, char **argv) exit (mount_one (device, directory, filesystemType, flags, string_flags, useMtab, fakeIt)); } else { - fprintf (stderr, "%s\n", mount_usage); - exit( FALSE); + goto goodbye; } } exit( TRUE); + +goodbye: + usage( mount_usage); } @@ -29,7 +29,7 @@ static const char mv_usage[] = "mv SOURCE DEST\n" -" or: mv SOURCE... DIRECTORY\n" +" or: mv SOURCE... DIRECTORY\n\n" "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"; diff --git a/procps/ps.c b/procps/ps.c index 55439da..1f61753 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -100,7 +100,7 @@ extern int ps_main(int argc, char **argv) int i, c; if ( argc>1 && **(argv+1) == '-' ) { - usage ("ps - report process status\nThis version of ps accepts no options.\n"); + usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n"); } dir = opendir("/proc"); @@ -100,7 +100,7 @@ extern int ps_main(int argc, char **argv) int i, c; if ( argc>1 && **(argv+1) == '-' ) { - usage ("ps - report process status\nThis version of ps accepts no options.\n"); + usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n"); } dir = opendir("/proc"); @@ -27,8 +27,9 @@ #include <utime.h> #include <dirent.h> -static const char* rm_usage = "rm [OPTION]... FILE...\n" +static const char* rm_usage = "rm [OPTION]... FILE...\n\n" "Remove (unlink) the FILE(s).\n\n" +"Options:\n" "\t-f\tremove existing destinations, never prompt\n" "\t-r\tremove the contents of directories recursively\n"; @@ -29,7 +29,7 @@ extern int rmdir_main(int argc, char **argv) { if ( argc==1 || **(argv+1) == '-' ) { - usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty."); + usage( "rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n"); } while (--argc > 0) { @@ -32,18 +32,18 @@ #include <ctype.h> static const char sed_usage[] = -"sed [-n] [-e script] [file...]\n" -"Allowed scripts come in the following form:\n\n" -"'s/regexp/replacement/[gp]'\n" -"\tattempt to match regexp against the pattern space\n" -"\tand if successful replaces the matched portion with replacement.\n\n" +"sed [-n] [-e script] [file...]\n\n" +"Allowed sed scripts come in the following form:\n" +"\t's/regexp/replacement/[gp]'\n" +"which attempt to match regexp against the pattern space\n" +"and if successful replaces the matched portion with replacement.\n\n" "Options:\n" "-e\tadd the script to the commands to be executed\n" "-n\tsuppress automatic printing of pattern space\n\n" #if defined BB_REGEXP -"This version of sed matches full regexps.\n"; +"This version of sed matches full regular expresions.\n"; #else -"This version of sed matches strings (not full regexps).\n"; +"This version of sed matches strings (not full regular expresions).\n"; #endif @@ -23,8 +23,8 @@ #include "internal.h" #include <stdio.h> -const char sleep_usage[] = " NUMBER\n" -"Pause for NUMBER seconds.\n"; +const char sleep_usage[] = "sleep N\n\n" +"Pause for N seconds.\n"; extern int sleep_main(int argc, char * * argv) @@ -27,7 +27,7 @@ extern int sync_main(int argc, char * * argv) { if ( argc>1 && **(argv+1) == '-' ) { - usage( "sync\nWrite all buffered filesystem blocks to disk.\n"); + usage( "sync\n\nWrite all buffered filesystem blocks to disk.\n"); } exit( sync()); } @@ -35,22 +35,13 @@ #include <signal.h> #include <time.h> -/* Note that tar.c expects TRUE and FALSE to be defined - * exactly the opposite of how they are used everywhere else. - * Some time this should be integrated a bit better, but this - * does the job for now. - */ -//#undef FALSE -//#undef TRUE -//#define FALSE ((int) 0) -//#define TRUE ((int) 1) - static const char tar_usage[] = - "tar -[cxtvOf] [tarFileName] [FILE] ...\n" - "Create, extract, or list files from a tar file\n\n" - "\tc=create, x=extract, t=list contents, v=verbose,\n" - "\tO=extract to stdout, f=tarfile or \"-\" for stdin\n"; +"tar -[cxtvOf] [tarFileName] [FILE] ...\n\n" +"Create, extract, or list files from a tar file\n\n" +"Options:\n" +"\tc=create, x=extract, t=list contents, v=verbose,\n" +"\tO=extract to stdout, f=tarfile or \"-\" for stdin\n"; @@ -96,18 +87,18 @@ typedef struct { /* * Static data. */ -static int listFlag; // -static int extractFlag; // -static int createFlag; // -static int verboseFlag; // -static int tostdoutFlag; // +static int listFlag; +static int extractFlag; +static int createFlag; +static int verboseFlag; +static int tostdoutFlag; static int inHeader; // <- check me -static int badHeader; // -static int errorFlag; // -static int skipFileFlag; // -static int warnedRoot; // -static int eofFlag; // +static int badHeader; +static int errorFlag; +static int skipFileFlag; +static int warnedRoot; +static int eofFlag; static long dataCc; static int outFd; static char outName[TAR_NAME_SIZE]; @@ -136,7 +127,7 @@ static void readHeader (const TarHeader * hp, /* * Local procedures to save files into a tar file. */ -static void saveFile (const char *fileName, int seeLinks); // +static void saveFile (const char *fileName, int seeLinks); static void saveRegularFile (const char *fileName, const struct stat *statbuf); @@ -145,13 +136,13 @@ static void saveDirectory (const char *fileName, const struct stat *statbuf); static int wantFileName (const char *fileName, - int fileCount, char **fileTable); // + int fileCount, char **fileTable); static void writeHeader (const char *fileName, const struct stat *statbuf); static void writeTarFile (int fileCount, char **fileTable); static void writeTarBlock (const char *buf, int len); -static int putOctal (char *cp, int len, long value); // +static int putOctal (char *cp, int len, long value); extern int tar_main (int argc, char **argv) @@ -217,10 +208,13 @@ extern int tar_main (int argc, char **argv) break; case '-': + usage( tar_usage); break; default: - fprintf (stderr, "Unknown tar flag '%c'\n", *options); + fprintf (stderr, "Unknown tar flag '%c'\n" + "Try `tar --help' for more information\n", + *options); exit (FALSE); } @@ -230,7 +224,6 @@ extern int tar_main (int argc, char **argv) /* * Validate the options. */ - fprintf(stderr, "TRUE=%d FALSE=%d\n", TRUE, FALSE); if (extractFlag + listFlag + createFlag != (TRUE+FALSE+FALSE)) { fprintf (stderr, "Exactly one of 'c', 'x' or 't' must be specified\n"); @@ -31,7 +31,7 @@ static const char touch_usage[] = "touch [-c] file [file ...]\n\n" -"\tUpdate the last-modified date on the given file[s].\n"; +"Update the last-modified date on the given file[s].\n"; @@ -54,7 +54,7 @@ touch_main(int argc, char **argv) create = FALSE; break; default: - fprintf(stderr, "Unknown option: %c\n", **argv); + usage( touch_usage); exit( FALSE); } argc--; @@ -29,8 +29,8 @@ #include <errno.h> static const char umount_usage[] = -"Usage: umount [flags] filesystem|directory\n" -"Optional Flags:\n" +"Usage: umount [flags] filesystem|directory\n\n" +"Flags:\n" "\t-a:\tUnmount all file systems" #ifdef BB_MTAB " in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n" @@ -108,7 +108,7 @@ umount_main(int argc, char** argv) } /* Parse any options */ - while (argc-- > 0 && **(argv++) == '-') { + while (--argc > 0 && **(++argv) == '-') { while (*++(*argv)) switch (**argv) { case 'a': umountAll = TRUE; @@ -41,8 +41,9 @@ static const char uname_usage[] = - "uname [OPTION]...\n" - "Print certain system information. With no OPTION, same as -s.\n" + "uname [OPTION]...\n\n" + "Print certain system information. With no OPTION, same as -s.\n\n" + "Options:\n" "\t-a\tprint all information\n" "\t-m\tthe machine (hardware) type\n" "\t-n\tprint the machine's network node hostname\n" diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 1252747..d31de20 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c @@ -191,9 +191,17 @@ static void leave(int status) } static void show_usage(void) { - fprintf(stderr, - "Usage: %s [-larvsmf] /dev/name\n", - program_name); + fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); + fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name); + fprintf(stderr, "Performs a consistency check for MINIX filesystems.\n\n"); + fprintf(stderr, "OPTIONS:\n"); + fprintf(stderr, "\t-l\tLists all filenames\n"); + fprintf(stderr, "\t-r\tPerform interactive repairs\n"); + fprintf(stderr, "\t-a\tPerform automatic repairs\n"); + fprintf(stderr, "\t-v\tverbose\n"); + fprintf(stderr, "\t-s\tOutputs super-block information\n"); + fprintf(stderr, "\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n"); + fprintf(stderr, "\t-f\tForce file system check.\n\n"); leave(16); } diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 926a023..b90d3a7 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -171,10 +171,15 @@ static volatile void die(char *str) { static volatile void show_usage() { - fprintf(stderr, "%s\n", program_name); - fprintf(stderr, - "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", - program_name); + fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); + fprintf(stderr, "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n", program_name); + fprintf(stderr, "Make a MINIX filesystem.\n\n"); + fprintf(stderr, "OPTIONS:\n"); + fprintf(stderr, "\t-c\t\tCheck the device for bad blocks\n"); + fprintf(stderr, "\t-n [14|30]\tSpecify the maximum length of filenames\n"); + fprintf(stderr, "\t-i\t\tSpecify the number of inodes for the filesystem\n"); + fprintf(stderr, "\t-l FILENAME\tRead the bad blocks list from FILENAME\n"); + fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n"); exit(16); } diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index fceeb28..601188f 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c @@ -47,11 +47,12 @@ /* we also get PAGE_SIZE via getpagesize() */ -static const char mkswap_usage[] = "mkswap [-c] [-v0|-v1] device [block-count]\n" +static const char mkswap_usage[] = "mkswap [-c] [-v0|-v1] device [block-count]\n\n" "Prepare a disk partition to be used as a swap partition.\n\n" -"\t-c\tCheck for read-ability.\n" -"\t-v0\tMake version 0 swap [max 128 Megs].\n" -"\t-v1\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n" +"Options:\n" +"\t-c\t\tCheck for read-ability.\n" +"\t-v0\t\tMake version 0 swap [max 128 Megs].\n" +"\t-v1\t\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n" "\tblock-count\tNumber of block to use (default is entire partition).\n"; diff --git a/util-linux/more.c b/util-linux/more.c index 4693161..515857e 100644 --- a/util-linux/more.c +++ b/util-linux/more.c @@ -37,7 +37,7 @@ #include <signal.h> #include <sys/ioctl.h> -static const char more_usage[] = "[file ...]"; +static const char more_usage[] = "more [file ...]\n"; /* ED: sparc termios is broken: revert back to old termio handling. */ #ifdef BB_FEATURE_USE_TERMIOS diff --git a/util-linux/mount.c b/util-linux/mount.c index 4c085d0..827a56f 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -43,7 +43,7 @@ extern const char mtab_file[]; /* Defined in utility.c */ -static const char mount_usage[] = "Usage:\tmount [flags]\n" +static const char mount_usage[] = "\tmount [flags]\n" "\tmount [flags] device directory [-o options,more-options]\n" "\n" "Flags:\n" @@ -248,8 +248,7 @@ extern int mount_main (int argc, char **argv) while (i>0 && *++(*argv)) switch (**argv) { case 'o': if (--i == 0) { - fprintf (stderr, "%s\n", mount_usage); - exit( FALSE); + goto goodbye; } parse_mount_options (*(++argv), &flags, string_flags); --i; @@ -260,8 +259,7 @@ extern int mount_main (int argc, char **argv) break; case 't': if (--i == 0) { - fprintf (stderr, "%s\n", mount_usage); - exit( FALSE); + goto goodbye; } filesystemType = *(++argv); --i; @@ -284,9 +282,7 @@ extern int mount_main (int argc, char **argv) case 'v': case 'h': case '-': - fprintf (stderr, "%s\n", mount_usage); - exit( TRUE); - break; + goto goodbye; } } else { if (device == NULL) @@ -294,8 +290,7 @@ extern int mount_main (int argc, char **argv) else if (directory == NULL) directory=*argv; else { - fprintf (stderr, "%s\n", mount_usage); - exit( TRUE); + goto goodbye; } } i--; @@ -331,9 +326,11 @@ extern int mount_main (int argc, char **argv) exit (mount_one (device, directory, filesystemType, flags, string_flags, useMtab, fakeIt)); } else { - fprintf (stderr, "%s\n", mount_usage); - exit( FALSE); + goto goodbye; } } exit( TRUE); + +goodbye: + usage( mount_usage); } diff --git a/util-linux/umount.c b/util-linux/umount.c index 89c59f9..0d105d9 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -29,8 +29,8 @@ #include <errno.h> static const char umount_usage[] = -"Usage: umount [flags] filesystem|directory\n" -"Optional Flags:\n" +"Usage: umount [flags] filesystem|directory\n\n" +"Flags:\n" "\t-a:\tUnmount all file systems" #ifdef BB_MTAB " in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n" @@ -108,7 +108,7 @@ umount_main(int argc, char** argv) } /* Parse any options */ - while (argc-- > 0 && **(argv++) == '-') { + while (--argc > 0 && **(++argv) == '-') { while (*++(*argv)) switch (**argv) { case 'a': umountAll = TRUE; @@ -46,7 +46,7 @@ const char mtab_file[] = "/proc/mounts"; /* volatile so gcc knows this is the enod of the line */ -volatile void usage(const char *usage) +extern void usage(const char *usage) { fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT); fprintf(stderr, "Usage: %s\n", usage); |