diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/tar.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/archival/tar.c b/archival/tar.c index 2ba51adf7..ca59643e5 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -23,10 +23,10 @@ | |||
23 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 23 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "busybox.h" | ||
27 | #include "unarchive.h" | ||
28 | #include <fnmatch.h> | 26 | #include <fnmatch.h> |
29 | #include <getopt.h> | 27 | #include <getopt.h> |
28 | #include "busybox.h" | ||
29 | #include "unarchive.h" | ||
30 | 30 | ||
31 | #if ENABLE_FEATURE_TAR_CREATE | 31 | #if ENABLE_FEATURE_TAR_CREATE |
32 | 32 | ||
@@ -37,6 +37,7 @@ | |||
37 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ | 37 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ |
38 | #define NAME_SIZE 100 | 38 | #define NAME_SIZE 100 |
39 | #define NAME_SIZE_STR "100" | 39 | #define NAME_SIZE_STR "100" |
40 | typedef struct TarHeader TarHeader; | ||
40 | struct TarHeader { /* byte offset */ | 41 | struct TarHeader { /* byte offset */ |
41 | char name[NAME_SIZE]; /* 0-99 */ | 42 | char name[NAME_SIZE]; /* 0-99 */ |
42 | char mode[8]; /* 100-107 */ | 43 | char mode[8]; /* 100-107 */ |
@@ -56,7 +57,6 @@ struct TarHeader { /* byte offset */ | |||
56 | char prefix[155]; /* 345-499 */ | 57 | char prefix[155]; /* 345-499 */ |
57 | char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */ | 58 | char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */ |
58 | }; | 59 | }; |
59 | typedef struct TarHeader TarHeader; | ||
60 | 60 | ||
61 | /* | 61 | /* |
62 | ** writeTarFile(), writeFileToTarball(), and writeTarHeader() are | 62 | ** writeTarFile(), writeFileToTarball(), and writeTarHeader() are |
@@ -73,6 +73,7 @@ struct HardLinkInfo { | |||
73 | }; | 73 | }; |
74 | 74 | ||
75 | /* Some info to be carried along when creating a new tarball */ | 75 | /* Some info to be carried along when creating a new tarball */ |
76 | typedef struct TarBallInfo TarBallInfo; | ||
76 | struct TarBallInfo { | 77 | struct TarBallInfo { |
77 | int tarFd; /* Open-for-write file descriptor | 78 | int tarFd; /* Open-for-write file descriptor |
78 | for the tarball */ | 79 | for the tarball */ |
@@ -85,7 +86,6 @@ struct TarBallInfo { | |||
85 | HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */ | 86 | HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */ |
86 | HardLinkInfo *hlInfo; /* Hard Link Info for the current file */ | 87 | HardLinkInfo *hlInfo; /* Hard Link Info for the current file */ |
87 | }; | 88 | }; |
88 | typedef struct TarBallInfo TarBallInfo; | ||
89 | 89 | ||
90 | /* A nice enum with all the possible tar file content types */ | 90 | /* A nice enum with all the possible tar file content types */ |
91 | enum TarFileType { | 91 | enum TarFileType { |
@@ -348,7 +348,7 @@ static int writeTarHeader(struct TarBallInfo *tbInfo, | |||
348 | return TRUE; | 348 | return TRUE; |
349 | } | 349 | } |
350 | 350 | ||
351 | # if ENABLE_FEATURE_TAR_FROM | 351 | #if ENABLE_FEATURE_TAR_FROM |
352 | static int exclude_file(const llist_t *excluded_files, const char *file) | 352 | static int exclude_file(const llist_t *excluded_files, const char *file) |
353 | { | 353 | { |
354 | while (excluded_files) { | 354 | while (excluded_files) { |
@@ -371,12 +371,12 @@ static int exclude_file(const llist_t *excluded_files, const char *file) | |||
371 | 371 | ||
372 | return 0; | 372 | return 0; |
373 | } | 373 | } |
374 | # else | 374 | #else |
375 | #define exclude_file(excluded_files, file) 0 | 375 | #define exclude_file(excluded_files, file) 0 |
376 | # endif | 376 | #endif |
377 | 377 | ||
378 | static int writeFileToTarball(const char *fileName, struct stat *statbuf, | 378 | static int writeFileToTarball(const char *fileName, struct stat *statbuf, |
379 | void *userData, int depth) | 379 | void *userData, int depth ATTRIBUTE_UNUSED) |
380 | { | 380 | { |
381 | struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData; | 381 | struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData; |
382 | const char *header_name; | 382 | const char *header_name; |
@@ -509,14 +509,14 @@ static int writeTarFile(const int tar_fd, const int verboseFlag, | |||
509 | if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) | 509 | if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) |
510 | bb_perror_msg_and_die("pipe"); | 510 | bb_perror_msg_and_die("pipe"); |
511 | 511 | ||
512 | signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ | 512 | signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ |
513 | 513 | ||
514 | # if __GNUC__ | 514 | #if defined(__GNUC__) && __GNUC__ |
515 | /* Avoid vfork clobbering */ | 515 | /* Avoid vfork clobbering */ |
516 | (void) &include; | 516 | (void) &include; |
517 | (void) &errorFlag; | 517 | (void) &errorFlag; |
518 | (void) &zip_exec; | 518 | (void) &zip_exec; |
519 | # endif | 519 | #endif |
520 | 520 | ||
521 | gzipPid = vfork(); | 521 | gzipPid = vfork(); |
522 | 522 | ||
@@ -600,7 +600,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag, | |||
600 | int writeTarFile(const int tar_fd, const int verboseFlag, | 600 | int writeTarFile(const int tar_fd, const int verboseFlag, |
601 | const unsigned long dereferenceFlag, const llist_t *include, | 601 | const unsigned long dereferenceFlag, const llist_t *include, |
602 | const llist_t *exclude, const int gzip); | 602 | const llist_t *exclude, const int gzip); |
603 | #endif /* tar_create */ | 603 | #endif /* FEATURE_TAR_CREATE */ |
604 | 604 | ||
605 | #if ENABLE_FEATURE_TAR_FROM | 605 | #if ENABLE_FEATURE_TAR_FROM |
606 | static llist_t *append_file_list_to_list(llist_t *list) | 606 | static llist_t *append_file_list_to_list(llist_t *list) |
@@ -628,7 +628,7 @@ static llist_t *append_file_list_to_list(llist_t *list) | |||
628 | return newlist; | 628 | return newlist; |
629 | } | 629 | } |
630 | #else | 630 | #else |
631 | #define append_file_list_to_list(x) 0 | 631 | #define append_file_list_to_list(x) 0 |
632 | #endif | 632 | #endif |
633 | 633 | ||
634 | #if ENABLE_FEATURE_TAR_COMPRESS | 634 | #if ENABLE_FEATURE_TAR_COMPRESS |
@@ -653,7 +653,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle) | |||
653 | return EXIT_FAILURE; | 653 | return EXIT_FAILURE; |
654 | } | 654 | } |
655 | #else | 655 | #else |
656 | #define get_header_tar_Z 0 | 656 | #define get_header_tar_Z NULL |
657 | #endif | 657 | #endif |
658 | 658 | ||
659 | #ifdef CHECK_FOR_CHILD_EXITCODE | 659 | #ifdef CHECK_FOR_CHILD_EXITCODE |