aboutsummaryrefslogtreecommitdiff
path: root/lib/tar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-12-16 18:57:49 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-19 16:24:56 +0100
commit491c39a4ed48cdf598b8a4fd8707ef1af0850b20 (patch)
treee4a3a9c8133d16d8e396f6e06b7c9d9b0bebbd4c /lib/tar
parent551dd3879c288a2b6b6fbaca5c09c04fbe994ff4 (diff)
libtar: simplify padd_file function
We have an "append_sparse" function in libio, with a fallback, so use that. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar')
-rw-r--r--lib/tar/padd_file.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/lib/tar/padd_file.c b/lib/tar/padd_file.c
index 6a1ca05..053ff1e 100644
--- a/lib/tar/padd_file.c
+++ b/lib/tar/padd_file.c
@@ -8,32 +8,12 @@
#include "tar/tar.h"
#include "tar/format.h"
-#include <stdlib.h>
-#include <stdio.h>
-
int padd_file(ostream_t *fp, sqfs_u64 size)
{
size_t padd_sz = size % TAR_RECORD_SIZE;
- int status = -1;
- sqfs_u8 *buffer;
if (padd_sz == 0)
return 0;
- padd_sz = TAR_RECORD_SIZE - padd_sz;
-
- buffer = calloc(1, padd_sz);
- if (buffer == NULL)
- goto fail_errno;
-
- if (ostream_append(fp, buffer, padd_sz))
- goto out;
-
- status = 0;
-out:
- free(buffer);
- return status;
-fail_errno:
- perror("padding output file to block size");
- goto out;
+ return ostream_append_sparse(fp, TAR_RECORD_SIZE - padd_sz);
}