summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-03-08 06:19:28 +0000
committerkientzle <kientzle@FreeBSD.org>2009-03-08 06:19:28 +0000
commit26f0010266cad2bb2d82b748cdf8cbacf7b8e2c8 (patch)
treef874d802e06b9260d9dd99a2074cc7fad2295b78 /usr.bin
parentab8f6aab1ae5011cc2e4dd5318ff3b80cda1ea1c (diff)
downloadFreeBSD-src-26f0010266cad2bb2d82b748cdf8cbacf7b8e2c8.zip
FreeBSD-src-26f0010266cad2bb2d82b748cdf8cbacf7b8e2c8.tar.gz
Merge r492 from libarchive.googlecode.com: First cut at exposing the
new options mechanism to userland. Documentation pending...
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tar/bsdtar.c3
-rw-r--r--usr.bin/tar/bsdtar.h2
-rw-r--r--usr.bin/tar/cmdline.c1
-rw-r--r--usr.bin/tar/read.c6
-rw-r--r--usr.bin/tar/write.c17
5 files changed, 29 insertions, 0 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c
index c982061..e90afbc 100644
--- a/usr.bin/tar/bsdtar.c
+++ b/usr.bin/tar/bsdtar.c
@@ -212,6 +212,9 @@ main(int argc, char **argv)
case OPTION_FORMAT: /* GNU tar, others */
bsdtar->create_format = bsdtar->optarg;
break;
+ case OPTION_FORMAT_OPTIONS:
+ bsdtar->option_format_options = bsdtar->optarg;
+ break;
case 'f': /* SUSv2 */
bsdtar->filename = bsdtar->optarg;
if (strcmp(bsdtar->filename, "-") == 0)
diff --git a/usr.bin/tar/bsdtar.h b/usr.bin/tar/bsdtar.h
index 98b365b..1e6673a 100644
--- a/usr.bin/tar/bsdtar.h
+++ b/usr.bin/tar/bsdtar.h
@@ -60,6 +60,7 @@ struct bsdtar {
char option_chroot; /* --chroot */
char option_dont_traverse_mounts; /* --one-file-system */
char option_fast_read; /* --fast-read */
+ const char *option_format_options; /* --format-options */
char option_honor_nodump; /* --nodump */
char option_interactive; /* -w */
char option_no_owner; /* -o */
@@ -110,6 +111,7 @@ enum {
OPTION_CHROOT,
OPTION_EXCLUDE,
OPTION_FORMAT,
+ OPTION_FORMAT_OPTIONS,
OPTION_HELP,
OPTION_INCLUDE,
OPTION_KEEP_NEWER_FILES,
diff --git a/usr.bin/tar/cmdline.c b/usr.bin/tar/cmdline.c
index 09818a3..ad8b487 100644
--- a/usr.bin/tar/cmdline.c
+++ b/usr.bin/tar/cmdline.c
@@ -83,6 +83,7 @@ static struct option {
{ "file", 1, 'f' },
{ "files-from", 1, 'T' },
{ "format", 1, OPTION_FORMAT },
+ { "format-options", 1, OPTION_FORMAT_OPTIONS },
{ "gunzip", 0, 'z' },
{ "gzip", 0, 'z' },
{ "help", 0, OPTION_HELP },
diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c
index 3aa164f..054476b 100644
--- a/usr.bin/tar/read.c
+++ b/usr.bin/tar/read.c
@@ -132,6 +132,12 @@ read_archive(struct bsdtar *bsdtar, char mode)
DEFAULT_BYTES_PER_BLOCK))
bsdtar_errc(bsdtar, 1, 0, "Error opening archive: %s",
archive_error_string(a));
+ if (bsdtar->option_format_options != NULL) {
+ r = archive_read_set_options(a, bsdtar->option_format_options);
+ if (r != ARCHIVE_OK)
+ bsdtar_errc(bsdtar, 1, 0, "Error archive options: %s",
+ archive_error_string(a));
+ }
do_chdir(bsdtar);
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c
index dd53453..6f89286 100644
--- a/usr.bin/tar/write.c
+++ b/usr.bin/tar/write.c
@@ -208,6 +208,12 @@ tar_mode_c(struct bsdtar *bsdtar)
if (r != ARCHIVE_OK)
bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+ if (bsdtar->option_format_options != NULL) {
+ r = archive_write_set_options(a, bsdtar->option_format_options);
+ if (r != ARCHIVE_OK)
+ bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+ }
+
write_archive(a, bsdtar);
}
@@ -294,6 +300,11 @@ tar_mode_r(struct bsdtar *bsdtar)
}
lseek(bsdtar->fd, end_offset, SEEK_SET); /* XXX check return val XXX */
archive_write_open_fd(a, bsdtar->fd); /* XXX check return val XXX */
+ if (bsdtar->option_format_options != NULL) {
+ r = archive_write_set_options(a, bsdtar->option_format_options);
+ if (r != ARCHIVE_OK)
+ bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+ }
write_archive(a, bsdtar); /* XXX check return val XXX */
@@ -310,6 +321,7 @@ tar_mode_u(struct bsdtar *bsdtar)
int format;
struct archive_dir_entry *p;
struct archive_dir archive_dir;
+ int r;
bsdtar->archive_dir = &archive_dir;
memset(&archive_dir, 0, sizeof(archive_dir));
@@ -374,6 +386,11 @@ tar_mode_u(struct bsdtar *bsdtar)
lseek(bsdtar->fd, end_offset, SEEK_SET);
ftruncate(bsdtar->fd, end_offset);
archive_write_open_fd(a, bsdtar->fd);
+ if (bsdtar->option_format_options != NULL) {
+ r = archive_write_set_options(a, bsdtar->option_format_options);
+ if (r != ARCHIVE_OK)
+ bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+ }
write_archive(a, bsdtar);
OpenPOWER on IntegriCloud