aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gusarov <dottedmag@dottedmag.net>2010-01-19 20:22:30 +0600
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-20 02:47:37 +0100
commit0d478334b3e6f644f26518c31117b25134a2678a (patch)
treeab622a7bda68d428db79961701cea608c263baa3
parent2e5fa4a69d49646d928041ebd20bbe659b6d8260 (diff)
downloadbusybox-w32-0d478334b3e6f644f26518c31117b25134a2678a.tar.gz
busybox-w32-0d478334b3e6f644f26518c31117b25134a2678a.tar.bz2
busybox-w32-0d478334b3e6f644f26518c31117b25134a2678a.zip
tar: handle -m (--touch) switch, enabled by FEATURE_TAR_NOPRESERVE_TIME
function old new delta .rodata 2731 2779 +48 usage_messages 432 471 +39 tar_main 603 614 +11 tar_longopts 211 219 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 106/0) Total: 106 bytes Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/Config.in7
-rw-r--r--archival/tar.c11
-rw-r--r--include/usage.h5
3 files changed, 22 insertions, 1 deletions
diff --git a/archival/Config.in b/archival/Config.in
index 17d5c411b..cf771f96c 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -276,6 +276,13 @@ config FEATURE_TAR_UNAME_GNAME
276 listings (-t) and preserving permissions when unpacking (-p). 276 listings (-t) and preserving permissions when unpacking (-p).
277 +200 bytes. 277 +200 bytes.
278 278
279config FEATURE_TAR_NOPRESERVE_TIME
280 bool "Enable -m (do not preserve time) option"
281 default n
282 depends on TAR
283 help
284 With this option busybox supports GNU tar -m (do not preserve time) option.
285
279endif #tar 286endif #tar
280 287
281config UNCOMPRESS 288config UNCOMPRESS
diff --git a/archival/tar.c b/archival/tar.c
index 399302bfd..f16b4d671 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -748,6 +748,7 @@ enum {
748 IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,) 748 IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
749 IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,) 749 IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
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 ENABLE_FEATURE_TAR_LONG_OPTIONS 752#if ENABLE_FEATURE_TAR_LONG_OPTIONS
752 OPTBIT_NUMERIC_OWNER, 753 OPTBIT_NUMERIC_OWNER,
753 OPTBIT_NOPRESERVE_PERM, 754 OPTBIT_NOPRESERVE_PERM,
@@ -769,6 +770,7 @@ enum {
769 OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T 770 OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
770 OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X 771 OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
771 OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z 772 OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
773 OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
772 OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z 774 OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
773 OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner 775 OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
774 OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions 776 OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
@@ -808,6 +810,9 @@ static const char tar_longopts[] ALIGN1 =
808# if ENABLE_FEATURE_SEAMLESS_Z 810# if ENABLE_FEATURE_SEAMLESS_Z
809 "compress\0" No_argument "Z" 811 "compress\0" No_argument "Z"
810# endif 812# endif
813# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
814 "touch\0" No_argument "m"
815# endif
811 /* use numeric uid/gid from tar header, not textual */ 816 /* use numeric uid/gid from tar header, not textual */
812 "numeric-owner\0" No_argument "\xfc" 817 "numeric-owner\0" No_argument "\xfc"
813 /* do not restore mode */ 818 /* do not restore mode */
@@ -894,6 +899,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
894 IF_FEATURE_TAR_FROM( "T:X:") 899 IF_FEATURE_TAR_FROM( "T:X:")
895 IF_FEATURE_SEAMLESS_GZ( "z" ) 900 IF_FEATURE_SEAMLESS_GZ( "z" )
896 IF_FEATURE_SEAMLESS_Z( "Z" ) 901 IF_FEATURE_SEAMLESS_Z( "Z" )
902 IF_FEATURE_TAR_NOPRESERVE_TIME("m")
897 , &base_dir // -C dir 903 , &base_dir // -C dir
898 , &tar_filename // -f filename 904 , &tar_filename // -f filename
899 IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T 905 IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
@@ -945,6 +951,11 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
945 if (opt & OPT_COMPRESS) 951 if (opt & OPT_COMPRESS)
946 get_header_ptr = get_header_tar_Z; 952 get_header_ptr = get_header_tar_Z;
947 953
954#if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
955 if (opt & OPT_NOPRESERVE_TIME)
956 tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE;
957#endif
958
948#if ENABLE_FEATURE_TAR_FROM 959#if ENABLE_FEATURE_TAR_FROM
949 tar_handle->reject = append_file_list_to_list(tar_handle->reject); 960 tar_handle->reject = append_file_list_to_list(tar_handle->reject);
950#if ENABLE_FEATURE_TAR_LONG_OPTIONS 961#if ENABLE_FEATURE_TAR_LONG_OPTIONS
diff --git a/include/usage.h b/include/usage.h
index 7b8564278..77b7b99bd 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -4408,7 +4408,7 @@
4408#define tar_trivial_usage \ 4408#define tar_trivial_usage \
4409 "-[" IF_FEATURE_TAR_CREATE("c") IF_FEATURE_SEAMLESS_GZ("z") \ 4409 "-[" IF_FEATURE_TAR_CREATE("c") IF_FEATURE_SEAMLESS_GZ("z") \
4410 IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \ 4410 IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \
4411 IF_FEATURE_SEAMLESS_Z("Z") "xtvO] " \ 4411 IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "xtvO] " \
4412 IF_FEATURE_TAR_FROM("[-X FILE] ") \ 4412 IF_FEATURE_TAR_FROM("[-X FILE] ") \
4413 "[-f TARFILE] [-C DIR] [FILE]..." 4413 "[-f TARFILE] [-C DIR] [FILE]..."
4414#define tar_full_usage "\n\n" \ 4414#define tar_full_usage "\n\n" \
@@ -4433,6 +4433,9 @@
4433 IF_FEATURE_SEAMLESS_Z( \ 4433 IF_FEATURE_SEAMLESS_Z( \
4434 "\n Z Filter the archive through compress" \ 4434 "\n Z Filter the archive through compress" \
4435 ) \ 4435 ) \
4436 IF_FEATURE_TAR_NOPRESERVE_TIME( \
4437 "\n m Do not extract files modified time" \
4438 ) \
4436 "\nFile selection:" \ 4439 "\nFile selection:" \
4437 "\n f Name of TARFILE or \"-\" for stdin" \ 4440 "\n f Name of TARFILE or \"-\" for stdin" \
4438 "\n O Extract to stdout" \ 4441 "\n O Extract to stdout" \