diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ustar.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ustar.c b/src/ustar.c index 3c57ba5..0ecf36a 100644 --- a/src/ustar.c +++ b/src/ustar.c @@ -271,7 +271,10 @@ opkg_opk_ustar_write_header(struct opkg_opk_ustar *ustar, uid_t uid, const char *uname, gid_t gid, const char *gname, uint64_t size, char type, const char *linkname) { - size_t linkname_len; + size_t linkname_len; + uint32_t chksum; + size_t i; + char *header_uc; if (opkg_opk_dirent_name_prefix(dirent, ustar->header.name, @@ -316,6 +319,19 @@ opkg_opk_ustar_write_header(struct opkg_opk_ustar *ustar, } memset(ustar->header.linkname, 0, sizeof(ustar->header.linkname) - linkname_len); + + strcpy(ustar->header.magic, "ustar"); + memcpy(ustar->header.version, "00", 2); + chksum = 0; + for (i = 0; i < sizeof(ustar->header.chksum); ++i) { + ustar->header.chksum[i] = ' '; + } + header_uc = (char *) &ustar->header; + for (i = 0; i < OPKG_OPK_USTAR_RECORD_SIZE; ++i) { + chksum += header_uc[i]; + } + sprintf(ustar->header.chksum, "%o", chksum); + if (opkg_opk_gzip_write(ustar->gzip, &ustar->header, OPKG_OPK_USTAR_RECORD_SIZE, 0) != OPKG_OPK_OK) { return OPKG_OPK_ERROR; |