[BusyBox] new tar feature
Rainer Weikusat
rainer.weikusat at sncag.com
Sun Aug 21 19:35:11 UTC 2005
If GNU tar is asked to work with a set of archive members, it will
report the names of all of them that are missing on stderr, followed
by a line that says "Error exit delayed from previous errors". The
patch below adds a compile-time option (default: off) to make the
busybox tar act likewise.
Index: busybox/archival/Config.in
===================================================================
RCS file: /data/repo/busybox/archival/Config.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- busybox/archival/Config.in 30 Nov 2004 16:02:30 -0000 1.1.1.1
+++ busybox/archival/Config.in 21 Aug 2005 19:11:08 -0000 1.2
@@ -205,6 +205,14 @@
help
Enable use of long options, increases size by about 400 Bytes
+config CONFIG_FEATURE_TAR_ALL_MISSING
+ bool " Report all specified files that were not part of the Archive."
+ default n
+ depends on CONFIG_TAR
+ help
+ Print the names of all archive members tar was asked to operate on
+ but couldn't, because they were not part of the archive to process.
+
config CONFIG_UNCOMPRESS
bool "uncompress"
default n
Index: busybox/archival/tar.c
===================================================================
RCS file: /data/repo/busybox/archival/tar.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- busybox/archival/tar.c 1 Jun 2005 08:04:03 -0000 1.1.1.2
+++ busybox/archival/tar.c 21 Aug 2005 19:10:59 -0000 1.2
@@ -611,6 +611,7 @@
# define TAR_OPT_FLAG_CREATE 0
#endif
+
#ifdef CONFIG_FEATURE_TAR_BZIP2
# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE))
# define TAR_OPT_STR_BZIP2 "j"
@@ -623,6 +624,7 @@
#ifdef CONFIG_FEATURE_TAR_FROM
# define TAR_OPT_INCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2))
# define TAR_OPT_EXCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + 1))
+# define TAR_OPT_IGNORE_MISSING (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + 2))
# define TAR_OPT_STR_FROM "T:X:"
# define TAR_OPT_FLAG_FROM 2
#else
@@ -644,6 +646,13 @@
# define TAR_OPT_STR_COMPRESS "Z"
#else
# define TAR_OPT_STR_COMPRESS ""
+# define TAR_OPT_FLAG_COMPRESS 0
+#endif
+
+#ifdef CONFIG_FEATURE_TAR_ALL_MISSING
+# define signal_error bb_error_msg
+#else
+# define signal_error bb_error_msg_and_die
#endif
static const char tar_options[]="txC:f:Opvk" \
@@ -663,6 +672,7 @@
{ "same-permissions", 0, NULL, 'p' },
{ "verbose", 0, NULL, 'v' },
{ "keep-old", 0, NULL, 'k' },
+ { "all-missing", 0, 0, 'a' },
# ifdef CONFIG_FEATURE_TAR_CREATE
{ "create", 0, NULL, 'c' },
{ "dereference", 0, NULL, 'h' },
@@ -692,6 +702,7 @@
const char *tar_filename = "-";
unsigned long opt;
unsigned long ctx_flag = 0;
+ int rc;
if (argc < 2) {
bb_show_usage();
@@ -842,6 +853,8 @@
bb_perror_msg_and_die("Couldnt chdir to %s", base_dir);
}
+ rc = EXIT_SUCCESS;
+
#ifdef CONFIG_FEATURE_TAR_CREATE
/* create an archive */
if (opt & CTX_CREATE) {
@@ -874,11 +887,16 @@
while (tar_handle->accept) {
if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) {
if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) {
- bb_error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data);
+ signal_error("%s: Not found in archive", tar_handle->accept->data);
+ rc = EXIT_FAILURE;
}
}
tar_handle->accept = tar_handle->accept->link;
}
+
+#ifdef CONFIG_FEATURE_TAR_ALL_MISSING
+ if (rc != EXIT_SUCCESS) bb_error_msg("Error exit delayed from previous errors");
+#endif
}
#ifdef CONFIG_FEATURE_CLEAN_UP
@@ -887,5 +905,5 @@
}
#endif /* CONFIG_FEATURE_CLEAN_UP */
- return(EXIT_SUCCESS);
+ return rc;
}
More information about the busybox
mailing list