diff options
author | Natanael Copa <natanael.copa@gmail.com> | 2012-04-24 17:06:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-05-18 16:34:30 +0200 |
commit | 044610413767eda4350c5adf35cf5e69a6d6df8f (patch) | |
tree | 285eda8f28514812b3ebc3285e14168e2dbf49d0 | |
parent | b6beada5a1432645090b441531b5909983cfbf10 (diff) | |
download | busybox-w32-044610413767eda4350c5adf35cf5e69a6d6df8f.tar.gz busybox-w32-044610413767eda4350c5adf35cf5e69a6d6df8f.tar.bz2 busybox-w32-044610413767eda4350c5adf35cf5e69a6d6df8f.zip |
tar: implement --no-recursion
function old new delta
tar_longopts 259 274 +15
.rodata 5757 5772 +15
tar_main 1038 1052 +14
writeTarFile 362 353 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 44/-9) Total: 35 bytes
text data bss dec hex filename
81457 1706 8344 91507 16573 busybox_old
81477 1706 8344 91527 16587 busybox_unstripped
Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/tar.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/archival/tar.c b/archival/tar.c index cf972c24c..a64d6510f 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -60,8 +60,8 @@ | |||
60 | 60 | ||
61 | #if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2 | 61 | #if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2 |
62 | /* Do not pass gzip flag to writeTarFile() */ | 62 | /* Do not pass gzip flag to writeTarFile() */ |
63 | #define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \ | 63 | #define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \ |
64 | writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude) | 64 | writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude) |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | 67 | ||
@@ -598,7 +598,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip) | |||
598 | 598 | ||
599 | /* gcc 4.2.1 inlines it, making code bigger */ | 599 | /* gcc 4.2.1 inlines it, making code bigger */ |
600 | static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | 600 | static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, |
601 | int dereferenceFlag, const llist_t *include, | 601 | int recurseFlags, const llist_t *include, |
602 | const llist_t *exclude, int gzip) | 602 | const llist_t *exclude, int gzip) |
603 | { | 603 | { |
604 | int errorFlag = FALSE; | 604 | int errorFlag = FALSE; |
@@ -621,8 +621,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
621 | 621 | ||
622 | /* Read the directory/files and iterate over them one at a time */ | 622 | /* Read the directory/files and iterate over them one at a time */ |
623 | while (include) { | 623 | while (include) { |
624 | if (!recursive_action(include->data, ACTION_RECURSE | | 624 | if (!recursive_action(include->data, recurseFlags, |
625 | (dereferenceFlag ? ACTION_FOLLOWLINKS : 0), | ||
626 | writeFileToTarball, writeFileToTarball, &tbInfo, 0) | 625 | writeFileToTarball, writeFileToTarball, &tbInfo, 0) |
627 | ) { | 626 | ) { |
628 | errorFlag = TRUE; | 627 | errorFlag = TRUE; |
@@ -662,7 +661,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
662 | } | 661 | } |
663 | #else | 662 | #else |
664 | int writeTarFile(int tar_fd, int verboseFlag, | 663 | int writeTarFile(int tar_fd, int verboseFlag, |
665 | int dereferenceFlag, const llist_t *include, | 664 | int recurseFlags, const llist_t *include, |
666 | const llist_t *exclude, int gzip); | 665 | const llist_t *exclude, int gzip); |
667 | #endif /* FEATURE_TAR_CREATE */ | 666 | #endif /* FEATURE_TAR_CREATE */ |
668 | 667 | ||
@@ -749,6 +748,7 @@ static llist_t *append_file_list_to_list(llist_t *list) | |||
749 | // o no-same-owner | 748 | // o no-same-owner |
750 | // p same-permissions | 749 | // p same-permissions |
751 | // k keep-old | 750 | // k keep-old |
751 | // no-recursion | ||
752 | // numeric-owner | 752 | // numeric-owner |
753 | // no-same-permissions | 753 | // no-same-permissions |
754 | // overwrite | 754 | // overwrite |
@@ -768,6 +768,7 @@ enum { | |||
768 | IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit | 768 | IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit |
769 | IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,) | 769 | IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,) |
770 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | 770 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS |
771 | OPTBIT_NORECURSION, | ||
771 | IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,) | 772 | IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,) |
772 | OPTBIT_NUMERIC_OWNER, | 773 | OPTBIT_NUMERIC_OWNER, |
773 | OPTBIT_NOPRESERVE_PERM, | 774 | OPTBIT_NOPRESERVE_PERM, |
@@ -791,6 +792,7 @@ enum { | |||
791 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z | 792 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z |
792 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z | 793 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z |
793 | OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m | 794 | OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m |
795 | OPT_NORECURSION = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION )) + 0, // no-recursion | ||
794 | OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command | 796 | OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command |
795 | OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner | 797 | OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner |
796 | OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions | 798 | OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions |
@@ -835,6 +837,7 @@ static const char tar_longopts[] ALIGN1 = | |||
835 | # if ENABLE_FEATURE_TAR_NOPRESERVE_TIME | 837 | # if ENABLE_FEATURE_TAR_NOPRESERVE_TIME |
836 | "touch\0" No_argument "m" | 838 | "touch\0" No_argument "m" |
837 | # endif | 839 | # endif |
840 | "no-recursion\0" No_argument "\xfa" | ||
838 | # if ENABLE_FEATURE_TAR_TO_COMMAND | 841 | # if ENABLE_FEATURE_TAR_TO_COMMAND |
839 | "to-command\0" Required_argument "\xfb" | 842 | "to-command\0" Required_argument "\xfb" |
840 | # endif | 843 | # endif |
@@ -1050,7 +1053,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1050 | zipMode = 2; | 1053 | zipMode = 2; |
1051 | #endif | 1054 | #endif |
1052 | /* NB: writeTarFile() closes tar_handle->src_fd */ | 1055 | /* NB: writeTarFile() closes tar_handle->src_fd */ |
1053 | return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE, | 1056 | return writeTarFile(tar_handle->src_fd, verboseFlag, |
1057 | (opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0) | ||
1058 | | (opt & OPT_NORECURSION ? 0 : ACTION_RECURSE), | ||
1054 | tar_handle->accept, | 1059 | tar_handle->accept, |
1055 | tar_handle->reject, zipMode); | 1060 | tar_handle->reject, zipMode); |
1056 | } | 1061 | } |