diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-09-13 13:37:42 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-09-16 09:34:35 +0200 |
commit | f757737060d4daebb24a32e90d912661428708a8 (patch) | |
tree | a6e96145d4fc540e435c13a69c924329db2edb6d /lib/tar/read_retry.c | |
parent | c1a2cb729bd5bb5fdadf00cb3968bbc541f79750 (diff) |
Remodel libtar/tar2sqfs to read data from an istream_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/read_retry.c')
-rw-r--r-- | lib/tar/read_retry.c | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/lib/tar/read_retry.c b/lib/tar/read_retry.c deleted file mode 100644 index 2a2f82c..0000000 --- a/lib/tar/read_retry.c +++ /dev/null @@ -1,57 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * read_retry.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "tar.h" -#include "internal.h" - -int read_retry(const char *errstr, FILE *fp, void *buffer, size_t size) -{ - size_t ret; - - while (size > 0) { - if (ferror(fp)) { - fprintf(stderr, "%s: error reading from file\n", - errstr); - return -1; - } - - if (feof(fp)) { - fprintf(stderr, "%s: short read\n", errstr); - return -1; - } - - ret = fread(buffer, 1, size, fp); - size -= ret; - buffer = (char *)buffer + ret; - } - - return 0; -} - -char *record_to_memory(FILE *fp, sqfs_u64 size) -{ - char *buffer = malloc(size + 1); - - if (buffer == NULL) - goto fail_errno; - - if (read_retry("reading tar record", fp, buffer, size)) - goto fail; - - if (skip_padding(fp, size)) - goto fail; - - buffer[size] = '\0'; - return buffer; -fail_errno: - perror("reading tar record"); - goto fail; -fail: - free(buffer); - return NULL; -} |