diff options
Diffstat (limited to 'include/bb_archive.h')
-rw-r--r-- | include/bb_archive.h | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/include/bb_archive.h b/include/bb_archive.h index 9e176d335..2043d8570 100644 --- a/include/bb_archive.h +++ b/include/bb_archive.h | |||
@@ -12,9 +12,10 @@ enum { | |||
12 | /* .xz signature: 0xfd, '7', 'z', 'X', 'Z', 0x00 */ | 12 | /* .xz signature: 0xfd, '7', 'z', 'X', 'Z', 0x00 */ |
13 | /* More info at: http://tukaani.org/xz/xz-file-format.txt */ | 13 | /* More info at: http://tukaani.org/xz/xz-file-format.txt */ |
14 | XZ_MAGIC1 = 256 * 0xfd + '7', | 14 | XZ_MAGIC1 = 256 * 0xfd + '7', |
15 | XZ_MAGIC2 = 256 * (256 * (256 * 'z' + 'X') + 'Z') + 0, | 15 | XZ_MAGIC2 = 256 * (unsigned)(256 * (256 * 'z' + 'X') + 'Z') + 0, |
16 | /* Different form: 32 bits, then 16 bits: */ | 16 | /* Different form: 32 bits, then 16 bits: */ |
17 | XZ_MAGIC1a = 256 * (256 * (256 * 0xfd + '7') + 'z') + 'X', | 17 | /* (unsigned) cast suppresses "integer overflow in expression" warning */ |
18 | XZ_MAGIC1a = 256 * (unsigned)(256 * (256 * 0xfd + '7') + 'z') + 'X', | ||
18 | XZ_MAGIC2a = 256 * 'Z' + 0, | 19 | XZ_MAGIC2a = 256 * 'Z' + 0, |
19 | #else | 20 | #else |
20 | COMPRESS_MAGIC = 0x9d1f, | 21 | COMPRESS_MAGIC = 0x9d1f, |
@@ -76,19 +77,20 @@ typedef struct archive_handle_t { | |||
76 | off_t offset; | 77 | off_t offset; |
77 | 78 | ||
78 | /* Archiver specific. Can make it a union if it ever gets big */ | 79 | /* Archiver specific. Can make it a union if it ever gets big */ |
80 | #define PAX_NEXT_FILE 0 | ||
81 | #define PAX_GLOBAL 1 | ||
79 | #if ENABLE_TAR || ENABLE_DPKG || ENABLE_DPKG_DEB | 82 | #if ENABLE_TAR || ENABLE_DPKG || ENABLE_DPKG_DEB |
80 | smallint tar__end; | 83 | smallint tar__end; |
81 | # if ENABLE_FEATURE_TAR_GNU_EXTENSIONS | 84 | # if ENABLE_FEATURE_TAR_GNU_EXTENSIONS |
82 | char* tar__longname; | 85 | char* tar__longname; |
83 | char* tar__linkname; | 86 | char* tar__linkname; |
84 | # endif | 87 | # endif |
85 | #if ENABLE_FEATURE_TAR_TO_COMMAND | 88 | # if ENABLE_FEATURE_TAR_TO_COMMAND |
86 | char* tar__to_command; | 89 | char* tar__to_command; |
87 | const char* tar__to_command_shell; | 90 | const char* tar__to_command_shell; |
88 | #endif | 91 | # endif |
89 | # if ENABLE_FEATURE_TAR_SELINUX | 92 | # if ENABLE_FEATURE_TAR_SELINUX |
90 | char* tar__global_sctx; | 93 | char* tar__sctx[2]; |
91 | char* tar__next_file_sctx; | ||
92 | # endif | 94 | # endif |
93 | #endif | 95 | #endif |
94 | #if ENABLE_CPIO || ENABLE_RPM2CPIO || ENABLE_RPM | 96 | #if ENABLE_CPIO || ENABLE_RPM2CPIO || ENABLE_RPM |
@@ -154,12 +156,6 @@ struct BUG_tar_header { | |||
154 | 156 | ||
155 | 157 | ||
156 | 158 | ||
157 | /* Info struct unpackers can fill out to inform users of thing like | ||
158 | * timestamps of unpacked files */ | ||
159 | typedef struct unpack_info_t { | ||
160 | time_t mtime; | ||
161 | } unpack_info_t; | ||
162 | |||
163 | archive_handle_t *init_handle(void) FAST_FUNC; | 159 | archive_handle_t *init_handle(void) FAST_FUNC; |
164 | 160 | ||
165 | char filter_accept_all(archive_handle_t *archive_handle) FAST_FUNC; | 161 | char filter_accept_all(archive_handle_t *archive_handle) FAST_FUNC; |
@@ -202,40 +198,47 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const void *inbuf, int len) FAST_ | |||
202 | int read_bunzip(bunzip_data *bd, char *outbuf, int len) FAST_FUNC; | 198 | int read_bunzip(bunzip_data *bd, char *outbuf, int len) FAST_FUNC; |
203 | void dealloc_bunzip(bunzip_data *bd) FAST_FUNC; | 199 | void dealloc_bunzip(bunzip_data *bd) FAST_FUNC; |
204 | 200 | ||
205 | typedef struct inflate_unzip_result { | 201 | /* Meaning and direction (input/output) of the fields are transformer-specific */ |
206 | off_t bytes_out; | 202 | typedef struct transformer_aux_data_t { |
207 | uint32_t crc; | 203 | smallint check_signature; /* most often referenced member */ |
208 | } inflate_unzip_result; | 204 | off_t bytes_out; |
209 | 205 | off_t bytes_in; /* used in unzip code only: needs to know packed size */ | |
210 | IF_DESKTOP(long long) int inflate_unzip(inflate_unzip_result *res, off_t compr_size, int src_fd, int dst_fd) FAST_FUNC; | 206 | uint32_t crc32; |
211 | /* xz unpacker takes .xz stream from offset 6 */ | 207 | time_t mtime; /* gunzip code may set this on exit */ |
212 | IF_DESKTOP(long long) int unpack_xz_stream(int src_fd, int dst_fd) FAST_FUNC; | 208 | } transformer_aux_data_t; |
213 | /* lzma unpacker takes .lzma stream from offset 0 */ | 209 | |
214 | IF_DESKTOP(long long) int unpack_lzma_stream(int src_fd, int dst_fd) FAST_FUNC; | 210 | void init_transformer_aux_data(transformer_aux_data_t *aux) FAST_FUNC; |
215 | /* the rest wants 2 first bytes already skipped by the caller */ | 211 | int FAST_FUNC check_signature16(transformer_aux_data_t *aux, int src_fd, unsigned magic16) FAST_FUNC; |
216 | IF_DESKTOP(long long) int unpack_bz2_stream(int src_fd, int dst_fd) FAST_FUNC; | 212 | |
217 | IF_DESKTOP(long long) int unpack_gz_stream(int src_fd, int dst_fd) FAST_FUNC; | 213 | IF_DESKTOP(long long) int inflate_unzip(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; |
218 | IF_DESKTOP(long long) int unpack_gz_stream_with_info(int src_fd, int dst_fd, unpack_info_t *info) FAST_FUNC; | 214 | IF_DESKTOP(long long) int unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; |
219 | IF_DESKTOP(long long) int unpack_Z_stream(int src_fd, int dst_fd) FAST_FUNC; | 215 | IF_DESKTOP(long long) int unpack_gz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; |
220 | /* wrapper which checks first two bytes to be "BZ" */ | 216 | IF_DESKTOP(long long) int unpack_bz2_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; |
221 | IF_DESKTOP(long long) int unpack_bz2_stream_prime(int src_fd, int dst_fd) FAST_FUNC; | 217 | IF_DESKTOP(long long) int unpack_lzma_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; |
218 | IF_DESKTOP(long long) int unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; | ||
222 | 219 | ||
223 | char* append_ext(char *filename, const char *expected_ext) FAST_FUNC; | 220 | char* append_ext(char *filename, const char *expected_ext) FAST_FUNC; |
224 | int bbunpack(char **argv, | 221 | int bbunpack(char **argv, |
225 | IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(unpack_info_t *info), | 222 | IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux), |
226 | char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), | 223 | char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), |
227 | const char *expected_ext | 224 | const char *expected_ext |
228 | ) FAST_FUNC; | 225 | ) FAST_FUNC; |
229 | 226 | ||
227 | void check_errors_in_children(int signo); | ||
230 | #if BB_MMU | 228 | #if BB_MMU |
231 | void open_transformer(int fd, | 229 | void open_transformer(int fd, |
232 | IF_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd)) FAST_FUNC; | 230 | int check_signature, |
233 | #define open_transformer(fd, transformer, transform_prog) open_transformer(fd, transformer) | 231 | IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_aux_data_t *aux, int src_fd, int dst_fd) |
232 | ) FAST_FUNC; | ||
233 | #define open_transformer_with_sig(fd, transformer, transform_prog) open_transformer((fd), 1, (transformer)) | ||
234 | #define open_transformer_with_no_sig(fd, transformer) open_transformer((fd), 0, (transformer)) | ||
234 | #else | 235 | #else |
235 | void open_transformer(int src_fd, const char *transform_prog) FAST_FUNC; | 236 | void open_transformer(int fd, const char *transform_prog) FAST_FUNC; |
236 | #define open_transformer(fd, transformer, transform_prog) open_transformer(fd, transform_prog) | 237 | #define open_transformer_with_sig(fd, transformer, transform_prog) open_transformer((fd), (transform_prog)) |
238 | /* open_transformer_with_no_sig() does not exist on NOMMU */ | ||
237 | #endif | 239 | #endif |
238 | 240 | ||
241 | |||
239 | POP_SAVED_FUNCTION_VISIBILITY | 242 | POP_SAVED_FUNCTION_VISIBILITY |
240 | 243 | ||
241 | #endif | 244 | #endif |