diff options
author | mm <mm@FreeBSD.org> | 2011-07-17 21:33:15 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2011-07-17 21:33:15 +0000 |
commit | 867c8ddd4db0c581c7d6f04f5317cdc34c07dd5c (patch) | |
tree | 8e28f61596b4577fd91c1332f714c570089da33e /usr.bin/tar/bsdtar.c | |
parent | af1b78954b9a91ab8b481f90c8b8c3522f6ea0fa (diff) | |
download | FreeBSD-src-867c8ddd4db0c581c7d6f04f5317cdc34c07dd5c.zip FreeBSD-src-867c8ddd4db0c581c7d6f04f5317cdc34c07dd5c.tar.gz |
Update bsdtar to 2.8.4
Use common code from lib/libarchive/libarchive_fe
Approved by: kientzle
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/tar/bsdtar.c')
-rw-r--r-- | usr.bin/tar/bsdtar.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index 00c6f45..0bb6a7f 100644 --- a/usr.bin/tar/bsdtar.c +++ b/usr.bin/tar/bsdtar.c @@ -63,6 +63,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#if HAVE_ZLIB_H +#include <zlib.h> +#endif #include "bsdtar.h" #include "err.h" @@ -86,6 +89,8 @@ __FBSDID("$FreeBSD$"); int _CRT_glob = 0; /* Disable broken CRT globbing. */ #endif +static struct bsdtar *_bsdtar; + #if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1)) static volatile int siginfo_occurred; @@ -139,7 +144,7 @@ main(int argc, char **argv) * Use a pointer for consistency, but stack-allocated storage * for ease of cleanup. */ - bsdtar = &bsdtar_storage; + _bsdtar = bsdtar = &bsdtar_storage; memset(bsdtar, 0, sizeof(*bsdtar)); bsdtar->fd = -1; /* Mark as "unused" */ option_o = 0; @@ -152,36 +157,36 @@ main(int argc, char **argv) sa.sa_flags = 0; #ifdef SIGINFO if (sigaction(SIGINFO, &sa, NULL)) - bsdtar_errc(1, errno, "sigaction(SIGINFO) failed"); + lafe_errc(1, errno, "sigaction(SIGINFO) failed"); #endif #ifdef SIGUSR1 /* ... and treat SIGUSR1 the same way as SIGINFO. */ if (sigaction(SIGUSR1, &sa, NULL)) - bsdtar_errc(1, errno, "sigaction(SIGUSR1) failed"); + lafe_errc(1, errno, "sigaction(SIGUSR1) failed"); #endif } #endif - /* Need bsdtar_progname before calling bsdtar_warnc. */ + /* Need lafe_progname before calling lafe_warnc. */ if (*argv == NULL) - bsdtar_progname = "bsdtar"; + lafe_progname = "bsdtar"; else { #if defined(_WIN32) && !defined(__CYGWIN__) - bsdtar_progname = strrchr(*argv, '\\'); + lafe_progname = strrchr(*argv, '\\'); #else - bsdtar_progname = strrchr(*argv, '/'); + lafe_progname = strrchr(*argv, '/'); #endif - if (bsdtar_progname != NULL) - bsdtar_progname++; + if (lafe_progname != NULL) + lafe_progname++; else - bsdtar_progname = *argv; + lafe_progname = *argv; } time(&now); #if HAVE_SETLOCALE if (setlocale(LC_ALL, "") == NULL) - bsdtar_warnc(0, "Failed to set default locale"); + lafe_warnc(0, "Failed to set default locale"); #endif #if defined(HAVE_NL_LANGINFO) && defined(HAVE_D_MD_ORDER) bsdtar->day_first = (*nl_langinfo(D_MD_ORDER) == 'd'); @@ -233,7 +238,7 @@ main(int argc, char **argv) case 'b': /* SUSv2 */ t = atoi(bsdtar->optarg); if (t <= 0 || t > 8192) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Argument to -b is out of range (1..8192)"); bsdtar->bytes_per_block = 512 * t; break; @@ -251,7 +256,7 @@ main(int argc, char **argv) break; case OPTION_EXCLUDE: /* GNU tar */ if (lafe_exclude(&bsdtar->matching, bsdtar->optarg)) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Couldn't exclude %s\n", bsdtar->optarg); break; case OPTION_FORMAT: /* GNU tar, others */ @@ -297,20 +302,20 @@ main(int argc, char **argv) * when transforming archives. */ if (lafe_include(&bsdtar->matching, bsdtar->optarg)) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Failed to add %s to inclusion list", bsdtar->optarg); break; case 'j': /* GNU tar */ if (bsdtar->create_compression != '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->create_compression); bsdtar->create_compression = opt; break; case 'J': /* GNU tar 1.21 and later */ if (bsdtar->create_compression != '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->create_compression); bsdtar->create_compression = opt; @@ -330,7 +335,7 @@ main(int argc, char **argv) break; case OPTION_LZMA: if (bsdtar->create_compression != '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->create_compression); bsdtar->create_compression = opt; @@ -355,7 +360,7 @@ main(int argc, char **argv) { struct stat st; if (stat(bsdtar->optarg, &st) != 0) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't open file %s", bsdtar->optarg); bsdtar->newer_ctime_sec = st.st_ctime; bsdtar->newer_ctime_nsec = @@ -369,7 +374,7 @@ main(int argc, char **argv) { struct stat st; if (stat(bsdtar->optarg, &st) != 0) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't open file %s", bsdtar->optarg); bsdtar->newer_mtime_sec = st.st_mtime; bsdtar->newer_mtime_nsec = @@ -440,7 +445,7 @@ main(int argc, char **argv) #if HAVE_REGEX_H add_substitution(bsdtar, bsdtar->optarg); #else - bsdtar_warnc(0, + lafe_warnc(0, "-s is not supported by this version of bsdtar"); usage(); #endif @@ -487,7 +492,7 @@ main(int argc, char **argv) break; case 'X': /* GNU tar */ if (lafe_exclude_from_file(&bsdtar->matching, bsdtar->optarg)) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "failed to process exclusions from file %s", bsdtar->optarg); break; @@ -496,21 +501,21 @@ main(int argc, char **argv) break; case 'y': /* FreeBSD version of GNU tar */ if (bsdtar->create_compression != '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->create_compression); bsdtar->create_compression = opt; break; case 'Z': /* GNU tar */ if (bsdtar->create_compression != '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->create_compression); bsdtar->create_compression = opt; break; case 'z': /* GNU tar, star, many others */ if (bsdtar->create_compression != '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->create_compression); bsdtar->create_compression = opt; @@ -535,7 +540,7 @@ main(int argc, char **argv) /* Otherwise, a mode is required. */ if (bsdtar->mode == '\0') - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Must specify one of -c, -r, -t, -u, -x"); /* Check boolean options only permitted in certain modes. */ @@ -615,7 +620,7 @@ main(int argc, char **argv) #endif if (bsdtar->return_value != 0) - bsdtar_warnc(0, + lafe_warnc(0, "Error exit delayed from previous errors."); return (bsdtar->return_value); } @@ -624,7 +629,7 @@ static void set_mode(struct bsdtar *bsdtar, char opt) { if (bsdtar->mode != '\0' && bsdtar->mode != opt) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, bsdtar->mode); bsdtar->mode = opt; } @@ -636,7 +641,7 @@ static void only_mode(struct bsdtar *bsdtar, const char *opt, const char *valid_modes) { if (strchr(valid_modes, bsdtar->mode) == NULL) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Option %s is not permitted in mode -%c", opt, bsdtar->mode); } @@ -647,7 +652,7 @@ usage(void) { const char *p; - p = bsdtar_progname; + p = lafe_progname; fprintf(stderr, "Usage:\n"); fprintf(stderr, " List: %s -tf <archive-filename>\n", p); @@ -707,7 +712,7 @@ long_help(void) const char *prog; const char *p; - prog = bsdtar_progname; + prog = lafe_progname; fflush(stderr); |