diff options
author | Ron Yorston <rmy@pobox.com> | 2017-08-22 14:56:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-08-22 14:56:12 +0100 |
commit | ce9af1cc5ea23f754587448cf35b5120c77bfeef (patch) | |
tree | 69e5eaba5e75ab909ed92d5045393471b8ff3c13 /archival/tar.c | |
parent | c170026700eabb10147dd848c45c06995b43a32e (diff) | |
parent | e837a0dbbebf4229306df98fe9ee3b9bb30630c4 (diff) | |
download | busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.gz busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.bz2 busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/archival/tar.c b/archival/tar.c index d90a5dc4f..503444796 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -278,23 +278,6 @@ static void chksum_and_xwrite(int fd, struct tar_header_t* hp) | |||
278 | xwrite(fd, hp, sizeof(*hp)); | 278 | xwrite(fd, hp, sizeof(*hp)); |
279 | } | 279 | } |
280 | 280 | ||
281 | static void replace_symlink_placeholders(llist_t *list) | ||
282 | { | ||
283 | while (list) { | ||
284 | char *target; | ||
285 | |||
286 | target = list->data + strlen(list->data) + 1; | ||
287 | if (symlink(target, list->data)) { | ||
288 | /* shared message */ | ||
289 | bb_error_msg_and_die("can't create %slink '%s' to '%s'", | ||
290 | "sym", | ||
291 | list->data, target | ||
292 | ); | ||
293 | } | ||
294 | list = list->link; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | #if ENABLE_FEATURE_TAR_GNU_EXTENSIONS | 281 | #if ENABLE_FEATURE_TAR_GNU_EXTENSIONS |
299 | static void writeLongname(int fd, int type, const char *name, int dir) | 282 | static void writeLongname(int fd, int type, const char *name, int dir) |
300 | { | 283 | { |
@@ -969,6 +952,11 @@ static const char tar_longopts[] ALIGN1 = | |||
969 | "exclude\0" Required_argument "\xff" | 952 | "exclude\0" Required_argument "\xff" |
970 | # endif | 953 | # endif |
971 | ; | 954 | ; |
955 | # define GETOPT32 getopt32long | ||
956 | # define LONGOPTS ,tar_longopts | ||
957 | #else | ||
958 | # define GETOPT32 getopt32 | ||
959 | # define LONGOPTS | ||
972 | #endif | 960 | #endif |
973 | 961 | ||
974 | int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 962 | int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
@@ -995,21 +983,8 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
995 | tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; | 983 | tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; |
996 | 984 | ||
997 | /* Prepend '-' to the first argument if required */ | 985 | /* Prepend '-' to the first argument if required */ |
998 | opt_complementary = "--:" // first arg is options | 986 | if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0') |
999 | "tt:vv:" // count -t,-v | 987 | argv[1] = xasprintf("-%s", argv[1]); |
1000 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM | ||
1001 | "\xff::" // --exclude=PATTERN is a list | ||
1002 | #endif | ||
1003 | IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd | ||
1004 | IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive | ||
1005 | IF_NOT_FEATURE_TAR_CREATE("t--x:x--t") // mutually exclusive | ||
1006 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | ||
1007 | ":\xf9+" // --strip-components=NUM | ||
1008 | #endif | ||
1009 | ; | ||
1010 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | ||
1011 | applet_long_options = tar_longopts; | ||
1012 | #endif | ||
1013 | #if ENABLE_DESKTOP | 988 | #if ENABLE_DESKTOP |
1014 | /* Lie to buildroot when it starts asking stupid questions. */ | 989 | /* Lie to buildroot when it starts asking stupid questions. */ |
1015 | if (argv[1] && strcmp(argv[1], "--version") == 0) { | 990 | if (argv[1] && strcmp(argv[1], "--version") == 0) { |
@@ -1046,7 +1021,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1046 | } | 1021 | } |
1047 | } | 1022 | } |
1048 | #endif | 1023 | #endif |
1049 | opt = getopt32(argv, | 1024 | opt = GETOPT32(argv, "^" |
1050 | "txC:f:Oopvk" | 1025 | "txC:f:Oopvk" |
1051 | IF_FEATURE_TAR_CREATE( "ch" ) | 1026 | IF_FEATURE_TAR_CREATE( "ch" ) |
1052 | IF_FEATURE_SEAMLESS_BZ2( "j" ) | 1027 | IF_FEATURE_SEAMLESS_BZ2( "j" ) |
@@ -1057,6 +1032,18 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1057 | IF_FEATURE_SEAMLESS_Z( "Z" ) | 1032 | IF_FEATURE_SEAMLESS_Z( "Z" ) |
1058 | IF_FEATURE_TAR_NOPRESERVE_TIME("m") | 1033 | IF_FEATURE_TAR_NOPRESERVE_TIME("m") |
1059 | IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components | 1034 | IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components |
1035 | "\0" | ||
1036 | "tt:vv:" // count -t,-v | ||
1037 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM | ||
1038 | "\xff::" // --exclude=PATTERN is a list | ||
1039 | #endif | ||
1040 | IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd | ||
1041 | IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive | ||
1042 | IF_NOT_FEATURE_TAR_CREATE("t--x:x--t") // mutually exclusive | ||
1043 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | ||
1044 | ":\xf9+" // --strip-components=NUM | ||
1045 | #endif | ||
1046 | LONGOPTS | ||
1060 | , &base_dir // -C dir | 1047 | , &base_dir // -C dir |
1061 | , &tar_filename // -f filename | 1048 | , &tar_filename // -f filename |
1062 | IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T | 1049 | IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T |
@@ -1280,8 +1267,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1280 | while (get_header_tar(tar_handle) == EXIT_SUCCESS) | 1267 | while (get_header_tar(tar_handle) == EXIT_SUCCESS) |
1281 | bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */ | 1268 | bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */ |
1282 | 1269 | ||
1283 | replace_symlink_placeholders(tar_handle->symlink_placeholders); | ||
1284 | |||
1285 | /* Check that every file that should have been extracted was */ | 1270 | /* Check that every file that should have been extracted was */ |
1286 | while (tar_handle->accept) { | 1271 | while (tar_handle->accept) { |
1287 | if (!find_list_entry(tar_handle->reject, tar_handle->accept->data) | 1272 | if (!find_list_entry(tar_handle->reject, tar_handle->accept->data) |