aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2004-01-25 05:48:28 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2004-01-25 05:48:28 +0000
commit303e989a119e99d79588b682c287f1bb491288a8 (patch)
treef37c85ba0bfa0fa84286f59e6e9527023d5edb66
parentca43b485deafb6467dbaf4dd3e6496da0239444c (diff)
downloadbusybox-w32-303e989a119e99d79588b682c287f1bb491288a8.tar.gz
busybox-w32-303e989a119e99d79588b682c287f1bb491288a8.tar.bz2
busybox-w32-303e989a119e99d79588b682c287f1bb491288a8.zip
Add the -h, --dereference option for archive creation.
-rw-r--r--archival/tar.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 8074c2d1a..cbd069425 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -432,7 +432,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
432} 432}
433 433
434static inline int writeTarFile(const int tar_fd, const int verboseFlag, 434static inline int writeTarFile(const int tar_fd, const int verboseFlag,
435 const llist_t *include, const llist_t *exclude, const int gzip) 435 const unsigned long dereferenceFlag, const llist_t *include,
436 const llist_t *exclude, const int gzip)
436{ 437{
437#ifdef CONFIG_FEATURE_TAR_GZIP 438#ifdef CONFIG_FEATURE_TAR_GZIP
438 int gzipDataPipe[2] = { -1, -1 }; 439 int gzipDataPipe[2] = { -1, -1 };
@@ -516,7 +517,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
516 517
517 /* Read the directory/files and iterate over them one at a time */ 518 /* Read the directory/files and iterate over them one at a time */
518 while (include) { 519 while (include) {
519 if (!recursive_action(include->data, TRUE, FALSE, FALSE, 520 if (!recursive_action(include->data, TRUE, dereferenceFlag, FALSE,
520 writeFileToTarball, writeFileToTarball, 521 writeFileToTarball, writeFileToTarball,
521 (void *) &tbInfo)) { 522 (void *) &tbInfo)) {
522 errorFlag = TRUE; 523 errorFlag = TRUE;
@@ -605,8 +606,9 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
605 606
606#ifdef CONFIG_FEATURE_TAR_CREATE 607#ifdef CONFIG_FEATURE_TAR_CREATE
607# define CTX_CREATE (1 << 8) 608# define CTX_CREATE (1 << 8)
608# define TAR_OPT_STR_CREATE "c" 609# define TAR_OPT_DEREFERNCE (1 << 9)
609# define TAR_OPT_FLAG_CREATE 1 610# define TAR_OPT_STR_CREATE "ch"
611# define TAR_OPT_FLAG_CREATE 2
610#else 612#else
611//# define CTX_CREATE 0 613//# define CTX_CREATE 0
612# define TAR_OPT_STR_CREATE "" 614# define TAR_OPT_STR_CREATE ""
@@ -667,6 +669,7 @@ static const struct option tar_long_options[] = {
667 { "keep-old", 0, NULL, 'k' }, 669 { "keep-old", 0, NULL, 'k' },
668# ifdef CONFIG_FEATURE_TAR_CREATE 670# ifdef CONFIG_FEATURE_TAR_CREATE
669 { "create", 0, NULL, 'c' }, 671 { "create", 0, NULL, 'c' },
672 { "dereference", 0, NULL, 'h' },
670# endif 673# endif
671# ifdef CONFIG_FEATURE_TAR_BZIP2 674# ifdef CONFIG_FEATURE_TAR_BZIP2
672 { "bzip2", 0, NULL, 'j' }, 675 { "bzip2", 0, NULL, 'j' },
@@ -861,7 +864,7 @@ int tar_main(int argc, char **argv)
861 (tar_handle->action_header == header_verbose_list)) { 864 (tar_handle->action_header == header_verbose_list)) {
862 verboseFlag = TRUE; 865 verboseFlag = TRUE;
863 } 866 }
864 writeTarFile(tar_handle->src_fd, verboseFlag, tar_handle->accept, 867 writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERNCE, tar_handle->accept,
865 tar_handle->reject, gzipFlag); 868 tar_handle->reject, gzipFlag);
866 } else 869 } else
867#endif /* CONFIG_FEATURE_TAR_CREATE */ 870#endif /* CONFIG_FEATURE_TAR_CREATE */