cpio: allow cpio -i to take params - names of files to extract
[oweals/busybox.git] / archival / tar.c
index f49fb129e593b48e2f39cb2669351ce62e8b7791..ebaa965c051007129ec29ce543370d7516ba8a69 100644 (file)
  *  Copyright (c) 1999 by David I. Bell
  *  Permission is granted to use, distribute, or modify this source,
  *  provided that this copyright notice remains intact.
- *  Permission to distribute sash derived code under the GPL has been granted.
+ *  Permission to distribute sash derived code under GPL has been granted.
  *
  * Based in part on the tar implementation from busybox-0.28
  *  Copyright (C) 1995 Bruce Perens
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 #include <fnmatch.h>
 #include "libbb.h"
-#include "unarchive.h"
+#include "archive.h"
 /* FIXME: Stop using this non-standard feature */
 #ifndef FNM_LEADING_DIR
 # define FNM_LEADING_DIR 0
@@ -237,7 +237,7 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
        struct tar_header_t header;
 
        memset(&header, 0, sizeof(header));
+
        strncpy(header.name, header_name, sizeof(header.name));
 
        /* POSIX says to mask mode with 07777. */
@@ -514,9 +514,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
        (void) &zip_exec;
 # endif
 
-       gzipPid = vfork();
-       if (gzipPid < 0)
-               bb_perror_msg_and_die("vfork");
+       gzipPid = xvfork();
 
        if (gzipPid == 0) {
                /* child */
@@ -574,8 +572,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
 
        /* Store the stat info for the tarball's file, so
         * can avoid including the tarball into itself....  */
-       if (fstat(tbInfo.tarFd, &tbInfo.tarFileStatBuf) < 0)
-               bb_perror_msg_and_die("can't stat tar file");
+       xfstat(tbInfo.tarFd, &tbInfo.tarFileStatBuf, "can't stat tar file");
 
 #if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
        if (gzip)
@@ -885,7 +882,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
        /* Prepend '-' to the first argument if required */
        opt_complementary = "--:" // first arg is options
                "tt:vv:" // count -t,-v
-               "?:" // bail out with usage instead of error return
                "X::T::" // cumulative lists
 #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
                "\xff::" // cumulative lists for --exclude