diff options
author | Ladislav Michl | 2010-06-25 01:33:00 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-06-25 01:33:00 +0200 |
commit | 2b46fd49b14b2ac30e0c767c65ac2b29f6922a45 (patch) | |
tree | 184e89b5922c87c866c7ae02ca4a87a61d0ac384 /archival/tar.c | |
parent | 51fa147c9bab41cc1f7bf5b2e3bbeddf0fdaf5ca (diff) | |
download | busybox-2b46fd49b14b2ac30e0c767c65ac2b29f6922a45.zip busybox-2b46fd49b14b2ac30e0c767c65ac2b29f6922a45.tar.gz |
tar: optional support for --to-command
function old new delta
data_extract_to_command - 430 +430
dec2env - 44 +44
tar_main 778 819 +41
str2env - 37 +37
tar_var - 32 +32
xputenv - 22 +22
tar_longopts 257 270 +13
------------------------------------------------------------------------------
(add/remove: 6/0 grow/shrink: 2/0 up/down: 619/0) Total: 619 bytes
Signed-off-by: Ladislav Michl <Ladislav.Michl@seznam.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/archival/tar.c b/archival/tar.c index 3a94012..344c9de 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -750,6 +750,7 @@ enum { IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,) #if ENABLE_FEATURE_TAR_LONG_OPTIONS + IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,) OPTBIT_NUMERIC_OWNER, OPTBIT_NOPRESERVE_PERM, OPTBIT_OVERWRITE, @@ -772,6 +773,7 @@ enum { OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m + OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite @@ -813,6 +815,9 @@ static const char tar_longopts[] ALIGN1 = # if ENABLE_FEATURE_TAR_NOPRESERVE_TIME "touch\0" No_argument "m" # endif +# if ENABLE_FEATURE_TAR_TO_COMMAND + "to-command\0" Required_argument "\xfb" +# endif /* use numeric uid/gid from tar header, not textual */ "numeric-owner\0" No_argument "\xfc" /* do not restore mode */ @@ -904,6 +909,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) , &tar_filename // -f filename IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X + IF_FEATURE_TAR_TO_COMMAND(, &(tar_handle->tar__to_command)) // --to-command #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM , &excludes // --exclude #endif @@ -922,6 +928,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv) if (opt & OPT_2STDOUT) tar_handle->action_data = data_extract_to_stdout; + if (opt & OPT_2COMMAND) { + putenv((char*)"TAR_FILETYPE=f"); + signal(SIGPIPE, SIG_IGN); + tar_handle->action_data = data_extract_to_command; + } + if (opt & OPT_KEEP_OLD) tar_handle->ah_flags &= ~ARCHIVE_UNLINK_OLD; |