diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-01 13:23:36 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-01 13:23:36 +0200 |
commit | 8aea2d1dc437b5b497170ef9c1b6854aee8f5dcf (patch) | |
tree | 0999ed4664c74cf90896d8b11f7f4a9dc06e8d48 /lib/tar/write_header.c | |
parent | f0d18050d832498c8e230c04084675455fef391f (diff) |
cleanup: split tar code up, remove some duplications
This commit attempts to split some of the monolitic tar parsing code up
into multiple functions in seperate files. Also, some code duplication
(like reading a record into memory which was implemented twice) is
removed.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/write_header.c')
-rw-r--r-- | lib/tar/write_header.c | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/lib/tar/write_header.c b/lib/tar/write_header.c index 0670523..b84324b 100644 --- a/lib/tar/write_header.c +++ b/lib/tar/write_header.c @@ -1,22 +1,9 @@ /* SPDX-License-Identifier: GPL-3.0-or-later */ -#include "util.h" -#include "tar.h" - -#include <sys/sysmacros.h> -#include <string.h> -#include <stdio.h> +#include "internal.h" static unsigned long pax_hdr_counter = 0; static char buffer[4096]; -static void write_octal(char *dst, unsigned int value, int digits) -{ - char temp[64]; - - sprintf(temp, "%0*o ", digits, value); - memcpy(dst, temp, strlen(temp)); -} - static int name_to_tar_header(tar_header_t *hdr, const char *path) { size_t len = strlen(path); @@ -80,21 +67,6 @@ static void init_header(tar_header_t *hdr, const struct stat *sb, sprintf(hdr->gname, "%u", sb->st_gid); } -static void update_checksum(tar_header_t *hdr) -{ - unsigned int chksum = 0; - size_t i; - - memset(hdr->chksum, ' ', sizeof(hdr->chksum)); - - for (i = 0; i < sizeof(*hdr); ++i) - chksum += ((unsigned char *)hdr)[i]; - - write_octal(hdr->chksum, chksum, 6); - hdr->chksum[6] = '\0'; - hdr->chksum[7] = ' '; -} - static bool need_pax_header(const struct stat *sb, const char *name) { tar_header_t tmp; |