diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-05-15 20:11:56 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-05-16 16:54:44 +0200 |
commit | 9a97a9a4fe224bcf53ad23af31bca67bbb71a824 (patch) | |
tree | bf1bd2ba581f8816813e6d17aa7e569b7b89cd1b /lib/io | |
parent | f5377528d4897e42fafe6c88ce550c956b0d85be (diff) |
libtar: replace tar_xattr_t with dir_entry_xattr_t struct
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io')
-rw-r--r-- | lib/io/Makemodule.am | 3 | ||||
-rw-r--r-- | lib/io/src/xattr.c | 40 |
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am index 841febf..3be208f 100644 --- a/lib/io/Makemodule.am +++ b/lib/io/Makemodule.am @@ -3,7 +3,8 @@ libio_a_SOURCES = include/io/istream.h include/io/ostream.h include/io/xfrm.h \ include/io/dir_iterator.h include/io/xattr.h \ lib/io/src/internal.h lib/io/src/ostream.c \ lib/io/src/istream.c lib/io/src/get_line.c lib/io/src/xfrm/ostream.c \ - lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c + lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c \ + lib/io/src/xattr.c libio_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS) libio_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS) diff --git a/lib/io/src/xattr.c b/lib/io/src/xattr.c new file mode 100644 index 0000000..dd9a338 --- /dev/null +++ b/lib/io/src/xattr.c @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * xattr.c + * + * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at> + */ +#include "io/xattr.h" + +#include <stdlib.h> +#include <string.h> + +dir_entry_xattr_t *dir_entry_xattr_create(const char *key, const sqfs_u8 *value, + size_t value_len) +{ + size_t key_len = strlen(key); + dir_entry_xattr_t *out = calloc(1, sizeof(*out) + key_len + 1 + + value_len + 1); + + if (out != NULL) { + out->key = out->data; + out->value = (sqfs_u8 *)(out->data + key_len + 1); + + memcpy(out->key, key, key_len); + memcpy(out->value, value, value_len); + out->value_len = value_len; + } + + return out; +} + +void dir_entry_xattr_list_free(dir_entry_xattr_t *list) +{ + dir_entry_xattr_t *old; + + while (list != NULL) { + old = list; + list = list->next; + free(old); + } +} |