summaryrefslogtreecommitdiffstats
path: root/source3/client/clitar.c
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2013-07-18 17:06:33 +0200
committerAndreas Schneider <asn@samba.org>2014-02-19 18:22:28 +0100
commitfc05ff32fd7e8484f00e02a27d000e05748cdf74 (patch)
tree61000cfe3569ffa51e0ad61315f1213ce47298ca /source3/client/clitar.c
parentcae67383ddd4373dcf8fc1f82a41dc30b1b7d299 (diff)
downloadsamba-fc05ff32fd7e8484f00e02a27d000e05748cdf74.tar.gz
samba-fc05ff32fd7e8484f00e02a27d000e05748cdf74.tar.xz
samba-fc05ff32fd7e8484f00e02a27d000e05748cdf74.zip
clitar.c: blocksize in block unit, fix error handling in tar_create().
Signed-off-by: Aurélien Aptel <aurelien.aptel@gmail.com> Reviewed-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/client/clitar.c')
-rw-r--r--source3/client/clitar.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 3d81016622c..cf31f45c4ce 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -29,22 +29,23 @@
#define DBG(a, b) (DEBUG(a, ("tar:%-4d ", __LINE__)), DEBUG(a, b))
/**
+ * Number of byte in a block unit.
+ */
+#define TAR_BLOCK_UNIT 512
+
+/**
+ * Default tar block size in TAR_BLOCK_UNIT.
+ */
+#define TAR_DEFAULT_BLOCK_SIZE 20
+
+/**
* Maximum value for the blocksize field
*/
#define TAR_MAX_BLOCK_SIZE 0xffff
/**
- * Default tar block size in bytes. Hasn't changed since the first
- * commit in 1996...
- *
- * A more adequate size will be used for better performance unless
- * we're dealing with a tape device with a fixed read/write block
- * size.
- *
- * The actual choice is made by libarchive.
+ * Size of the buffer used when downloading a file
*/
-#define TAR_DEFAULT_BLOCK_SIZE (20*512)
-
#define TAR_CLI_READ_SIZE 0xff00
#define TAR_DO_LIST_ATTR (FILE_ATTRIBUTE_DIRECTORY \
@@ -938,10 +939,20 @@ static int tar_create(struct tar* t)
t->archive = archive_write_new();
if (!t->mode.dry) {
+ const int bsize = t->mode.blocksize * TAR_BLOCK_UNIT;
+ r = archive_write_set_bytes_per_block(t->archive, bsize);
+ if (r != ARCHIVE_OK) {
+ DBG(0, ("Can't use a block size of %d bytes", bsize));
+ err = 1;
+ goto out;
+ }
+
r = archive_write_set_format_pax_restricted(t->archive);
if (r != ARCHIVE_OK) {
- DBG(0, ("Can't open %s: %s\n", t->tar_path,
+ DBG(0, ("Can't use pax restricted format: %s\n",
archive_error_string(t->archive)));
+ err = 1;
+ goto out;
}
if (strequal(t->tar_path, "-")) {
@@ -1069,16 +1080,16 @@ static int tar_extract(struct tar *t)
int err = 0;
int r;
struct archive_entry *entry;
+ const size_t bsize = t->mode.blocksize * TAR_BLOCK_UNIT;
t->archive = archive_read_new();
archive_read_support_format_all(t->archive);
archive_read_support_filter_all(t->archive);
if (strequal(t->tar_path, "-")) {
- r = archive_read_open_fd(t->archive, STDIN_FILENO, t->mode.blocksize);
+ r = archive_read_open_fd(t->archive, STDIN_FILENO, bsize);
} else {
- r = archive_read_open_filename(t->archive, t->tar_path,
- t->mode.blocksize);
+ r = archive_read_open_filename(t->archive, t->tar_path, bsize);
}
if (r != ARCHIVE_OK) {