summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gusarov2010-01-19 20:22:30 +0600
committerDenys Vlasenko2010-01-20 02:47:37 +0100
commit0d478334b3e6f644f26518c31117b25134a2678a (patch)
treeab622a7bda68d428db79961701cea608c263baa3
parent2e5fa4a69d49646d928041ebd20bbe659b6d8260 (diff)
downloadbusybox-0d478334b3e6f644f26518c31117b25134a2678a.zip
busybox-0d478334b3e6f644f26518c31117b25134a2678a.tar.gz
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 17d5c41..cf771f9 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -276,6 +276,13 @@ config FEATURE_TAR_UNAME_GNAME
listings (-t) and preserving permissions when unpacking (-p).
+200 bytes.
+config FEATURE_TAR_NOPRESERVE_TIME
+ bool "Enable -m (do not preserve time) option"
+ default n
+ depends on TAR
+ help
+ With this option busybox supports GNU tar -m (do not preserve time) option.
+
endif #tar
config UNCOMPRESS
diff --git a/archival/tar.c b/archival/tar.c
index 399302b..f16b4d6 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -748,6 +748,7 @@ enum {
IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit
+ IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
OPTBIT_NUMERIC_OWNER,
OPTBIT_NOPRESERVE_PERM,
@@ -769,6 +770,7 @@ enum {
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
+ OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
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
@@ -808,6 +810,9 @@ static const char tar_longopts[] ALIGN1 =
# if ENABLE_FEATURE_SEAMLESS_Z
"compress\0" No_argument "Z"
# endif
+# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
+ "touch\0" No_argument "m"
+# endif
/* use numeric uid/gid from tar header, not textual */
"numeric-owner\0" No_argument "\xfc"
/* do not restore mode */
@@ -894,6 +899,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
IF_FEATURE_TAR_FROM( "T:X:")
IF_FEATURE_SEAMLESS_GZ( "z" )
IF_FEATURE_SEAMLESS_Z( "Z" )
+ IF_FEATURE_TAR_NOPRESERVE_TIME("m")
, &base_dir // -C dir
, &tar_filename // -f filename
IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
@@ -945,6 +951,11 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_COMPRESS)
get_header_ptr = get_header_tar_Z;
+#if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
+ if (opt & OPT_NOPRESERVE_TIME)
+ tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE;
+#endif
+
#if ENABLE_FEATURE_TAR_FROM
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
diff --git a/include/usage.h b/include/usage.h
index 7b85642..77b7b99 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -4408,7 +4408,7 @@
#define tar_trivial_usage \
"-[" IF_FEATURE_TAR_CREATE("c") IF_FEATURE_SEAMLESS_GZ("z") \
IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \
- IF_FEATURE_SEAMLESS_Z("Z") "xtvO] " \
+ IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "xtvO] " \
IF_FEATURE_TAR_FROM("[-X FILE] ") \
"[-f TARFILE] [-C DIR] [FILE]..."
#define tar_full_usage "\n\n" \
@@ -4433,6 +4433,9 @@
IF_FEATURE_SEAMLESS_Z( \
"\n Z Filter the archive through compress" \
) \
+ IF_FEATURE_TAR_NOPRESERVE_TIME( \
+ "\n m Do not extract files modified time" \
+ ) \
"\nFile selection:" \
"\n f Name of TARFILE or \"-\" for stdin" \
"\n O Extract to stdout" \