diff options
author | Ladislav Michl <Ladislav.Michl@seznam.cz> | 2010-06-25 01:33:00 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-25 01:33:00 +0200 |
commit | 2b46fd49b14b2ac30e0c767c65ac2b29f6922a45 (patch) | |
tree | 184e89b5922c87c866c7ae02ca4a87a61d0ac384 /archival/tar.c | |
parent | 51fa147c9bab41cc1f7bf5b2e3bbeddf0fdaf5ca (diff) | |
download | busybox-w32-2b46fd49b14b2ac30e0c767c65ac2b29f6922a45.tar.gz busybox-w32-2b46fd49b14b2ac30e0c767c65ac2b29f6922a45.tar.bz2 busybox-w32-2b46fd49b14b2ac30e0c767c65ac2b29f6922a45.zip |
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 3a940128b..344c9dea4 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -750,6 +750,7 @@ enum { | |||
750 | IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit | 750 | IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit |
751 | IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,) | 751 | IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,) |
752 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | 752 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS |
753 | IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,) | ||
753 | OPTBIT_NUMERIC_OWNER, | 754 | OPTBIT_NUMERIC_OWNER, |
754 | OPTBIT_NOPRESERVE_PERM, | 755 | OPTBIT_NOPRESERVE_PERM, |
755 | OPTBIT_OVERWRITE, | 756 | OPTBIT_OVERWRITE, |
@@ -772,6 +773,7 @@ enum { | |||
772 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z | 773 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z |
773 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z | 774 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z |
774 | OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m | 775 | OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m |
776 | OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command | ||
775 | OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner | 777 | OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner |
776 | OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions | 778 | OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions |
777 | OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite | 779 | OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite |
@@ -813,6 +815,9 @@ static const char tar_longopts[] ALIGN1 = | |||
813 | # if ENABLE_FEATURE_TAR_NOPRESERVE_TIME | 815 | # if ENABLE_FEATURE_TAR_NOPRESERVE_TIME |
814 | "touch\0" No_argument "m" | 816 | "touch\0" No_argument "m" |
815 | # endif | 817 | # endif |
818 | # if ENABLE_FEATURE_TAR_TO_COMMAND | ||
819 | "to-command\0" Required_argument "\xfb" | ||
820 | # endif | ||
816 | /* use numeric uid/gid from tar header, not textual */ | 821 | /* use numeric uid/gid from tar header, not textual */ |
817 | "numeric-owner\0" No_argument "\xfc" | 822 | "numeric-owner\0" No_argument "\xfc" |
818 | /* do not restore mode */ | 823 | /* do not restore mode */ |
@@ -904,6 +909,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
904 | , &tar_filename // -f filename | 909 | , &tar_filename // -f filename |
905 | IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T | 910 | IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T |
906 | IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X | 911 | IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X |
912 | IF_FEATURE_TAR_TO_COMMAND(, &(tar_handle->tar__to_command)) // --to-command | ||
907 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM | 913 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM |
908 | , &excludes // --exclude | 914 | , &excludes // --exclude |
909 | #endif | 915 | #endif |
@@ -922,6 +928,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
922 | if (opt & OPT_2STDOUT) | 928 | if (opt & OPT_2STDOUT) |
923 | tar_handle->action_data = data_extract_to_stdout; | 929 | tar_handle->action_data = data_extract_to_stdout; |
924 | 930 | ||
931 | if (opt & OPT_2COMMAND) { | ||
932 | putenv((char*)"TAR_FILETYPE=f"); | ||
933 | signal(SIGPIPE, SIG_IGN); | ||
934 | tar_handle->action_data = data_extract_to_command; | ||
935 | } | ||
936 | |||
925 | if (opt & OPT_KEEP_OLD) | 937 | if (opt & OPT_KEEP_OLD) |
926 | tar_handle->ah_flags &= ~ARCHIVE_UNLINK_OLD; | 938 | tar_handle->ah_flags &= ~ARCHIVE_UNLINK_OLD; |
927 | 939 | ||