From 9a97a9a4fe224bcf53ad23af31bca67bbb71a824 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 15 May 2023 20:11:56 +0200 Subject: libtar: replace tar_xattr_t with dir_entry_xattr_t struct Signed-off-by: David Oberhollenzer --- lib/tar/test/tar_write_simple.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) (limited to 'lib/tar/test') diff --git a/lib/tar/test/tar_write_simple.c b/lib/tar/test/tar_write_simple.c index c78565b..738b469 100644 --- a/lib/tar/test/tar_write_simple.c +++ b/lib/tar/test/tar_write_simple.c @@ -52,29 +52,7 @@ static const char *buffer_get_filename(ostream_t *strm) #define TIME_STAMP (1057296600) -static tar_xattr_t *mkxattr(const char *key, const sqfs_u8 *value, - size_t value_len) -{ - size_t key_len = strlen(key); - tar_xattr_t *out = malloc(sizeof(*out) + key_len + 1 + value_len + 1); - - TEST_NOT_NULL(out); - - out->next = NULL; - out->key = out->data; - out->value = (sqfs_u8 *)(out->data + key_len + 1); - out->value_len = value_len; - - memcpy(out->data, key, key_len); - out->data[key_len] = '\0'; - - memcpy(out->data + key_len + 1, value, value_len); - out->data[key_len + 1 + value_len] = '\0'; - - return out; -} - -static tar_xattr_t *mkxattr_chain(void) +static dir_entry_xattr_t *mkxattr_chain(void) { static const uint8_t value[] = { 0x00, 0x00, 0x00, 0x02, @@ -83,17 +61,20 @@ static tar_xattr_t *mkxattr_chain(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - tar_xattr_t *list; - - list = mkxattr("user.mime_type", (const sqfs_u8 *)"blob/magic", 10); - list->next = mkxattr("security.capability", value, sizeof(value)); - + dir_entry_xattr_t *list; + + list = dir_entry_xattr_create("user.mime_type", + (const sqfs_u8 *)"blob/magic", 10); + TEST_NOT_NULL(list); + list->next = dir_entry_xattr_create("security.capability", + value, sizeof(value)); + TEST_NOT_NULL(list->next); return list; } int main(int argc, char **argv) { - tar_xattr_t *xattr; + dir_entry_xattr_t *xattr; struct stat sb; istream_t *fp; int ret; @@ -173,7 +154,7 @@ int main(int argc, char **argv) ret = write_tar_header(&mem_stream, &sb, "home/goliath/test.exe", NULL, xattr, 11); TEST_EQUAL_I(ret, 0); - free_xattr_list(xattr); + dir_entry_xattr_list_free(xattr); ret = ostream_append(&mem_stream, ":-)\n", 4); TEST_EQUAL_I(ret, 0); -- cgit v1.2.3