diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/libunarchive/data_extract_all.c | 50 | ||||
-rw-r--r-- | archival/libunarchive/get_header_cpio.c | 12 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar.c | 12 | ||||
-rw-r--r-- | archival/libunarchive/header_verbose_list.c | 4 |
4 files changed, 41 insertions, 37 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 0bb5bfe33..76e7edf24 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
@@ -25,7 +25,8 @@ void data_extract_all(archive_handle_t *archive_handle) | |||
25 | && (unlink(file_header->name) == -1) | 25 | && (unlink(file_header->name) == -1) |
26 | && (errno != ENOENT) | 26 | && (errno != ENOENT) |
27 | ) { | 27 | ) { |
28 | bb_perror_msg_and_die("cannot remove old file"); | 28 | bb_perror_msg_and_die("cannot remove old file %s", |
29 | file_header->name); | ||
29 | } | 30 | } |
30 | } | 31 | } |
31 | else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) { | 32 | else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) { |
@@ -52,13 +53,16 @@ void data_extract_all(archive_handle_t *archive_handle) | |||
52 | 53 | ||
53 | /* Handle hard links separately | 54 | /* Handle hard links separately |
54 | * We identified hard links as regular files of size 0 with a symlink */ | 55 | * We identified hard links as regular files of size 0 with a symlink */ |
55 | if (S_ISREG(file_header->mode) && (file_header->link_name) | 56 | if (S_ISREG(file_header->mode) && (file_header->link_target) |
56 | && (file_header->size == 0) | 57 | && (file_header->size == 0) |
57 | ) { | 58 | ) { |
58 | /* hard link */ | 59 | /* hard link */ |
59 | res = link(file_header->link_name, file_header->name); | 60 | res = link(file_header->link_target, file_header->name); |
60 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { | 61 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { |
61 | bb_perror_msg("cannot create hard link"); | 62 | bb_perror_msg("cannot create %slink " |
63 | "from %s to %s", "hard", | ||
64 | file_header->name, | ||
65 | file_header->link_target); | ||
62 | } | 66 | } |
63 | } else { | 67 | } else { |
64 | /* Create the filesystem entry */ | 68 | /* Create the filesystem entry */ |
@@ -73,22 +77,22 @@ void data_extract_all(archive_handle_t *archive_handle) | |||
73 | } | 77 | } |
74 | case S_IFDIR: | 78 | case S_IFDIR: |
75 | res = mkdir(file_header->name, file_header->mode); | 79 | res = mkdir(file_header->name, file_header->mode); |
76 | if ((errno != EISDIR) && (res == -1) | 80 | if ((res == -1) && (errno != EISDIR) |
77 | && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) | 81 | && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) |
78 | ) { | 82 | ) { |
79 | bb_perror_msg("extract_archive: %s", file_header->name); | 83 | bb_perror_msg("cannot make dir %s", file_header->name); |
80 | } | 84 | } |
81 | break; | 85 | break; |
82 | case S_IFLNK: | 86 | case S_IFLNK: |
83 | /* Symlink */ | 87 | /* Symlink */ |
84 | res = symlink(file_header->link_name, file_header->name); | 88 | res = symlink(file_header->link_target, file_header->name); |
85 | if ((res == -1) | 89 | if ((res == -1) |
86 | && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) | 90 | && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) |
87 | ) { | 91 | ) { |
88 | bb_perror_msg("cannot create symlink " | 92 | bb_perror_msg("cannot create %slink " |
89 | "from %s to '%s'", | 93 | "from %s to %s", "sym", |
90 | file_header->name, | 94 | file_header->name, |
91 | file_header->link_name); | 95 | file_header->link_target); |
92 | } | 96 | } |
93 | break; | 97 | break; |
94 | case S_IFSOCK: | 98 | case S_IFSOCK: |
@@ -110,18 +114,18 @@ void data_extract_all(archive_handle_t *archive_handle) | |||
110 | if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) { | 114 | if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) { |
111 | lchown(file_header->name, file_header->uid, file_header->gid); | 115 | lchown(file_header->name, file_header->uid, file_header->gid); |
112 | } | 116 | } |
113 | /* uclibc has no lchmod, glibc is even stranger - | 117 | if ((file_header->mode & S_IFMT) != S_IFLNK) { |
114 | * it has lchmod which seems to do nothing! | 118 | /* uclibc has no lchmod, glibc is even stranger - |
115 | * so we use chmod... */ | 119 | * it has lchmod which seems to do nothing! |
116 | if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM) | 120 | * so we use chmod... */ |
117 | && (file_header->mode & S_IFMT) != S_IFLNK | 121 | if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM)) { |
118 | ) { | 122 | chmod(file_header->name, file_header->mode); |
119 | chmod(file_header->name, file_header->mode); | 123 | } |
120 | } | 124 | /* same for utime */ |
121 | 125 | if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) { | |
122 | if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) { | 126 | struct utimbuf t; |
123 | struct utimbuf t; | 127 | t.actime = t.modtime = file_header->mtime; |
124 | t.actime = t.modtime = file_header->mtime; | 128 | utime(file_header->name, &t); |
125 | utime(file_header->name, &t); | 129 | } |
126 | } | 130 | } |
127 | } | 131 | } |
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c index 6fd134018..724368be2 100644 --- a/archival/libunarchive/get_header_cpio.c +++ b/archival/libunarchive/get_header_cpio.c | |||
@@ -30,7 +30,7 @@ char get_header_cpio(archive_handle_t *archive_handle) | |||
30 | tmp = saved_hardlinks; | 30 | tmp = saved_hardlinks; |
31 | oldtmp = NULL; | 31 | oldtmp = NULL; |
32 | 32 | ||
33 | file_header->link_name = file_header->name; | 33 | file_header->link_target = file_header->name; |
34 | file_header->size = 0; | 34 | file_header->size = 0; |
35 | 35 | ||
36 | while (tmp) { | 36 | while (tmp) { |
@@ -56,7 +56,7 @@ char get_header_cpio(archive_handle_t *archive_handle) | |||
56 | saved_hardlinks = tmp; | 56 | saved_hardlinks = tmp; |
57 | } | 57 | } |
58 | 58 | ||
59 | file_header->name = file_header->link_name; | 59 | file_header->name = file_header->link_target; |
60 | 60 | ||
61 | if (pending_hardlinks > 1) { | 61 | if (pending_hardlinks > 1) { |
62 | bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?"); | 62 | bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?"); |
@@ -122,12 +122,12 @@ char get_header_cpio(archive_handle_t *archive_handle) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | if (S_ISLNK(file_header->mode)) { | 124 | if (S_ISLNK(file_header->mode)) { |
125 | file_header->link_name = xzalloc(file_header->size + 1); | 125 | file_header->link_target = xzalloc(file_header->size + 1); |
126 | xread(archive_handle->src_fd, file_header->link_name, file_header->size); | 126 | xread(archive_handle->src_fd, file_header->link_target, file_header->size); |
127 | archive_handle->offset += file_header->size; | 127 | archive_handle->offset += file_header->size; |
128 | file_header->size = 0; /* Stop possible seeks in future */ | 128 | file_header->size = 0; /* Stop possible seeks in future */ |
129 | } else { | 129 | } else { |
130 | file_header->link_name = NULL; | 130 | file_header->link_target = NULL; |
131 | } | 131 | } |
132 | if (nlink > 1 && !S_ISDIR(file_header->mode)) { | 132 | if (nlink > 1 && !S_ISDIR(file_header->mode)) { |
133 | if (file_header->size == 0) { /* Put file on a linked list for later */ | 133 | if (file_header->size == 0) { /* Put file on a linked list for later */ |
@@ -154,7 +154,7 @@ char get_header_cpio(archive_handle_t *archive_handle) | |||
154 | 154 | ||
155 | archive_handle->offset += file_header->size; | 155 | archive_handle->offset += file_header->size; |
156 | 156 | ||
157 | free(file_header->link_name); | 157 | free(file_header->link_target); |
158 | 158 | ||
159 | return EXIT_SUCCESS; | 159 | return EXIT_SUCCESS; |
160 | } | 160 | } |
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index b3efdec94..d42f4c276 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c | |||
@@ -141,13 +141,13 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
141 | unsigned major = GET_OCTAL(tar.devmajor); | 141 | unsigned major = GET_OCTAL(tar.devmajor); |
142 | file_header->device = makedev(major, minor); | 142 | file_header->device = makedev(major, minor); |
143 | } | 143 | } |
144 | file_header->link_name = NULL; | 144 | file_header->link_target = NULL; |
145 | if (!linkname && parse_names && tar.linkname[0]) { | 145 | if (!linkname && parse_names && tar.linkname[0]) { |
146 | /* we trash magic[0] here, it's ok */ | 146 | /* we trash magic[0] here, it's ok */ |
147 | tar.linkname[sizeof(tar.linkname)] = '\0'; | 147 | tar.linkname[sizeof(tar.linkname)] = '\0'; |
148 | file_header->link_name = xstrdup(tar.linkname); | 148 | file_header->link_target = xstrdup(tar.linkname); |
149 | /* FIXME: what if we have non-link object with link_name? */ | 149 | /* FIXME: what if we have non-link object with link_target? */ |
150 | /* Will link_name be free()ed? */ | 150 | /* Will link_target be free()ed? */ |
151 | } | 151 | } |
152 | file_header->mtime = GET_OCTAL(tar.mtime); | 152 | file_header->mtime = GET_OCTAL(tar.mtime); |
153 | file_header->size = GET_OCTAL(tar.size); | 153 | file_header->size = GET_OCTAL(tar.size); |
@@ -248,7 +248,7 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
248 | longname = NULL; | 248 | longname = NULL; |
249 | } | 249 | } |
250 | if (linkname) { | 250 | if (linkname) { |
251 | file_header->link_name = linkname; | 251 | file_header->link_target = linkname; |
252 | linkname = NULL; | 252 | linkname = NULL; |
253 | } | 253 | } |
254 | #endif | 254 | #endif |
@@ -277,7 +277,7 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
277 | } | 277 | } |
278 | archive_handle->offset += file_header->size; | 278 | archive_handle->offset += file_header->size; |
279 | 279 | ||
280 | free(file_header->link_name); | 280 | free(file_header->link_target); |
281 | /* Do not free(file_header->name)! */ | 281 | /* Do not free(file_header->name)! */ |
282 | 282 | ||
283 | return EXIT_SUCCESS; | 283 | return EXIT_SUCCESS; |
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c index 7b97e524c..f3b0d8c5c 100644 --- a/archival/libunarchive/header_verbose_list.c +++ b/archival/libunarchive/header_verbose_list.c | |||
@@ -23,8 +23,8 @@ void header_verbose_list(const file_header_t *file_header) | |||
23 | mtime->tm_sec, | 23 | mtime->tm_sec, |
24 | file_header->name); | 24 | file_header->name); |
25 | 25 | ||
26 | if (file_header->link_name) { | 26 | if (file_header->link_target) { |
27 | printf(" -> %s", file_header->link_name); | 27 | printf(" -> %s", file_header->link_target); |
28 | } | 28 | } |
29 | /* putchar isnt used anywhere else i dont think */ | 29 | /* putchar isnt used anywhere else i dont think */ |
30 | puts(""); | 30 | puts(""); |