diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-10-22 17:19:34 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-03-30 22:31:30 +0200 |
commit | 916c8f6e26140cf3c03e58726b57dc4f86e18316 (patch) | |
tree | 59603136d62ef2b7ca3626e26929e848db7ab3f1 /lib | |
parent | a0e9956f931e28eeb430bd2459668fd96a69c676 (diff) |
Cleanup: remove struct stat from libtar
The idea was originally to use struct stat in the libfstree code, so
we can simply hose data read from a directory into the fstree_t. The
struct was then also used with libtar, for simpler interoperation,
but it turned out to introduce a lot of platform quirks and causes
more trouble than it's worth.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tar/pax_header.c | 4 | ||||
-rw-r--r-- | lib/tar/read_header.c | 40 |
2 files changed, 15 insertions, 29 deletions
diff --git a/lib/tar/pax_header.c b/lib/tar/pax_header.c index 71b849b..d24def0 100644 --- a/lib/tar/pax_header.c +++ b/lib/tar/pax_header.c @@ -10,13 +10,13 @@ static int pax_uid(tar_header_decoded_t *out, sqfs_u64 id) { - out->sb.st_uid = id; + out->uid = id; return 0; } static int pax_gid(tar_header_decoded_t *out, sqfs_u64 id) { - out->sb.st_gid = id; + out->gid = id; return 0; } diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c index ecba0bc..d1790de 100644 --- a/lib/tar/read_header.c +++ b/lib/tar/read_header.c @@ -74,27 +74,27 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, if (!(set_by_pax & PAX_UID)) { if (read_number(hdr->uid, sizeof(hdr->uid), &field)) return -1; - out->sb.st_uid = field; + out->uid = field; } if (!(set_by_pax & PAX_GID)) { if (read_number(hdr->gid, sizeof(hdr->gid), &field)) return -1; - out->sb.st_gid = field; + out->gid = field; } if (!(set_by_pax & PAX_DEV_MAJ)) { if (read_number(hdr->devmajor, sizeof(hdr->devmajor), &field)) return -1; - out->sb.st_rdev = makedev(field, minor(out->sb.st_rdev)); + out->devno = makedev(field, minor(out->devno)); } if (!(set_by_pax & PAX_DEV_MIN)) { if (read_number(hdr->devminor, sizeof(hdr->devminor), &field)) return -1; - out->sb.st_rdev = makedev(major(out->sb.st_rdev), field); + out->devno = makedev(major(out->devno), field); } if (!(set_by_pax & PAX_MTIME)) { @@ -111,7 +111,7 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, if (read_octal(hdr->mode, sizeof(hdr->mode), &field)) return -1; - out->sb.st_mode = field & 07777; + out->mode = field & 07777; if (hdr->typeflag == TAR_TYPE_LINK || hdr->typeflag == TAR_TYPE_SLINK) { @@ -131,42 +131,31 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, case '\0': case TAR_TYPE_FILE: case TAR_TYPE_GNU_SPARSE: - out->sb.st_mode |= S_IFREG; + out->mode |= S_IFREG; break; case TAR_TYPE_LINK: out->is_hard_link = true; break; case TAR_TYPE_SLINK: - out->sb.st_mode = S_IFLNK | 0777; + out->mode = S_IFLNK | 0777; break; case TAR_TYPE_CHARDEV: - out->sb.st_mode |= S_IFCHR; + out->mode |= S_IFCHR; break; case TAR_TYPE_BLOCKDEV: - out->sb.st_mode |= S_IFBLK; + out->mode |= S_IFBLK; break; case TAR_TYPE_DIR: - out->sb.st_mode |= S_IFDIR; + out->mode |= S_IFDIR; break; case TAR_TYPE_FIFO: - out->sb.st_mode |= S_IFIFO; + out->mode |= S_IFIFO; break; default: out->unknown_record = true; break; } - if (sizeof(time_t) * CHAR_BIT < 64) { - if (out->mtime > (sqfs_s64)INT32_MAX) { - out->sb.st_mtime = INT32_MAX; - } else if (out->mtime < (sqfs_s64)INT32_MIN) { - out->sb.st_mtime = INT32_MIN; - } else { - out->sb.st_mtime = out->mtime; - } - } else { - out->sb.st_mtime = out->mtime; - } return 0; } @@ -268,12 +257,9 @@ int read_header(istream_t *fp, tar_header_decoded_t *out) goto fail; } - if (out->sparse != NULL) { - out->sb.st_size = out->actual_size; - } else { - out->sb.st_size = out->record_size; + if (out->sparse == NULL) out->actual_size = out->record_size; - } + return 0; out_eof: clear_header(out); |