aboutsummaryrefslogtreecommitdiff
path: root/tar.c
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-23 01:34:05 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-23 01:34:05 +0000
commitde552874d2074ac48ea4b834d61c54e1b6971be3 (patch)
tree0360b39142f1c85e1cac2637e09c6e452cf1a444 /tar.c
parentf4acea8cf5175de2292c86b58f2f30d262f14345 (diff)
downloadbusybox-de552874d2074ac48ea4b834d61c54e1b6971be3.tar.gz
Some busybox updates. You no longer _have_ to put a "-" in front of tar
options, logger is better behaved and has a "-t" option now. init now supports the kernel chroot patch, so you can chroot to a new device and umount the old root. -Erik
Diffstat (limited to 'tar.c')
-rw-r--r--tar.c133
1 files changed, 62 insertions, 71 deletions
diff --git a/tar.c b/tar.c
index 5c407864f..adae6c94c 100644
--- a/tar.c
+++ b/tar.c
@@ -108,9 +108,7 @@ typedef struct {
*/
static int listFlag;
static int extractFlag;
-#ifdef BB_FEATURE_TAR_CREATE
static int createFlag;
-#endif
static int verboseFlag;
static int tostdoutFlag;
@@ -185,9 +183,7 @@ extern int tar_main (int argc, char **argv)
errorFlag = FALSE;
extractFlag = FALSE;
-#ifdef BB_FEATURE_TAR_CREATE
createFlag = FALSE;
-#endif
listFlag = FALSE;
verboseFlag = FALSE;
tostdoutFlag = FALSE;
@@ -199,90 +195,85 @@ extern int tar_main (int argc, char **argv)
/*
* Parse the options.
*/
- if (**argv == '-') {
+ if (**argv == '-')
options = (*argv++) + 1;
- argc--;
- for (; *options; options++) {
- switch (*options) {
- case 'f':
- if (tarName != NULL) {
- fprintf (stderr, "Only one 'f' option allowed\n");
-
- exit (FALSE);
- }
-
- tarName = *argv++;
- argc--;
-
- break;
-
- case 't':
- listFlag = TRUE;
- break;
-
- case 'x':
- extractFlag = TRUE;
- break;
-#ifdef BB_FEATURE_TAR_CREATE
- case 'c':
- createFlag = TRUE;
- break;
-#else
- case 'c':
- fprintf (stderr, "This version of tar was not compiled with tar creation support.\n" );
-
- exit (FALSE);
-#endif
-
- case 'v':
- verboseFlag = TRUE;
- break;
-
- case 'O':
- tostdoutFlag = TRUE;
- break;
-
- case '-':
- usage( tar_usage);
- break;
+ else
+ options = (*argv++);
+ argc--;
- default:
- fprintf (stderr, "Unknown tar flag '%c'\n"
- "Try `tar --help' for more information\n",
- *options);
+ for (; *options; options++) {
+ switch (*options) {
+ case 'f':
+ if (tarName != NULL) {
+ fprintf (stderr, "Only one 'f' option allowed\n");
exit (FALSE);
}
- }
- }
- /*
- * Validate the options.
- */
- if (extractFlag + listFlag
-#ifdef BB_FEATURE_TAR_CREATE
- + createFlag
-#endif
- != (TRUE+FALSE+FALSE)) {
- fprintf (stderr,
- "Exactly one of 'c', 'x' or 't' must be specified\n");
-
- exit (FALSE);
+ tarName = *argv++;
+ argc--;
+
+ break;
+
+ case 't':
+ if (extractFlag == TRUE || createFlag == TRUE )
+ goto flagError;
+ listFlag = TRUE;
+ break;
+
+ case 'x':
+ if (listFlag == TRUE || createFlag == TRUE )
+ goto flagError;
+ extractFlag = TRUE;
+ break;
+ case 'c':
+ if (extractFlag == TRUE || listFlag == TRUE)
+ goto flagError;
+ createFlag = TRUE;
+ break;
+
+ case 'v':
+ verboseFlag = TRUE;
+ break;
+
+ case 'O':
+ tostdoutFlag = TRUE;
+ break;
+
+ case '-':
+ usage( tar_usage);
+ break;
+
+ default:
+ fprintf (stderr, "Unknown tar flag '%c'\n"
+ "Try `tar --help' for more information\n",
+ *options);
+ exit (FALSE);
+ }
}
/*
* Do the correct type of action supplying the rest of the
* command line arguments as the list of files to process.
*/
-#ifdef BB_FEATURE_TAR_CREATE
- if (createFlag==TRUE)
+ if (createFlag==TRUE) {
+#ifndef BB_FEATURE_TAR_CREATE
+ fprintf (stderr, "This version of tar was not compiled with tar creation support.\n" );
+ exit (FALSE);
+#else
writeTarFile (argc, argv);
- else
#endif
+ } else {
readTarFile (argc, argv);
- if (errorFlag==TRUE)
+ }
+ if (errorFlag==TRUE) {
fprintf (stderr, "\n");
+ }
exit (!errorFlag);
+
+flagError:
+ fprintf (stderr, "Exactly one of 'c', 'x' or 't' must be specified\n");
+ exit (FALSE);
}