Updates to usage, and made tar work.

-Erik
This commit is contained in:
Eric Andersen
1999-11-10 23:13:02 +00:00
parent 84d8568071
commit d73dc5b073
63 changed files with 290 additions and 230 deletions

View File

@ -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 0.34
* ls -l now displays link names outside the current directory, * ls -l now displays link names outside the current directory,
Patch thanks to Eric Delaunay Patch thanks to Eric Delaunay

View File

@ -220,12 +220,12 @@ int busybox_main(int argc, char **argv)
if (been_there_done_that == 1 || argc < 1) { if (been_there_done_that == 1 || argc < 1) {
const struct Applet *a = applets; 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); BB_VER, BB_BT);
fprintf(stderr, "\nUsage:\t[function] [arguments]...\n"); fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
fprintf(stderr, "\tbusybox [function] [arguments]...\n"); fprintf(stderr, " or: [function] [arguments]...\n\n");
fprintf(stderr, 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"); "\tfunction name, and busybox will act like whatever you invoke it as.\n");
fprintf(stderr, "\nCurrently defined functions:\n"); fprintf(stderr, "\nCurrently defined functions:\n");

View File

@ -35,22 +35,13 @@
#include <signal.h> #include <signal.h>
#include <time.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[] = static const char tar_usage[] =
"tar -[cxtvOf] [tarFileName] [FILE] ...\n" "tar -[cxtvOf] [tarFileName] [FILE] ...\n\n"
"Create, extract, or list files from a tar file\n\n" "Create, extract, or list files from a tar file\n\n"
"\tc=create, x=extract, t=list contents, v=verbose,\n" "Options:\n"
"\tO=extract to stdout, f=tarfile or \"-\" for stdin\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 data.
*/ */
static int listFlag; // static int listFlag;
static int extractFlag; // static int extractFlag;
static int createFlag; // static int createFlag;
static int verboseFlag; // static int verboseFlag;
static int tostdoutFlag; // static int tostdoutFlag;
static int inHeader; // <- check me static int inHeader; // <- check me
static int badHeader; // static int badHeader;
static int errorFlag; // static int errorFlag;
static int skipFileFlag; // static int skipFileFlag;
static int warnedRoot; // static int warnedRoot;
static int eofFlag; // static int eofFlag;
static long dataCc; static long dataCc;
static int outFd; static int outFd;
static char outName[TAR_NAME_SIZE]; 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. * 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, static void saveRegularFile (const char *fileName,
const struct stat *statbuf); const struct stat *statbuf);
@ -145,13 +136,13 @@ static void saveDirectory (const char *fileName,
const struct stat *statbuf); const struct stat *statbuf);
static int wantFileName (const char *fileName, 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 writeHeader (const char *fileName, const struct stat *statbuf);
static void writeTarFile (int fileCount, char **fileTable); static void writeTarFile (int fileCount, char **fileTable);
static void writeTarBlock (const char *buf, int len); 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) extern int tar_main (int argc, char **argv)
@ -217,10 +208,13 @@ extern int tar_main (int argc, char **argv)
break; break;
case '-': case '-':
usage( tar_usage);
break; break;
default: 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); exit (FALSE);
} }
@ -230,7 +224,6 @@ extern int tar_main (int argc, char **argv)
/* /*
* Validate the options. * Validate the options.
*/ */
fprintf(stderr, "TRUE=%d FALSE=%d\n", TRUE, FALSE);
if (extractFlag + listFlag + createFlag != (TRUE+FALSE+FALSE)) { if (extractFlag + listFlag + createFlag != (TRUE+FALSE+FALSE)) {
fprintf (stderr, fprintf (stderr,
"Exactly one of 'c', 'x' or 't' must be specified\n"); "Exactly one of 'c', 'x' or 't' must be specified\n");

View File

@ -220,12 +220,12 @@ int busybox_main(int argc, char **argv)
if (been_there_done_that == 1 || argc < 1) { if (been_there_done_that == 1 || argc < 1) {
const struct Applet *a = applets; 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); BB_VER, BB_BT);
fprintf(stderr, "\nUsage:\t[function] [arguments]...\n"); fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
fprintf(stderr, "\tbusybox [function] [arguments]...\n"); fprintf(stderr, " or: [function] [arguments]...\n\n");
fprintf(stderr, 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"); "\tfunction name, and busybox will act like whatever you invoke it as.\n");
fprintf(stderr, "\nCurrently defined functions:\n"); fprintf(stderr, "\nCurrently defined functions:\n");

View File

@ -2,6 +2,7 @@
* This file is parsed by sed. You MUST use single line comments. * This file is parsed by sed. You MUST use single line comments.
* IE //#define BB_BLAH * IE //#define BB_BLAH
*/ */
#define BB_BUSYBOX #define BB_BUSYBOX
#define BB_CAT #define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP #define BB_CHMOD_CHOWN_CHGRP
@ -12,48 +13,48 @@
#define BB_DD #define BB_DD
#define BB_DF #define BB_DF
#define BB_DMESG #define BB_DMESG
#define BB_DUTMP //#define BB_DUTMP
#define BB_FDFLUSH //#define BB_FDFLUSH
#define BB_FIND #define BB_FIND
#define BB_FSCK_MINIX #define BB_FSCK_MINIX
#define BB_MKFS_MINIX #define BB_MKFS_MINIX
#define BB_CHVT #define BB_CHVT
#define BB_DEALLOCVT #define BB_DEALLOCVT
#define BB_GREP #define BB_GREP
#define BB_HALT //#define BB_HALT
#define BB_INIT #define BB_INIT
#define BB_KILL #define BB_KILL
#define BB_LENGTH //#define BB_LENGTH
#define BB_LN #define BB_LN
#define BB_LOADFONT #define BB_LOADFONT
#define BB_LOADKMAP #define BB_LOADKMAP
#define BB_LS #define BB_LS
#define BB_MAKEDEVS //#define BB_MAKEDEVS
#define BB_MATH //#define BB_MATH
#define BB_MKDIR #define BB_MKDIR
#define BB_MKNOD #define BB_MKNOD
#define BB_MKSWAP #define BB_MKSWAP
#define BB_MNC //#define BB_MNC
#define BB_MORE #define BB_MORE
#define BB_MOUNT #define BB_MOUNT
#define BB_MT //#define BB_MT
#define BB_MTAB //#define BB_MTAB
#define BB_MV #define BB_MV
#define BB_PRINTF //#define BB_PRINTF
#define BB_PS #define BB_PS
#define BB_PWD #define BB_PWD
#define BB_REGEXP #define BB_REGEXP
#define BB_REBOOT #define BB_REBOOT
#define BB_RM #define BB_RM
#define BB_RMDIR #define BB_RMDIR
#define BB_SFDISK //#define BB_SFDISK
#define BB_SED #define BB_SED
#define BB_SLEEP #define BB_SLEEP
#define BB_SWAPONOFF #define BB_SWAPONOFF
#define BB_SYNC #define BB_SYNC
#define BB_TAR #define BB_TAR
#define BB_TOUCH #define BB_TOUCH
#define BB_TRUE_FALSE //#define BB_TRUE_FALSE // Supplied by ash
#define BB_UMOUNT #define BB_UMOUNT
#define BB_UPDATE #define BB_UPDATE
#define BB_UNAME #define BB_UNAME

View File

@ -38,16 +38,16 @@ static mode_t mode=0644;
#define CHOWN_APP 2 #define CHOWN_APP 2
#define CHMOD_APP 3 #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" "Change the group membership of each FILE to GROUP.\n"
"\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; "\nOptions:\n\t-R\tchange files and directories recursively\n";
static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\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" "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"; "\nOptions:\n\t-R\tchange files and directories recursively\n";
static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\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" "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" "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) 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; int recursiveFlag=FALSE;
char *groupName; char *groupName;
const char *appUsage;
whichApp = (strcmp(*argv, "chown")==0)? CHOWN_APP : (strcmp(*argv, "chmod")==0)? CHMOD_APP : CHGRP_APP; whichApp = (strcmp(*argv, "chown")==0)? CHOWN_APP : (strcmp(*argv, "chmod")==0)? CHMOD_APP : CHGRP_APP;
if (argc < 2) { appUsage = (whichApp==CHOWN_APP)? chown_usage : (whichApp==CHMOD_APP)? chmod_usage : chgrp_usage;
fprintf(stderr, "Usage: %s %s", *argv,
(whichApp==TRUE)? chown_usage : chgrp_usage); if (argc < 2)
exit( FALSE); usage( appUsage);
}
invocationName=*argv; invocationName=*argv;
argc--; argc--;
argv++; argv++;
@ -93,7 +93,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
break; break;
default: default:
fprintf(stderr, "Unknown option: %c\n", **argv); fprintf(stderr, "Unknown option: %c\n", **argv);
exit( FALSE); usage( appUsage);
} }
argc--; argc--;
argv++; argv++;

View File

@ -27,7 +27,7 @@
#include <errno.h> #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"; "Run COMMAND with root directory set to NEWROOT.\n";

2
chvt.c
View File

@ -19,7 +19,7 @@ chvt_main(int argc, char** argv)
int fd, num; int fd, num;
if ( ( argc != 2) || (**(argv+1) == '-' ) ) { 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"); fd = get_console_fd("/dev/console");
num = atoi(argv[1]); num = atoi(argv[1]);

View File

@ -19,7 +19,7 @@ chvt_main(int argc, char** argv)
int fd, num; int fd, num;
if ( ( argc != 2) || (**(argv+1) == '-' ) ) { 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"); fd = get_console_fd("/dev/console");
num = atoi(argv[1]); num = atoi(argv[1]);

View File

@ -17,8 +17,10 @@ int
deallocvt_main(int argc, char *argv[]) { deallocvt_main(int argc, char *argv[]) {
int fd, num, i; int fd, num, i;
if (argc < 1) /* unlikely */ if ( ( argc != 2) || (**(argv+1) == '-' ) ) {
exit(1); usage ("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n");
}
progname = argv[0]; progname = argv[0];
fd = get_console_fd("/dev/console"); fd = get_console_fd("/dev/console");

View File

@ -27,7 +27,7 @@
#include <errno.h> #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"; "Run COMMAND with root directory set to NEWROOT.\n";

View File

@ -28,7 +28,7 @@
#include <dirent.h> #include <dirent.h>
static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n" 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" "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
"\n" "\n"
"\t-a\tsame as -dpR\n" "\t-a\tsame as -dpR\n"

View File

@ -35,7 +35,7 @@
mail commands */ mail commands */
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" 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" "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" "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
"\t-s\t\tset time described by STRING\n" "\t-s\t\tset time described by STRING\n"

View File

@ -34,7 +34,7 @@
#include <errno.h> #include <errno.h>
static const char dd_usage[] = 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" "Copy a file, converting and formatting according to options\n\n"
"\tif=FILE\tread from FILE instead of stdin\n" "\tif=FILE\tread from FILE instead of stdin\n"
"\tof=FILE\twrite to FILE instead of stout\n" "\tof=FILE\twrite to FILE instead of stout\n"
@ -227,8 +227,7 @@ extern int dd_main (int argc, char **argv)
exit( TRUE); exit( TRUE);
usage: usage:
fprintf (stderr, "%s", dd_usage); usage( dd_usage);
exit( FALSE);
} }

View File

@ -27,9 +27,9 @@
#include <errno.h> #include <errno.h>
static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\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" "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"\nOptions:\n" "Options:\n"
"\t-s\tmake symbolic links instead of hard links\n" "\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"; "\t-f\tremove existing destination files\n";

View File

@ -26,10 +26,11 @@
#include <errno.h> #include <errno.h>
#include <sys/param.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" "Create the DIRECTORY(ies), if they do not already exist\n\n"
"-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" "Options:\n"
"-p\tno error if existing, make parent directories as needed\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; static int parentFlag = FALSE;

View File

@ -27,9 +27,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
static const char mknod_usage[] = "mknod file b|c|u|p major minor\n" static const char mknod_usage[] = "mknod [OPTION]... NAME TYPE MAJOR MINOR\n\n"
"\tMake special files.\n" "Make block or character special files.\n\n"
"\n" "Options:\n"
"\tb:\tMake a block (buffered) device.\n" "\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-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"; "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";

View File

@ -29,7 +29,7 @@
static const char mv_usage[] = "mv SOURCE DEST\n" 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"; "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n";

View File

@ -27,8 +27,9 @@
#include <utime.h> #include <utime.h>
#include <dirent.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" "Remove (unlink) the FILE(s).\n\n"
"Options:\n"
"\t-f\tremove existing destinations, never prompt\n" "\t-f\tremove existing destinations, never prompt\n"
"\t-r\tremove the contents of directories recursively\n"; "\t-r\tremove the contents of directories recursively\n";

View File

@ -29,7 +29,7 @@
extern int rmdir_main(int argc, char **argv) extern int rmdir_main(int argc, char **argv)
{ {
if ( argc==1 || **(argv+1) == '-' ) { 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) { while (--argc > 0) {

View File

@ -23,8 +23,8 @@
#include "internal.h" #include "internal.h"
#include <stdio.h> #include <stdio.h>
const char sleep_usage[] = " NUMBER\n" const char sleep_usage[] = "sleep N\n\n"
"Pause for NUMBER seconds.\n"; "Pause for N seconds.\n";
extern int extern int
sleep_main(int argc, char * * argv) sleep_main(int argc, char * * argv)

View File

@ -27,7 +27,7 @@ extern int
sync_main(int argc, char * * argv) sync_main(int argc, char * * argv)
{ {
if ( argc>1 && **(argv+1) == '-' ) { 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()); exit( sync());
} }

View File

@ -31,7 +31,7 @@
static const char touch_usage[] = "touch [-c] file [file ...]\n\n" 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; create = FALSE;
break; break;
default: default:
fprintf(stderr, "Unknown option: %c\n", **argv); usage( touch_usage);
exit( FALSE); exit( FALSE);
} }
argc--; argc--;

View File

@ -41,8 +41,9 @@
static const char uname_usage[] = static const char uname_usage[] =
"uname [OPTION]...\n" "uname [OPTION]...\n\n"
"Print certain system information. With no OPTION, same as -s.\n" "Print certain system information. With no OPTION, same as -s.\n\n"
"Options:\n"
"\t-a\tprint all information\n" "\t-a\tprint all information\n"
"\t-m\tthe machine (hardware) type\n" "\t-m\tthe machine (hardware) type\n"
"\t-n\tprint the machine's network node hostname\n" "\t-n\tprint the machine's network node hostname\n"

2
cp.c
View File

@ -28,7 +28,7 @@
#include <dirent.h> #include <dirent.h>
static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n" 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" "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
"\n" "\n"
"\t-a\tsame as -dpR\n" "\t-a\tsame as -dpR\n"

2
date.c
View File

@ -35,7 +35,7 @@
mail commands */ mail commands */
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" 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" "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" "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
"\t-s\t\tset time described by STRING\n" "\t-s\t\tset time described by STRING\n"

5
dd.c
View File

@ -34,7 +34,7 @@
#include <errno.h> #include <errno.h>
static const char dd_usage[] = 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" "Copy a file, converting and formatting according to options\n\n"
"\tif=FILE\tread from FILE instead of stdin\n" "\tif=FILE\tread from FILE instead of stdin\n"
"\tof=FILE\twrite to FILE instead of stout\n" "\tof=FILE\twrite to FILE instead of stout\n"
@ -227,8 +227,7 @@ extern int dd_main (int argc, char **argv)
exit( TRUE); exit( TRUE);
usage: usage:
fprintf (stderr, "%s", dd_usage); usage( dd_usage);
exit( FALSE);
} }

View File

@ -17,8 +17,10 @@ int
deallocvt_main(int argc, char *argv[]) { deallocvt_main(int argc, char *argv[]) {
int fd, num, i; int fd, num, i;
if (argc < 1) /* unlikely */ if ( ( argc != 2) || (**(argv+1) == '-' ) ) {
exit(1); usage ("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n");
}
progname = argv[0]; progname = argv[0];
fd = get_console_fd("/dev/console"); fd = get_console_fd("/dev/console");

View File

@ -32,18 +32,18 @@
#include <ctype.h> #include <ctype.h>
static const char sed_usage[] = static const char sed_usage[] =
"sed [-n] [-e script] [file...]\n" "sed [-n] [-e script] [file...]\n\n"
"Allowed scripts come in the following form:\n\n" "Allowed sed scripts come in the following form:\n"
"'s/regexp/replacement/[gp]'\n" "\t's/regexp/replacement/[gp]'\n"
"\tattempt to match regexp against the pattern space\n" "which attempt to match regexp against the pattern space\n"
"\tand if successful replaces the matched portion with replacement.\n\n" "and if successful replaces the matched portion with replacement.\n\n"
"Options:\n" "Options:\n"
"-e\tadd the script to the commands to be executed\n" "-e\tadd the script to the commands to be executed\n"
"-n\tsuppress automatic printing of pattern space\n\n" "-n\tsuppress automatic printing of pattern space\n\n"
#if defined BB_REGEXP #if defined BB_REGEXP
"This version of sed matches full regexps.\n"; "This version of sed matches full regular expresions.\n";
#else #else
"This version of sed matches strings (not full regexps).\n"; "This version of sed matches strings (not full regular expresions).\n";
#endif #endif

15
find.c
View File

@ -32,9 +32,18 @@ static char* pattern=NULL;
static char* directory="."; static char* directory=".";
static int dereferenceFlag=FALSE; static int dereferenceFlag=FALSE;
static const char find_usage[] = "find [path...] [expression]\n" static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n"
"default path is the current directory; default expression is -print\n" "Search for files in a directory hierarchy. The default PATH is\n"
"expression may consist of:\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

View File

@ -32,9 +32,18 @@ static char* pattern=NULL;
static char* directory="."; static char* directory=".";
static int dereferenceFlag=FALSE; static int dereferenceFlag=FALSE;
static const char find_usage[] = "find [path...] [expression]\n" static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n"
"default path is the current directory; default expression is -print\n" "Search for files in a directory hierarchy. The default PATH is\n"
"expression may consist of:\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

View File

@ -32,15 +32,16 @@
#include <ctype.h> #include <ctype.h>
static const char grep_usage[] = 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" "Search for PATTERN in each FILE or standard input.\n\n"
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n" "\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n" "\t-i\tignore case distinctions\n"
"\t-n\tprint line number with output lines\n\n" "\t-n\tprint line number with output lines\n\n"
#if defined BB_REGEXP #if defined BB_REGEXP
"This version of grep matches full regexps.\n"; "This version of grep matches full regular expresions.\n";
#else #else
"This version of grep matches strings (not regexps).\n"; "This version of grep matches strings (not regular expresions).\n";
#endif #endif

View File

@ -191,9 +191,17 @@ static void leave(int status)
} }
static void show_usage(void) { static void show_usage(void) {
fprintf(stderr, fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT);
"Usage: %s [-larvsmf] /dev/name\n", fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name);
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); leave(16);
} }

7
grep.c
View File

@ -32,15 +32,16 @@
#include <ctype.h> #include <ctype.h>
static const char grep_usage[] = 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" "Search for PATTERN in each FILE or standard input.\n\n"
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n" "\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n" "\t-i\tignore case distinctions\n"
"\t-n\tprint line number with output lines\n\n" "\t-n\tprint line number with output lines\n\n"
#if defined BB_REGEXP #if defined BB_REGEXP
"This version of grep matches full regexps.\n"; "This version of grep matches full regular expresions.\n";
#else #else
"This version of grep matches strings (not regexps).\n"; "This version of grep matches strings (not regular expresions).\n";
#endif #endif

7
init.c
View File

@ -430,6 +430,13 @@ extern int init_main(int argc, char **argv)
#endif #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 */ /* Check if we are supposed to be in single user mode */
if ( argc > 1 && (!strcmp(argv[1], "single") || if ( argc > 1 && (!strcmp(argv[1], "single") ||
!strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) { !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {

View File

@ -430,6 +430,13 @@ extern int init_main(int argc, char **argv)
#endif #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 */ /* Check if we are supposed to be in single user mode */
if ( argc > 1 && (!strcmp(argv[1], "single") || if ( argc > 1 && (!strcmp(argv[1], "single") ||
!strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) { !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {

View File

@ -138,7 +138,7 @@ const char* timeString(time_t timeVal);
extern void createPath (const char *name, int mode); extern void createPath (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode); 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 uid_t my_getpwnam(char *name);
extern gid_t my_getgrnam(char *name); extern gid_t my_getgrnam(char *name);

6
ln.c
View File

@ -27,9 +27,9 @@
#include <errno.h> #include <errno.h>
static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\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" "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"\nOptions:\n" "Options:\n"
"\t-s\tmake symbolic links instead of hard links\n" "\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"; "\t-f\tremove existing destination files\n";

View File

@ -26,10 +26,11 @@
#include <errno.h> #include <errno.h>
#include <sys/param.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" "Create the DIRECTORY(ies), if they do not already exist\n\n"
"-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" "Options:\n"
"-p\tno error if existing, make parent directories as needed\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; static int parentFlag = FALSE;

View File

@ -171,10 +171,15 @@ static volatile void die(char *str) {
static volatile void show_usage() static volatile void show_usage()
{ {
fprintf(stderr, "%s\n", program_name); fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT);
fprintf(stderr, fprintf(stderr, "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n", program_name);
"Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", fprintf(stderr, "Make a MINIX filesystem.\n\n");
program_name); 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); exit(16);
} }

View File

@ -27,9 +27,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
static const char mknod_usage[] = "mknod file b|c|u|p major minor\n" static const char mknod_usage[] = "mknod [OPTION]... NAME TYPE MAJOR MINOR\n\n"
"\tMake special files.\n" "Make block or character special files.\n\n"
"\n" "Options:\n"
"\tb:\tMake a block (buffered) device.\n" "\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-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"; "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";

View File

@ -47,11 +47,12 @@
/* we also get PAGE_SIZE via getpagesize() */ /* 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" "Prepare a disk partition to be used as a swap partition.\n\n"
"\t-c\tCheck for read-ability.\n" "Options:\n"
"\t-v0\tMake version 0 swap [max 128 Megs].\n" "\t-c\t\tCheck for read-ability.\n"
"\t-v1\tMake version 1 swap [big!] (default for kernels > 2.1.117).\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"; "\tblock-count\tNumber of block to use (default is entire partition).\n";

2
more.c
View File

@ -37,7 +37,7 @@
#include <signal.h> #include <signal.h>
#include <sys/ioctl.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. */ /* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS #ifdef BB_FEATURE_USE_TERMIOS

21
mount.c
View File

@ -43,7 +43,7 @@
extern const char mtab_file[]; /* Defined in utility.c */ 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" "\tmount [flags] device directory [-o options,more-options]\n"
"\n" "\n"
"Flags:\n" "Flags:\n"
@ -248,8 +248,7 @@ extern int mount_main (int argc, char **argv)
while (i>0 && *++(*argv)) switch (**argv) { while (i>0 && *++(*argv)) switch (**argv) {
case 'o': case 'o':
if (--i == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( FALSE);
} }
parse_mount_options (*(++argv), &flags, string_flags); parse_mount_options (*(++argv), &flags, string_flags);
--i; --i;
@ -260,8 +259,7 @@ extern int mount_main (int argc, char **argv)
break; break;
case 't': case 't':
if (--i == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( FALSE);
} }
filesystemType = *(++argv); filesystemType = *(++argv);
--i; --i;
@ -284,9 +282,7 @@ extern int mount_main (int argc, char **argv)
case 'v': case 'v':
case 'h': case 'h':
case '-': case '-':
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( TRUE);
break;
} }
} else { } else {
if (device == NULL) if (device == NULL)
@ -294,8 +290,7 @@ extern int mount_main (int argc, char **argv)
else if (directory == NULL) else if (directory == NULL)
directory=*argv; directory=*argv;
else { else {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( TRUE);
} }
} }
i--; i--;
@ -331,9 +326,11 @@ extern int mount_main (int argc, char **argv)
exit (mount_one (device, directory, filesystemType, exit (mount_one (device, directory, filesystemType,
flags, string_flags, useMtab, fakeIt)); flags, string_flags, useMtab, fakeIt));
} else { } else {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( FALSE);
} }
} }
exit( TRUE); exit( TRUE);
goodbye:
usage( mount_usage);
} }

2
mv.c
View File

@ -29,7 +29,7 @@
static const char mv_usage[] = "mv SOURCE DEST\n" 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"; "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n";

View File

@ -100,7 +100,7 @@ extern int ps_main(int argc, char **argv)
int i, c; int i, c;
if ( argc>1 && **(argv+1) == '-' ) { 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"); dir = opendir("/proc");

2
ps.c
View File

@ -100,7 +100,7 @@ extern int ps_main(int argc, char **argv)
int i, c; int i, c;
if ( argc>1 && **(argv+1) == '-' ) { 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"); dir = opendir("/proc");

3
rm.c
View File

@ -27,8 +27,9 @@
#include <utime.h> #include <utime.h>
#include <dirent.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" "Remove (unlink) the FILE(s).\n\n"
"Options:\n"
"\t-f\tremove existing destinations, never prompt\n" "\t-f\tremove existing destinations, never prompt\n"
"\t-r\tremove the contents of directories recursively\n"; "\t-r\tremove the contents of directories recursively\n";

View File

@ -29,7 +29,7 @@
extern int rmdir_main(int argc, char **argv) extern int rmdir_main(int argc, char **argv)
{ {
if ( argc==1 || **(argv+1) == '-' ) { 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) { while (--argc > 0) {

14
sed.c
View File

@ -32,18 +32,18 @@
#include <ctype.h> #include <ctype.h>
static const char sed_usage[] = static const char sed_usage[] =
"sed [-n] [-e script] [file...]\n" "sed [-n] [-e script] [file...]\n\n"
"Allowed scripts come in the following form:\n\n" "Allowed sed scripts come in the following form:\n"
"'s/regexp/replacement/[gp]'\n" "\t's/regexp/replacement/[gp]'\n"
"\tattempt to match regexp against the pattern space\n" "which attempt to match regexp against the pattern space\n"
"\tand if successful replaces the matched portion with replacement.\n\n" "and if successful replaces the matched portion with replacement.\n\n"
"Options:\n" "Options:\n"
"-e\tadd the script to the commands to be executed\n" "-e\tadd the script to the commands to be executed\n"
"-n\tsuppress automatic printing of pattern space\n\n" "-n\tsuppress automatic printing of pattern space\n\n"
#if defined BB_REGEXP #if defined BB_REGEXP
"This version of sed matches full regexps.\n"; "This version of sed matches full regular expresions.\n";
#else #else
"This version of sed matches strings (not full regexps).\n"; "This version of sed matches strings (not full regular expresions).\n";
#endif #endif

View File

@ -23,8 +23,8 @@
#include "internal.h" #include "internal.h"
#include <stdio.h> #include <stdio.h>
const char sleep_usage[] = " NUMBER\n" const char sleep_usage[] = "sleep N\n\n"
"Pause for NUMBER seconds.\n"; "Pause for N seconds.\n";
extern int extern int
sleep_main(int argc, char * * argv) sleep_main(int argc, char * * argv)

2
sync.c
View File

@ -27,7 +27,7 @@ extern int
sync_main(int argc, char * * argv) sync_main(int argc, char * * argv)
{ {
if ( argc>1 && **(argv+1) == '-' ) { 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()); exit( sync());
} }

51
tar.c
View File

@ -35,22 +35,13 @@
#include <signal.h> #include <signal.h>
#include <time.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[] = static const char tar_usage[] =
"tar -[cxtvOf] [tarFileName] [FILE] ...\n" "tar -[cxtvOf] [tarFileName] [FILE] ...\n\n"
"Create, extract, or list files from a tar file\n\n" "Create, extract, or list files from a tar file\n\n"
"\tc=create, x=extract, t=list contents, v=verbose,\n" "Options:\n"
"\tO=extract to stdout, f=tarfile or \"-\" for stdin\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 data.
*/ */
static int listFlag; // static int listFlag;
static int extractFlag; // static int extractFlag;
static int createFlag; // static int createFlag;
static int verboseFlag; // static int verboseFlag;
static int tostdoutFlag; // static int tostdoutFlag;
static int inHeader; // <- check me static int inHeader; // <- check me
static int badHeader; // static int badHeader;
static int errorFlag; // static int errorFlag;
static int skipFileFlag; // static int skipFileFlag;
static int warnedRoot; // static int warnedRoot;
static int eofFlag; // static int eofFlag;
static long dataCc; static long dataCc;
static int outFd; static int outFd;
static char outName[TAR_NAME_SIZE]; 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. * 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, static void saveRegularFile (const char *fileName,
const struct stat *statbuf); const struct stat *statbuf);
@ -145,13 +136,13 @@ static void saveDirectory (const char *fileName,
const struct stat *statbuf); const struct stat *statbuf);
static int wantFileName (const char *fileName, 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 writeHeader (const char *fileName, const struct stat *statbuf);
static void writeTarFile (int fileCount, char **fileTable); static void writeTarFile (int fileCount, char **fileTable);
static void writeTarBlock (const char *buf, int len); 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) extern int tar_main (int argc, char **argv)
@ -217,10 +208,13 @@ extern int tar_main (int argc, char **argv)
break; break;
case '-': case '-':
usage( tar_usage);
break; break;
default: 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); exit (FALSE);
} }
@ -230,7 +224,6 @@ extern int tar_main (int argc, char **argv)
/* /*
* Validate the options. * Validate the options.
*/ */
fprintf(stderr, "TRUE=%d FALSE=%d\n", TRUE, FALSE);
if (extractFlag + listFlag + createFlag != (TRUE+FALSE+FALSE)) { if (extractFlag + listFlag + createFlag != (TRUE+FALSE+FALSE)) {
fprintf (stderr, fprintf (stderr,
"Exactly one of 'c', 'x' or 't' must be specified\n"); "Exactly one of 'c', 'x' or 't' must be specified\n");

View File

@ -31,7 +31,7 @@
static const char touch_usage[] = "touch [-c] file [file ...]\n\n" 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; create = FALSE;
break; break;
default: default:
fprintf(stderr, "Unknown option: %c\n", **argv); usage( touch_usage);
exit( FALSE); exit( FALSE);
} }
argc--; argc--;

View File

@ -29,8 +29,8 @@
#include <errno.h> #include <errno.h>
static const char umount_usage[] = static const char umount_usage[] =
"Usage: umount [flags] filesystem|directory\n" "Usage: umount [flags] filesystem|directory\n\n"
"Optional Flags:\n" "Flags:\n"
"\t-a:\tUnmount all file systems" "\t-a:\tUnmount all file systems"
#ifdef BB_MTAB #ifdef BB_MTAB
" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n" " 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 */ /* Parse any options */
while (argc-- > 0 && **(argv++) == '-') { while (--argc > 0 && **(++argv) == '-') {
while (*++(*argv)) switch (**argv) { while (*++(*argv)) switch (**argv) {
case 'a': case 'a':
umountAll = TRUE; umountAll = TRUE;

View File

@ -41,8 +41,9 @@
static const char uname_usage[] = static const char uname_usage[] =
"uname [OPTION]...\n" "uname [OPTION]...\n\n"
"Print certain system information. With no OPTION, same as -s.\n" "Print certain system information. With no OPTION, same as -s.\n\n"
"Options:\n"
"\t-a\tprint all information\n" "\t-a\tprint all information\n"
"\t-m\tthe machine (hardware) type\n" "\t-m\tthe machine (hardware) type\n"
"\t-n\tprint the machine's network node hostname\n" "\t-n\tprint the machine's network node hostname\n"

View File

@ -191,9 +191,17 @@ static void leave(int status)
} }
static void show_usage(void) { static void show_usage(void) {
fprintf(stderr, fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT);
"Usage: %s [-larvsmf] /dev/name\n", fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name);
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); leave(16);
} }

View File

@ -171,10 +171,15 @@ static volatile void die(char *str) {
static volatile void show_usage() static volatile void show_usage()
{ {
fprintf(stderr, "%s\n", program_name); fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT);
fprintf(stderr, fprintf(stderr, "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n", program_name);
"Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", fprintf(stderr, "Make a MINIX filesystem.\n\n");
program_name); 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); exit(16);
} }

View File

@ -47,11 +47,12 @@
/* we also get PAGE_SIZE via getpagesize() */ /* 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" "Prepare a disk partition to be used as a swap partition.\n\n"
"\t-c\tCheck for read-ability.\n" "Options:\n"
"\t-v0\tMake version 0 swap [max 128 Megs].\n" "\t-c\t\tCheck for read-ability.\n"
"\t-v1\tMake version 1 swap [big!] (default for kernels > 2.1.117).\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"; "\tblock-count\tNumber of block to use (default is entire partition).\n";

View File

@ -37,7 +37,7 @@
#include <signal.h> #include <signal.h>
#include <sys/ioctl.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. */ /* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS #ifdef BB_FEATURE_USE_TERMIOS

View File

@ -43,7 +43,7 @@
extern const char mtab_file[]; /* Defined in utility.c */ 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" "\tmount [flags] device directory [-o options,more-options]\n"
"\n" "\n"
"Flags:\n" "Flags:\n"
@ -248,8 +248,7 @@ extern int mount_main (int argc, char **argv)
while (i>0 && *++(*argv)) switch (**argv) { while (i>0 && *++(*argv)) switch (**argv) {
case 'o': case 'o':
if (--i == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( FALSE);
} }
parse_mount_options (*(++argv), &flags, string_flags); parse_mount_options (*(++argv), &flags, string_flags);
--i; --i;
@ -260,8 +259,7 @@ extern int mount_main (int argc, char **argv)
break; break;
case 't': case 't':
if (--i == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( FALSE);
} }
filesystemType = *(++argv); filesystemType = *(++argv);
--i; --i;
@ -284,9 +282,7 @@ extern int mount_main (int argc, char **argv)
case 'v': case 'v':
case 'h': case 'h':
case '-': case '-':
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( TRUE);
break;
} }
} else { } else {
if (device == NULL) if (device == NULL)
@ -294,8 +290,7 @@ extern int mount_main (int argc, char **argv)
else if (directory == NULL) else if (directory == NULL)
directory=*argv; directory=*argv;
else { else {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( TRUE);
} }
} }
i--; i--;
@ -331,9 +326,11 @@ extern int mount_main (int argc, char **argv)
exit (mount_one (device, directory, filesystemType, exit (mount_one (device, directory, filesystemType,
flags, string_flags, useMtab, fakeIt)); flags, string_flags, useMtab, fakeIt));
} else { } else {
fprintf (stderr, "%s\n", mount_usage); goto goodbye;
exit( FALSE);
} }
} }
exit( TRUE); exit( TRUE);
goodbye:
usage( mount_usage);
} }

View File

@ -29,8 +29,8 @@
#include <errno.h> #include <errno.h>
static const char umount_usage[] = static const char umount_usage[] =
"Usage: umount [flags] filesystem|directory\n" "Usage: umount [flags] filesystem|directory\n\n"
"Optional Flags:\n" "Flags:\n"
"\t-a:\tUnmount all file systems" "\t-a:\tUnmount all file systems"
#ifdef BB_MTAB #ifdef BB_MTAB
" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n" " 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 */ /* Parse any options */
while (argc-- > 0 && **(argv++) == '-') { while (--argc > 0 && **(++argv) == '-') {
while (*++(*argv)) switch (**argv) { while (*++(*argv)) switch (**argv) {
case 'a': case 'a':
umountAll = TRUE; umountAll = TRUE;

View File

@ -46,7 +46,7 @@ const char mtab_file[] = "/proc/mounts";
/* volatile so gcc knows this is the enod of the line */ /* 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, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", BB_VER, BB_BT);
fprintf(stderr, "Usage: %s\n", usage); fprintf(stderr, "Usage: %s\n", usage);