aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-10-15 06:32:38 +0000
committer"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-10-15 06:32:38 +0000
commit84e7511607600c2c7b9e7c4087897d44cc4668c4 (patch)
tree757c93493b9741c7b2c9820b6e8abeaee17fe073
parent3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f (diff)
downloadbusybox-w32-84e7511607600c2c7b9e7c4087897d44cc4668c4.tar.gz
busybox-w32-84e7511607600c2c7b9e7c4087897d44cc4668c4.tar.bz2
busybox-w32-84e7511607600c2c7b9e7c4087897d44cc4668c4.zip
llist must initialize, add loses ifdef, small indent correction
-rw-r--r--archival/tar.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 81edc3fc3..4363d355b 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -94,8 +94,8 @@ typedef struct TarHeader TarHeader;
94typedef struct HardLinkInfo HardLinkInfo; 94typedef struct HardLinkInfo HardLinkInfo;
95struct HardLinkInfo { 95struct HardLinkInfo {
96 HardLinkInfo *next; /* Next entry in list */ 96 HardLinkInfo *next; /* Next entry in list */
97 dev_t dev; /* Device number */ 97 dev_t dev; /* Device number */
98 ino_t ino; /* Inode number */ 98 ino_t ino; /* Inode number */
99 short linkCount; /* (Hard) Link Count */ 99 short linkCount; /* (Hard) Link Count */
100 char name[1]; /* Start of filename (must be last) */ 100 char name[1]; /* Start of filename (must be last) */
101}; 101};
@@ -103,7 +103,7 @@ struct HardLinkInfo {
103/* Some info to be carried along when creating a new tarball */ 103/* Some info to be carried along when creating a new tarball */
104struct TarBallInfo { 104struct TarBallInfo {
105 char *fileName; /* File name of the tarball */ 105 char *fileName; /* File name of the tarball */
106 int tarFd; /* Open-for-write file descriptor 106 int tarFd; /* Open-for-write file descriptor
107 for the tarball */ 107 for the tarball */
108 struct stat statBuf; /* Stat info for the tarball, letting 108 struct stat statBuf; /* Stat info for the tarball, letting
109 us know the inode and device that the 109 us know the inode and device that the
@@ -213,8 +213,9 @@ static int putOctal(char *cp, int len, long value)
213 213
214/* Write out a tar header for the specified file/directory/whatever */ 214/* Write out a tar header for the specified file/directory/whatever */
215static inline int writeTarHeader(struct TarBallInfo *tbInfo, 215static inline int writeTarHeader(struct TarBallInfo *tbInfo,
216 const char *header_name, 216 const char *header_name,
217 const char *real_name, struct stat *statbuf) 217 const char *real_name,
218 struct stat *statbuf)
218{ 219{
219 long chksum = 0; 220 long chksum = 0;
220 struct TarHeader header; 221 struct TarHeader header;
@@ -396,7 +397,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
396 if (exclude_file(tbInfo->excludeList, header_name)) { 397 if (exclude_file(tbInfo->excludeList, header_name)) {
397 return SKIP; 398 return SKIP;
398 } 399 }
399# endif /* CONFIG_FEATURE_TAR_FROM */ 400# endif /* CONFIG_FEATURE_TAR_FROM */
400 401
401 if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) { 402 if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) {
402 return (FALSE); 403 return (FALSE);
@@ -513,7 +514,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
513 /* Read the directory/files and iterate over them one at a time */ 514 /* Read the directory/files and iterate over them one at a time */
514 while (include) { 515 while (include) {
515 if (!recursive_action(include->data, TRUE, dereferenceFlag, FALSE, 516 if (!recursive_action(include->data, TRUE, dereferenceFlag, FALSE,
516 writeFileToTarball, writeFileToTarball, 517 writeFileToTarball, writeFileToTarball,
517 (void *) &tbInfo)) { 518 (void *) &tbInfo)) {
518 errorFlag = TRUE; 519 errorFlag = TRUE;
519 } 520 }
@@ -543,7 +544,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
543 544
544 return !errorFlag; 545 return !errorFlag;
545} 546}
546#endif /* tar_create */ 547#endif /* tar_create */
547 548
548#ifdef CONFIG_FEATURE_TAR_FROM 549#ifdef CONFIG_FEATURE_TAR_FROM
549static llist_t *append_file_list_to_list(llist_t *list) 550static llist_t *append_file_list_to_list(llist_t *list)
@@ -588,28 +589,28 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
588} 589}
589#endif 590#endif
590 591
591#define CTX_TEST (1 << 0) 592#define CTX_TEST (1 << 0)
592#define CTX_EXTRACT (1 << 1) 593#define CTX_EXTRACT (1 << 1)
593#define TAR_OPT_BASEDIR (1 << 2) 594#define TAR_OPT_BASEDIR (1 << 2)
594#define TAR_OPT_TARNAME (1 << 3) 595#define TAR_OPT_TARNAME (1 << 3)
595#define TAR_OPT_2STDOUT (1 << 4) 596#define TAR_OPT_2STDOUT (1 << 4)
596#define TAR_OPT_P (1 << 5) 597#define TAR_OPT_P (1 << 5)
597#define TAR_OPT_VERBOSE (1 << 6) 598#define TAR_OPT_VERBOSE (1 << 6)
598#define TAR_OPT_KEEP_OLD (1 << 7) 599#define TAR_OPT_KEEP_OLD (1 << 7)
599 600
600#ifdef CONFIG_FEATURE_TAR_CREATE 601#ifdef CONFIG_FEATURE_TAR_CREATE
601# define CTX_CREATE (1 << 8) 602# define CTX_CREATE (1 << 8)
602# define TAR_OPT_DEREFERNCE (1 << 9) 603# define TAR_OPT_DEREFERNCE (1 << 9)
603# define TAR_OPT_STR_CREATE "ch" 604# define TAR_OPT_STR_CREATE "ch"
604# define TAR_OPT_FLAG_CREATE 2 605# define TAR_OPT_FLAG_CREATE 2
605#else 606#else
606# define CTX_CREATE 0 607# define CTX_CREATE 0
607# define TAR_OPT_STR_CREATE "" 608# define TAR_OPT_STR_CREATE ""
608# define TAR_OPT_FLAG_CREATE 0 609# define TAR_OPT_FLAG_CREATE 0
609#endif 610#endif
610 611
611#ifdef CONFIG_FEATURE_TAR_BZIP2 612#ifdef CONFIG_FEATURE_TAR_BZIP2
612# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE)) 613# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE))
613# define TAR_OPT_STR_BZIP2 "j" 614# define TAR_OPT_STR_BZIP2 "j"
614# define TAR_OPT_FLAG_BZIP2 1 615# define TAR_OPT_FLAG_BZIP2 1
615#else 616#else
@@ -652,20 +653,20 @@ static const char tar_options[]="txC:f:Opvk" \
652 653
653#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS 654#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
654static const struct option tar_long_options[] = { 655static const struct option tar_long_options[] = {
655 { "list", 0, NULL, 't' }, 656 { "list", 0, NULL, 't' },
656 { "extract", 0, NULL, 'x' }, 657 { "extract", 0, NULL, 'x' },
657 { "directory", 1, NULL, 'C' }, 658 { "directory", 1, NULL, 'C' },
658 { "file", 1, NULL, 'f' }, 659 { "file", 1, NULL, 'f' },
659 { "to-stdout", 0, NULL, 'O' }, 660 { "to-stdout", 0, NULL, 'O' },
660 { "same-permissions", 0, NULL, 'p' }, 661 { "same-permissions", 0, NULL, 'p' },
661 { "verbose", 0, NULL, 'v' }, 662 { "verbose", 0, NULL, 'v' },
662 { "keep-old", 0, NULL, 'k' }, 663 { "keep-old", 0, NULL, 'k' },
663# ifdef CONFIG_FEATURE_TAR_CREATE 664# ifdef CONFIG_FEATURE_TAR_CREATE
664 { "create", 0, NULL, 'c' }, 665 { "create", 0, NULL, 'c' },
665 { "dereference", 0, NULL, 'h' }, 666 { "dereference", 0, NULL, 'h' },
666# endif 667# endif
667# ifdef CONFIG_FEATURE_TAR_BZIP2 668# ifdef CONFIG_FEATURE_TAR_BZIP2
668 { "bzip2", 0, NULL, 'j' }, 669 { "bzip2", 0, NULL, 'j' },
669# endif 670# endif
670# ifdef CONFIG_FEATURE_TAR_FROM 671# ifdef CONFIG_FEATURE_TAR_FROM
671 { "files-from", 1, NULL, 'T' }, 672 { "files-from", 1, NULL, 'T' },
@@ -673,12 +674,12 @@ static const struct option tar_long_options[] = {
673 { "exclude", 1, NULL, '\n' }, 674 { "exclude", 1, NULL, '\n' },
674# endif 675# endif
675# ifdef CONFIG_FEATURE_TAR_GZIP 676# ifdef CONFIG_FEATURE_TAR_GZIP
676 { "gzip", 0, NULL, 'z' }, 677 { "gzip", 0, NULL, 'z' },
677# endif 678# endif
678# ifdef CONFIG_FEATURE_TAR_COMPRESS 679# ifdef CONFIG_FEATURE_TAR_COMPRESS
679 { "compress", 0, NULL, 'Z' }, 680 { "compress", 0, NULL, 'Z' },
680# endif 681# endif
681 { 0, 0, 0, 0 } 682 { 0, 0, 0, 0 }
682}; 683};
683#endif 684#endif
684 685
@@ -689,8 +690,10 @@ int tar_main(int argc, char **argv)
689 char *base_dir = NULL; 690 char *base_dir = NULL;
690 const char *tar_filename = "-"; 691 const char *tar_filename = "-";
691 unsigned long opt; 692 unsigned long opt;
692 llist_t *excludes; 693
693 694#if defined(CONFIG_FEATURE_TAR_FROM)
695 llist_t *excludes = NULL;
696#endif
694 697
695 /* Initialise default values */ 698 /* Initialise default values */
696 tar_handle = init_handle(); 699 tar_handle = init_handle();
@@ -772,7 +775,7 @@ int tar_main(int argc, char **argv)
772#endif 775#endif
773 776
774 /* Check if we are reading from stdin */ 777 /* Check if we are reading from stdin */
775 if ((argv[optind]) && (*argv[optind] == '-')) { 778 if (argv[optind] && *argv[optind] == '-') {
776 /* Default is to read from stdin, so just skip to next arg */ 779 /* Default is to read from stdin, so just skip to next arg */
777 optind++; 780 optind++;
778 } 781 }
@@ -856,8 +859,8 @@ int tar_main(int argc, char **argv)
856 /* Ckeck that every file that should have been extracted was */ 859 /* Ckeck that every file that should have been extracted was */
857 while (tar_handle->accept) { 860 while (tar_handle->accept) {
858 if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) { 861 if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) {
859 if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) { 862 if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) {
860 bb_error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data); 863 bb_error_msg_and_die("%s: Not found in archive", tar_handle->accept->data);
861 } 864 }
862 } 865 }
863 tar_handle->accept = tar_handle->accept->link; 866 tar_handle->accept = tar_handle->accept->link;