//config: create compressed archives. It's probably the most widely used
//config: UNIX archive program.
//config:
+//config:config FEATURE_TAR_LONG_OPTIONS
+//config: bool "Enable long options"
+//config: default y
+//config: depends on TAR && LONG_OPTS
+//config:
//config:config FEATURE_TAR_CREATE
-//config: bool "Enable archive creation"
+//config: bool "Enable -c (archive creation)"
//config: default y
//config: depends on TAR
-//config: help
-//config: If you enable this option you'll be able to create
-//config: tar archives using the `-c' option.
//config:
//config:config FEATURE_TAR_AUTODETECT
//config: bool "Autodetect compressed tarballs"
//config: a list of files to include or exclude from an archive.
//config:
//config:config FEATURE_TAR_OLDGNU_COMPATIBILITY
-//config: bool "Support for old tar header format"
+//config: bool "Support old tar header format"
//config: default y
//config: depends on TAR || DPKG
//config: help
//config: tarballs still exist.
//config:
//config:config FEATURE_TAR_GNU_EXTENSIONS
-//config: bool "Support for GNU tar extensions (long filenames)"
+//config: bool "Support GNU tar extensions (long filenames)"
//config: default y
//config: depends on TAR || DPKG
-//config: help
-//config: With this option busybox supports GNU long filenames and
-//config: linknames.
-//config:
-//config:config FEATURE_TAR_LONG_OPTIONS
-//config: bool "Enable long options"
-//config: default y
-//config: depends on TAR && LONG_OPTS
-//config: help
-//config: Enable use of long options, increases size by about 400 Bytes
//config:
//config:config FEATURE_TAR_TO_COMMAND
-//config: bool "Support for writing to an external program"
+//config: bool "Support writing to an external program (--to-command)"
//config: default y
//config: depends on TAR && FEATURE_TAR_LONG_OPTIONS
//config: help
//config: default y
//config: depends on TAR
//config: help
-//config: Enables use of user and group names in tar. This affects contents
+//config: Enable use of user and group names in tar. This affects contents
//config: listings (-t) and preserving permissions when unpacking (-p).
//config: +200 bytes.
//config:
//config:config FEATURE_TAR_NOPRESERVE_TIME
-//config: bool "Enable -m (do not preserve time) option"
+//config: bool "Enable -m (do not preserve time) GNU option"
//config: default y
//config: depends on TAR
-//config: help
-//config: With this option busybox supports GNU tar -m
-//config: (do not preserve time) option.
//config:
//config:config FEATURE_TAR_SELINUX
-//config: bool "Support for extracting SELinux labels"
+//config: bool "Support extracting SELinux labels"
//config: default n
//config: depends on TAR && SELINUX
//config: help
#include <fnmatch.h>
#include "libbb.h"
+#include "common_bufsiz.h"
#include "bb_archive.h"
/* FIXME: Stop using this non-standard feature */
#ifndef FNM_LEADING_DIR
#define block_buf bb_common_bufsiz1
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
#if ENABLE_FEATURE_TAR_CREATE
/*
* Check to see if we are dealing with a hard link.
* If so -
- * Treat the first occurance of a given dev/inode as a file while
- * treating any additional occurances as hard links. This is done
+ * Treat the first occurrence of a given dev/inode as a file while
+ * treating any additional occurrences as hard links. This is done
* by adding the file information to the HardLinkInfo linked list.
*/
tbInfo->hlInfo = NULL;
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
llist_t *excludes = NULL;
#endif
+ INIT_G();
/* Initialise default values */
tar_handle = init_handle();
/* Prepend '-' to the first argument if required */
opt_complementary = "--:" // first arg is options
"tt:vv:" // count -t,-v
- IF_FEATURE_TAR_FROM("X::T::") // cumulative lists
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
"\xff::" // --exclude=PATTERN is a list
#endif
#endif
opt = getopt32(argv,
"txC:f:Oopvk"
- IF_FEATURE_TAR_CREATE( "ch" )
- IF_FEATURE_SEAMLESS_BZ2( "j" )
- IF_FEATURE_SEAMLESS_LZMA("a" )
- IF_FEATURE_TAR_FROM( "T:X:")
- IF_FEATURE_SEAMLESS_GZ( "z" )
- IF_FEATURE_SEAMLESS_XZ( "J" )
- IF_FEATURE_SEAMLESS_Z( "Z" )
+ IF_FEATURE_TAR_CREATE( "ch" )
+ IF_FEATURE_SEAMLESS_BZ2( "j" )
+ IF_FEATURE_SEAMLESS_LZMA("a" )
+ IF_FEATURE_TAR_FROM( "T:*X:*")
+ IF_FEATURE_SEAMLESS_GZ( "z" )
+ IF_FEATURE_SEAMLESS_XZ( "J" )
+ IF_FEATURE_SEAMLESS_Z( "Z" )
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components
, &base_dir // -C dir
// /* We need to know whether child (gzip/bzip/etc) exits abnormally */
// signal(SIGCHLD, check_errors_in_children);
+#if ENABLE_FEATURE_TAR_CREATE
/* Create an archive */
if (opt & OPT_CREATE) {
-#if SEAMLESS_COMPRESSION
+# if SEAMLESS_COMPRESSION
const char *zipMode = NULL;
if (opt & OPT_COMPRESS)
zipMode = "compress";
zipMode = "lzma";
if (opt & OPT_XZ)
zipMode = "xz";
-#endif
+# endif
/* NB: writeTarFile() closes tar_handle->src_fd */
return writeTarFile(tar_handle->src_fd, verboseFlag,
(opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
tar_handle->accept,
tar_handle->reject, zipMode);
}
+#endif
if (opt & OPT_ANY_COMPRESS) {
USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_state_t *xstate);)
USE_FOR_NOMMU(const char *xformer_prog;)
- if (opt & OPT_COMPRESS)
- USE_FOR_MMU(xformer = unpack_Z_stream;)
+ if (opt & OPT_COMPRESS) {
+ USE_FOR_MMU(IF_FEATURE_SEAMLESS_Z(xformer = unpack_Z_stream;))
USE_FOR_NOMMU(xformer_prog = "uncompress";)
- if (opt & OPT_GZIP)
- USE_FOR_MMU(xformer = unpack_gz_stream;)
+ }
+ if (opt & OPT_GZIP) {
+ USE_FOR_MMU(IF_FEATURE_SEAMLESS_GZ(xformer = unpack_gz_stream;))
USE_FOR_NOMMU(xformer_prog = "gunzip";)
- if (opt & OPT_BZIP2)
- USE_FOR_MMU(xformer = unpack_bz2_stream;)
+ }
+ if (opt & OPT_BZIP2) {
+ USE_FOR_MMU(IF_FEATURE_SEAMLESS_BZ2(xformer = unpack_bz2_stream;))
USE_FOR_NOMMU(xformer_prog = "bunzip2";)
- if (opt & OPT_LZMA)
- USE_FOR_MMU(xformer = unpack_lzma_stream;)
+ }
+ if (opt & OPT_LZMA) {
+ USE_FOR_MMU(IF_FEATURE_SEAMLESS_LZMA(xformer = unpack_lzma_stream;))
USE_FOR_NOMMU(xformer_prog = "unlzma";)
- if (opt & OPT_XZ)
- USE_FOR_MMU(xformer = unpack_xz_stream;)
+ }
+ if (opt & OPT_XZ) {
+ USE_FOR_MMU(IF_FEATURE_SEAMLESS_XZ(xformer = unpack_xz_stream;))
USE_FOR_NOMMU(xformer_prog = "unxz";)
+ }
fork_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
/* Can't lseek over pipes */