diff options
Diffstat (limited to 'lib/tar/src')
-rw-r--r-- | lib/tar/src/cleanup.c | 13 | ||||
-rw-r--r-- | lib/tar/src/pax_header.c | 36 | ||||
-rw-r--r-- | lib/tar/src/write_header.c | 6 |
3 files changed, 12 insertions, 43 deletions
diff --git a/lib/tar/src/cleanup.c b/lib/tar/src/cleanup.c index 9f33336..3ba8019 100644 --- a/lib/tar/src/cleanup.c +++ b/lib/tar/src/cleanup.c @@ -21,20 +21,9 @@ void free_sparse_list(sparse_map_t *sparse) } } -void free_xattr_list(tar_xattr_t *list) -{ - tar_xattr_t *old; - - while (list != NULL) { - old = list; - list = list->next; - free(old); - } -} - void clear_header(tar_header_decoded_t *hdr) { - free_xattr_list(hdr->xattr); + dir_entry_xattr_list_free(hdr->xattr); free_sparse_list(hdr->sparse); free(hdr->name); free(hdr->link_target); diff --git a/lib/tar/src/pax_header.c b/lib/tar/src/pax_header.c index b61aab6..81f6ad4 100644 --- a/lib/tar/src/pax_header.c +++ b/lib/tar/src/pax_header.c @@ -141,7 +141,7 @@ fail: } static int pax_xattr_schily(tar_header_decoded_t *out, - tar_xattr_t *xattr) + dir_entry_xattr_t *xattr) { xattr->next = out->xattr; out->xattr = xattr; @@ -149,7 +149,7 @@ static int pax_xattr_schily(tar_header_decoded_t *out, } static int pax_xattr_libarchive(tar_header_decoded_t *out, - tar_xattr_t *xattr) + dir_entry_xattr_t *xattr) { int ret; @@ -184,7 +184,8 @@ static const struct pax_handler_t { int (*uint)(tar_header_decoded_t *out, sqfs_u64 uval); int (*str)(tar_header_decoded_t *out, char *str); int (*cstr)(tar_header_decoded_t *out, const char *str); - int (*xattr)(tar_header_decoded_t *out, tar_xattr_t *xattr); + int (*xattr)(tar_header_decoded_t *out, + dir_entry_xattr_t *xattr); } cb; } pax_fields[] = { { "uid", PAX_UID, PAX_TYPE_UINT, { .uint = pax_uid } }, @@ -234,33 +235,11 @@ static const struct pax_handler_t *find_handler(const char *key) return NULL; } -static tar_xattr_t *mkxattr(const char *key, - const char *value, size_t valuelen) -{ - size_t keylen = strlen(key); - tar_xattr_t *xattr; - - xattr = calloc(1, sizeof(*xattr) + keylen + 1 + valuelen + 1); - if (xattr == NULL) - return NULL; - - xattr->key = xattr->data; - memcpy(xattr->key, key, keylen); - xattr->key[keylen] = '\0'; - - xattr->value = (sqfs_u8 *)xattr->key + keylen + 1; - memcpy(xattr->value, value, valuelen); - xattr->value[valuelen] = '\0'; - - xattr->value_len = valuelen; - return xattr; -} - static int apply_handler(tar_header_decoded_t *out, const struct pax_handler_t *field, const char *key, const char *value, size_t valuelen) { - tar_xattr_t *xattr; + dir_entry_xattr_t *xattr; sqfs_s64 s64val; sqfs_u64 uval; char *copy; @@ -295,8 +274,9 @@ static int apply_handler(tar_header_decoded_t *out, } break; case PAX_TYPE_PREFIXED_XATTR: - xattr = mkxattr(key + strlen(field->name) + 1, - value, valuelen); + xattr = dir_entry_xattr_create(key + strlen(field->name) + 1, + (const sqfs_u8 *)value, + valuelen); if (xattr == NULL) { perror("reading pax xattr field"); return -1; diff --git a/lib/tar/src/write_header.c b/lib/tar/src/write_header.c index 6876c38..f5473ca 100644 --- a/lib/tar/src/write_header.c +++ b/lib/tar/src/write_header.c @@ -144,11 +144,11 @@ static size_t prefix_digit_len(size_t len) } static int write_schily_xattr(ostream_t *fp, const struct stat *orig, - const char *name, const tar_xattr_t *xattr) + const char *name, const dir_entry_xattr_t *xattr) { static const char *prefix = "SCHILY.xattr."; size_t len, total_size = 0; - const tar_xattr_t *it; + const dir_entry_xattr_t *it; char *buffer, *ptr; int ret; @@ -184,7 +184,7 @@ static int write_schily_xattr(ostream_t *fp, const struct stat *orig, } int write_tar_header(ostream_t *fp, const struct stat *sb, const char *name, - const char *slink_target, const tar_xattr_t *xattr, + const char *slink_target, const dir_entry_xattr_t *xattr, unsigned int counter) { const char *reason; |