From 9a97a9a4fe224bcf53ad23af31bca67bbb71a824 Mon Sep 17 00:00:00 2001
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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 <david.oberhollenzer@sigma-star.at>
---
 lib/io/src/xattr.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 lib/io/src/xattr.c

(limited to 'lib/io/src')

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);
+	}
+}
-- 
cgit v1.2.3