aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorAlexander Shishkin <virtuoso@slind.org>2010-03-15 15:38:09 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-15 15:38:09 +0100
commit535584c750820dd6c36011697f9ef89fe0a0698c (patch)
tree6c682a7a6ca7d740529201c759fa4e64d9622797 /archival/libunarchive
parent814da220a5d451c036c9871094253366372676e0 (diff)
downloadbusybox-w32-535584c750820dd6c36011697f9ef89fe0a0698c.tar.gz
busybox-w32-535584c750820dd6c36011697f9ef89fe0a0698c.tar.bz2
busybox-w32-535584c750820dd6c36011697f9ef89fe0a0698c.zip
ar: add archive creation support
function old new delta ar_main 184 542 +358 output_ar_header - 166 +166 copy_data - 54 +54 filter_replaceable - 19 +19 get_header_ar 409 414 +5 header_verbose_list_ar 85 88 +3 static.msg_unsupported_err 28 - -28 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 3/0 up/down: 605/-28) Total: 577 bytes Signed-off-by: Alexander Shishkin <virtuoso@slind.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/get_header_ar.c13
-rw-r--r--archival/libunarchive/unpack_ar_archive.c7
2 files changed, 7 insertions, 13 deletions
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index 2f38279cc..dbc5ec004 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -6,6 +6,7 @@
6 6
7#include "libbb.h" 7#include "libbb.h"
8#include "unarchive.h" 8#include "unarchive.h"
9#include "ar.h"
9 10
10static unsigned read_num(const char *str, int base) 11static unsigned read_num(const char *str, int base)
11{ 12{
@@ -23,15 +24,7 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
23 unsigned size; 24 unsigned size;
24 union { 25 union {
25 char raw[60]; 26 char raw[60];
26 struct { 27 struct ar_header formatted;
27 char name[16];
28 char date[12];
29 char uid[6];
30 char gid[6];
31 char mode[8];
32 char size[10];
33 char magic[2];
34 } formatted;
35 } ar; 28 } ar;
36#if ENABLE_FEATURE_AR_LONG_FILENAMES 29#if ENABLE_FEATURE_AR_LONG_FILENAMES
37 static char *ar_long_names; 30 static char *ar_long_names;
@@ -55,13 +48,13 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
55 } 48 }
56 archive_handle->offset += 60; 49 archive_handle->offset += 60;
57 50
58 /* align the headers based on the header magic */
59 if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n') 51 if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
60 bb_error_msg_and_die("invalid ar header"); 52 bb_error_msg_and_die("invalid ar header");
61 53
62 /* FIXME: more thorough routine would be in order here 54 /* FIXME: more thorough routine would be in order here
63 * (we have something like that in tar) 55 * (we have something like that in tar)
64 * but for now we are lax. */ 56 * but for now we are lax. */
57 ar.formatted.magic[0] = '\0'; /* else 4G-2 file will have size="4294967294`\n..." */
65 typed->size = size = read_num(ar.formatted.size, 10); 58 typed->size = size = read_num(ar.formatted.size, 10);
66 59
67 /* special filenames have '/' as the first character */ 60 /* special filenames have '/' as the first character */
diff --git a/archival/libunarchive/unpack_ar_archive.c b/archival/libunarchive/unpack_ar_archive.c
index dc2eec223..300d10e48 100644
--- a/archival/libunarchive/unpack_ar_archive.c
+++ b/archival/libunarchive/unpack_ar_archive.c
@@ -5,16 +5,17 @@
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "unarchive.h" 7#include "unarchive.h"
8#include "ar.h"
8 9
9void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive) 10void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
10{ 11{
11 char magic[7]; 12 char magic[7];
12 13
13 xread(ar_archive->src_fd, magic, 7); 14 xread(ar_archive->src_fd, magic, AR_MAGIC_LEN);
14 if (strncmp(magic, "!<arch>", 7) != 0) { 15 if (strncmp(magic, AR_MAGIC, AR_MAGIC_LEN) != 0) {
15 bb_error_msg_and_die("invalid ar magic"); 16 bb_error_msg_and_die("invalid ar magic");
16 } 17 }
17 ar_archive->offset += 7; 18 ar_archive->offset += AR_MAGIC_LEN;
18 19
19 while (get_header_ar(ar_archive) == EXIT_SUCCESS) 20 while (get_header_ar(ar_archive) == EXIT_SUCCESS)
20 continue; 21 continue;