aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-26 18:21:36 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-26 18:21:36 +0200
commit52827e3ebcd80f634f990030ee697254a0ae517d (patch)
tree61cb4b3f65587301b1f2774a42c228d2f221d24e /archival/libunarchive
parentd0a8a0d31243f2ac798531ced2cca45ddf1fea42 (diff)
downloadbusybox-w32-52827e3ebcd80f634f990030ee697254a0ae517d.tar.gz
busybox-w32-52827e3ebcd80f634f990030ee697254a0ae517d.tar.bz2
busybox-w32-52827e3ebcd80f634f990030ee697254a0ae517d.zip
*: tar-related cleanups: move struct to unarchive.h; move help to tar.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/get_header_tar.c40
1 files changed, 8 insertions, 32 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index fcddcb834..01c10433e 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -118,34 +118,10 @@ static char *get_selinux_sctx_from_pax_hdr(archive_handle_t *archive_handle, uns
118} 118}
119#endif 119#endif
120 120
121void BUG_tar_header_size(void);
122char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) 121char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
123{ 122{
124 file_header_t *file_header = archive_handle->file_header; 123 file_header_t *file_header = archive_handle->file_header;
125 struct { 124 struct tar_header_t tar;
126 /* ustar header, Posix 1003.1 */
127 char name[100]; /* 0-99 */
128 char mode[8]; /* 100-107 */
129 char uid[8]; /* 108-115 */
130 char gid[8]; /* 116-123 */
131 char size[12]; /* 124-135 */
132 char mtime[12]; /* 136-147 */
133 char chksum[8]; /* 148-155 */
134 char typeflag; /* 156-156 */
135 char linkname[100]; /* 157-256 */
136 /* POSIX: "ustar" NUL "00" */
137 /* GNU tar: "ustar " NUL */
138 /* Normally it's defined as magic[6] followed by
139 * version[2], but we put them together to simplify code
140 */
141 char magic[8]; /* 257-264 */
142 char uname[32]; /* 265-296 */
143 char gname[32]; /* 297-328 */
144 char devmajor[8]; /* 329-336 */
145 char devminor[8]; /* 337-344 */
146 char prefix[155]; /* 345-499 */
147 char padding[12]; /* 500-512 */
148 } tar;
149 char *cp; 125 char *cp;
150 int i, sum_u, sum; 126 int i, sum_u, sum;
151#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY 127#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
@@ -162,9 +138,6 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
162# define p_linkname 0 138# define p_linkname 0
163#endif 139#endif
164 140
165 if (sizeof(tar) != 512)
166 BUG_tar_header_size();
167
168#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS || ENABLE_FEATURE_TAR_SELINUX 141#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS || ENABLE_FEATURE_TAR_SELINUX
169 again: 142 again:
170#endif 143#endif
@@ -230,18 +203,21 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
230 * we can switch to get_header_tar_gz/bz2/lzma(). 203 * we can switch to get_header_tar_gz/bz2/lzma().
231 * Needs seekable fd. I wish recv(MSG_PEEK) works 204 * Needs seekable fd. I wish recv(MSG_PEEK) works
232 * on any fd... */ 205 * on any fd... */
233#if ENABLE_FEATURE_SEAMLESS_GZ 206# if ENABLE_FEATURE_SEAMLESS_GZ
234 if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */ 207 if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
235 get_header_ptr = get_header_tar_gz; 208 get_header_ptr = get_header_tar_gz;
236 } else 209 } else
237#endif 210# endif
238#if ENABLE_FEATURE_SEAMLESS_BZ2 211# if ENABLE_FEATURE_SEAMLESS_BZ2
239 if (tar.name[0] == 'B' && tar.name[1] == 'Z' 212 if (tar.name[0] == 'B' && tar.name[1] == 'Z'
240 && tar.name[2] == 'h' && isdigit(tar.name[3]) 213 && tar.name[2] == 'h' && isdigit(tar.name[3])
241 ) { /* bzip2 */ 214 ) { /* bzip2 */
242 get_header_ptr = get_header_tar_bz2; 215 get_header_ptr = get_header_tar_bz2;
243 } else 216 } else
244#endif 217# endif
218# if ENABLE_FEATURE_SEAMLESS_XZ
219 //TODO
220# endif
245 goto err; 221 goto err;
246 /* Two different causes for lseek() != 0: 222 /* Two different causes for lseek() != 0:
247 * unseekable fd (would like to support that too, but...), 223 * unseekable fd (would like to support that too, but...),