diff options
| author | Ron Yorston <rmy@pobox.com> | 2021-01-19 11:47:11 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2021-01-19 11:47:11 +0000 |
| commit | df81ab878f0b8124f3ead12d8299abec6ce5fac3 (patch) | |
| tree | 72ec1a8bcb405cf48099b9d2d9a71f7fc6090d49 | |
| parent | 12e14ebba6b6fe111829cac357b48154e769d778 (diff) | |
| download | busybox-w32-df81ab878f0b8124f3ead12d8299abec6ce5fac3.tar.gz busybox-w32-df81ab878f0b8124f3ead12d8299abec6ce5fac3.tar.bz2 busybox-w32-df81ab878f0b8124f3ead12d8299abec6ce5fac3.zip | |
libarchive: allow extraction of hard links
Allow create_or_remember_link() to create hardlinks.
As a result tar and cpio can now extract hard links. Since unzip
only supports symlinks it sees no improvement. As before, attempts
to extract symlinks result in a warning.
| -rw-r--r-- | archival/libarchive/unsafe_symlink_target.c | 10 | ||||
| -rw-r--r-- | archival/unzip.c | 5 | ||||
| -rw-r--r-- | include/bb_archive.h | 7 |
3 files changed, 8 insertions, 14 deletions
diff --git a/archival/libarchive/unsafe_symlink_target.c b/archival/libarchive/unsafe_symlink_target.c index ff96991f5..b5f5a2670 100644 --- a/archival/libarchive/unsafe_symlink_target.c +++ b/archival/libarchive/unsafe_symlink_target.c | |||
| @@ -24,12 +24,17 @@ void FAST_FUNC create_or_remember_link(llist_t **link_placeholders, | |||
| 24 | ); | 24 | ); |
| 25 | } | 25 | } |
| 26 | #else | 26 | #else |
| 27 | if (hard_link) { | ||
| 28 | llist_add_to_end(link_placeholders, | ||
| 29 | xasprintf("%c%s%c%s", hard_link, linkname, '\0', target) | ||
| 30 | ); | ||
| 31 | return; | ||
| 32 | } | ||
| 27 | /* symlink isn't implemented for WIN32, just issue a warning */ | 33 | /* symlink isn't implemented for WIN32, just issue a warning */ |
| 28 | bb_perror_msg("can't create %slink '%s' to '%s'", "sym", linkname, target); | 34 | bb_perror_msg("can't create symlink '%s' to '%s'", linkname, target); |
| 29 | #endif | 35 | #endif |
| 30 | } | 36 | } |
| 31 | 37 | ||
| 32 | #if !ENABLE_PLATFORM_MINGW32 | ||
| 33 | void FAST_FUNC create_links_from_list(llist_t *list) | 38 | void FAST_FUNC create_links_from_list(llist_t *list) |
| 34 | { | 39 | { |
| 35 | while (list) { | 40 | while (list) { |
| @@ -46,4 +51,3 @@ void FAST_FUNC create_links_from_list(llist_t *list) | |||
| 46 | list = list->link; | 51 | list = list->link; |
| 47 | } | 52 | } |
| 48 | } | 53 | } |
| 49 | #endif | ||
diff --git a/archival/unzip.c b/archival/unzip.c index 67593d4ed..19353c708 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
| @@ -348,9 +348,6 @@ static void unzip_create_leading_dirs(const char *fn) | |||
| 348 | } | 348 | } |
| 349 | 349 | ||
| 350 | #if ENABLE_FEATURE_UNZIP_CDF | 350 | #if ENABLE_FEATURE_UNZIP_CDF |
| 351 | #if ENABLE_PLATFORM_MINGW32 | ||
| 352 | #define unzip_extract_symlink(s, z, d) unzip_extract_symlink(z, d) | ||
| 353 | #endif | ||
| 354 | static void unzip_extract_symlink(llist_t **symlink_placeholders, | 351 | static void unzip_extract_symlink(llist_t **symlink_placeholders, |
| 355 | zip_header_t *zip, | 352 | zip_header_t *zip, |
| 356 | const char *dst_fn) | 353 | const char *dst_fn) |
| @@ -495,7 +492,7 @@ int unzip_main(int argc, char **argv) | |||
| 495 | llist_t *zaccept = NULL; | 492 | llist_t *zaccept = NULL; |
| 496 | llist_t *zreject = NULL; | 493 | llist_t *zreject = NULL; |
| 497 | char *base_dir = NULL; | 494 | char *base_dir = NULL; |
| 498 | #if ENABLE_FEATURE_UNZIP_CDF && !ENABLE_PLATFORM_MINGW32 | 495 | #if ENABLE_FEATURE_UNZIP_CDF |
| 499 | llist_t *symlink_placeholders = NULL; | 496 | llist_t *symlink_placeholders = NULL; |
| 500 | #endif | 497 | #endif |
| 501 | int i; | 498 | int i; |
diff --git a/include/bb_archive.h b/include/bb_archive.h index 58e4c21bb..892c8a472 100644 --- a/include/bb_archive.h +++ b/include/bb_archive.h | |||
| @@ -213,18 +213,11 @@ void seek_by_jump(int fd, off_t amount) FAST_FUNC; | |||
| 213 | void seek_by_read(int fd, off_t amount) FAST_FUNC; | 213 | void seek_by_read(int fd, off_t amount) FAST_FUNC; |
| 214 | 214 | ||
| 215 | const char *strip_unsafe_prefix(const char *str) FAST_FUNC; | 215 | const char *strip_unsafe_prefix(const char *str) FAST_FUNC; |
| 216 | #if ENABLE_PLATFORM_MINGW32 | ||
| 217 | #define create_or_remember_link(lp, t, ln, hl) create_or_remember_link(t, ln) | ||
| 218 | #endif | ||
| 219 | void create_or_remember_link(llist_t **link_placeholders, | 216 | void create_or_remember_link(llist_t **link_placeholders, |
| 220 | const char *target, | 217 | const char *target, |
| 221 | const char *linkname, | 218 | const char *linkname, |
| 222 | int hard_link) FAST_FUNC; | 219 | int hard_link) FAST_FUNC; |
| 223 | #if !ENABLE_PLATFORM_MINGW32 | ||
| 224 | void create_links_from_list(llist_t *list) FAST_FUNC; | 220 | void create_links_from_list(llist_t *list) FAST_FUNC; |
| 225 | #else | ||
| 226 | #define create_links_from_list(l) (void)0 | ||
| 227 | #endif | ||
| 228 | 221 | ||
| 229 | void data_align(archive_handle_t *archive_handle, unsigned boundary) FAST_FUNC; | 222 | void data_align(archive_handle_t *archive_handle, unsigned boundary) FAST_FUNC; |
| 230 | const llist_t *find_list_entry(const llist_t *list, const char *filename) FAST_FUNC; | 223 | const llist_t *find_list_entry(const llist_t *list, const char *filename) FAST_FUNC; |
