+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
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");
#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";
/*
* 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];
/*
* 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);
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)
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);
}
/*
* 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");
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");
* 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
#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
#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)
{
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++;
break;
default:
fprintf(stderr, "Unknown option: %c\n", **argv);
- exit( FALSE);
+ usage( appUsage);
}
argc--;
argv++;
#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";
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]);
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]);
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");
#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";
#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"
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"
#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"
exit( TRUE);
usage:
- fprintf (stderr, "%s", dd_usage);
- exit( FALSE);
+ usage( dd_usage);
}
#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";
#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;
#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";
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";
#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";
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) {
#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)
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());
}
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";
create = FALSE;
break;
default:
- fprintf(stderr, "Unknown option: %c\n", **argv);
+ usage( touch_usage);
exit( FALSE);
}
argc--;
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"
#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"
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"
#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"
exit( TRUE);
usage:
- fprintf (stderr, "%s", dd_usage);
- exit( FALSE);
+ usage( dd_usage);
}
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");
#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
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
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
#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
}
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);
}
#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
#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"))) {
#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"))) {
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);
#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";
#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;
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);
}
#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";
/* 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";
#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
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"
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;
break;
case 't':
if (--i == 0) {
- fprintf (stderr, "%s\n", mount_usage);
- exit( FALSE);
+ goto goodbye;
}
filesystemType = *(++argv);
--i;
case 'v':
case 'h':
case '-':
- fprintf (stderr, "%s\n", mount_usage);
- exit( TRUE);
- break;
+ goto goodbye;
}
} else {
if (device == NULL)
else if (directory == NULL)
directory=*argv;
else {
- fprintf (stderr, "%s\n", mount_usage);
- exit( TRUE);
+ goto goodbye;
}
}
i--;
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);
}
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";
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");
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");
#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";
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) {
#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
#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)
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());
}
#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";
/*
* 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];
/*
* 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);
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)
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);
}
/*
* 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");
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";
create = FALSE;
break;
default:
- fprintf(stderr, "Unknown option: %c\n", **argv);
+ usage( touch_usage);
exit( FALSE);
}
argc--;
#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"
}
/* Parse any options */
- while (argc-- > 0 && **(argv++) == '-') {
+ while (--argc > 0 && **(++argv) == '-') {
while (*++(*argv)) switch (**argv) {
case 'a':
umountAll = TRUE;
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"
}
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);
}
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);
}
/* 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";
#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
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"
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;
break;
case 't':
if (--i == 0) {
- fprintf (stderr, "%s\n", mount_usage);
- exit( FALSE);
+ goto goodbye;
}
filesystemType = *(++argv);
--i;
case 'v':
case 'h':
case '-':
- fprintf (stderr, "%s\n", mount_usage);
- exit( TRUE);
- break;
+ goto goodbye;
}
} else {
if (device == NULL)
else if (directory == NULL)
directory=*argv;
else {
- fprintf (stderr, "%s\n", mount_usage);
- exit( TRUE);
+ goto goodbye;
}
}
i--;
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);
}
#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"
}
/* Parse any options */
- while (argc-- > 0 && **(argv++) == '-') {
+ while (--argc > 0 && **(++argv) == '-') {
while (*++(*argv)) switch (**argv) {
case 'a':
umountAll = TRUE;
/* 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);