aboutsummaryrefslogtreecommitdiff
path: root/lib/tar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-05 19:06:42 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-05 16:01:34 +0200
commitc9a8adc15f9de110771156fdc85fb98533648a53 (patch)
treecdd6300b1c69a002628a76c4bac45ac6664111d9 /lib/tar
parent57ca46cdd74fd1004a3b0476c136e1f26fcf002d (diff)
Move dir_entry_xattr_t from libio to libsquashfs
The structure and functions are renamed to sqfs_xattr_* instead, an additional helper is added to accept an encoded xattr. Documentation and unit test are added as well. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar')
-rw-r--r--lib/tar/Makemodule.am78
-rw-r--r--lib/tar/src/cleanup.c3
-rw-r--r--lib/tar/src/iterator.c5
-rw-r--r--lib/tar/src/pax_header.c26
-rw-r--r--lib/tar/src/write_header.c10
-rw-r--r--lib/tar/test/tar_write_simple.c17
-rw-r--r--lib/tar/test/tar_xattr.c1
-rw-r--r--lib/tar/test/tar_xattr_bin.c1
8 files changed, 78 insertions, 63 deletions
diff --git a/lib/tar/Makemodule.am b/lib/tar/Makemodule.am
index 7e58cc6..9061571 100644
--- a/lib/tar/Makemodule.am
+++ b/lib/tar/Makemodule.am
@@ -11,177 +11,187 @@ noinst_LIBRARIES += libtar.a
TARDATADIR=$(top_srcdir)/lib/tar/test/data
test_tar_gnu0_SOURCES = lib/tar/test/tar_simple.c
-test_tar_gnu0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu0_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu0_CPPFLAGS += -DTESTFILE=format-acceptance/gnu.tar
test_tar_gnu1_SOURCES = lib/tar/test/tar_simple.c
-test_tar_gnu1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu1_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu1_CPPFLAGS += -DTESTFILE=format-acceptance/gnu-g.tar
test_tar_gnu2_SOURCES = lib/tar/test/tar_simple.c
-test_tar_gnu2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu2_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu2_CPPFLAGS += -DTESTFILE=user-group-largenum/gnu.tar
test_tar_gnu2_CPPFLAGS += -DTESTUID=0x80000000 -DTESTGID=0x80000000
test_tar_gnu2_CPPFLAGS += -DTESTTS=1542995392
test_tar_gnu3_SOURCES = lib/tar/test/tar_simple.c
-test_tar_gnu3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu3_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu3_CPPFLAGS += -DTESTFILE=negative-mtime/gnu.tar -DTESTTS=-315622800
test_tar_gnu4_SOURCES = lib/tar/test/tar_simple.c
-test_tar_gnu4_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu4_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu4_CPPFLAGS += -DTESTFILE=long-paths/gnu.tar -DLONG_NAME_TEST
test_tar_gnu4_CPPFLAGS += -DTESTTS=1542909670
test_tar_gnu5_SOURCES = lib/tar/test/tar_simple.c
-test_tar_gnu5_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu5_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu5_CPPFLAGS += -DTESTFILE=large-mtime/gnu.tar -DTESTTS=8589934592L
test_tar_gnu6_SOURCES = lib/tar/test/tar_big_file.c
-test_tar_gnu6_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu6_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_gnu6_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_gnu6_CPPFLAGS += -DTESTFILE=file-size/gnu.tar
test_tar_pax0_SOURCES = lib/tar/test/tar_simple.c
-test_tar_pax0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax0_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_pax0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_pax0_CPPFLAGS += -DTESTFILE=format-acceptance/pax.tar
test_tar_pax1_SOURCES = lib/tar/test/tar_simple.c
-test_tar_pax1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax1_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_pax1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_pax1_CPPFLAGS += -DTESTFILE=user-group-largenum/pax.tar
test_tar_pax1_CPPFLAGS += -DTESTUID=2147483648UL -DTESTGID=2147483648UL
test_tar_pax1_CPPFLAGS += -DTESTTS=1542995392
test_tar_pax2_SOURCES = lib/tar/test/tar_simple.c
-test_tar_pax2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax2_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_pax2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_pax2_CPPFLAGS += -DTESTFILE=large-mtime/pax.tar -DTESTTS=8589934592L
test_tar_pax3_SOURCES = lib/tar/test/tar_simple.c
-test_tar_pax3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax3_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_pax3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_pax3_CPPFLAGS += -DTESTFILE=negative-mtime/pax.tar -DTESTTS=-315622800
test_tar_pax4_SOURCES = lib/tar/test/tar_simple.c
-test_tar_pax4_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax4_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_pax4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_pax4_CPPFLAGS += -DTESTFILE=long-paths/pax.tar
test_tar_pax4_CPPFLAGS += -DLONG_NAME_TEST -DTESTTS=1542909670
test_tar_pax5_SOURCES = lib/tar/test/tar_big_file.c
-test_tar_pax5_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax5_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_pax5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_pax5_CPPFLAGS += -DTESTFILE=file-size/pax.tar
test_tar_ustar0_SOURCES = lib/tar/test/tar_simple.c
-test_tar_ustar0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar0_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar0_CPPFLAGS += -DTESTFILE=format-acceptance/ustar.tar
test_tar_ustar1_SOURCES = lib/tar/test/tar_simple.c
-test_tar_ustar1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar1_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar1_CPPFLAGS += -DTESTFILE=format-acceptance/ustar-pre-posix.tar
test_tar_ustar2_SOURCES = lib/tar/test/tar_simple.c
-test_tar_ustar2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar2_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar2_CPPFLAGS += -DTESTFILE=format-acceptance/v7.tar
test_tar_ustar3_SOURCES = lib/tar/test/tar_simple.c
-test_tar_ustar3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar3_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar3_CPPFLAGS += -DTESTFILE=user-group-largenum/8-digit.tar
test_tar_ustar3_CPPFLAGS += -DTESTUID=8388608 -DTESTGID=8388608
test_tar_ustar3_CPPFLAGS += -DTESTTS=1542995392
test_tar_ustar4_SOURCES = lib/tar/test/tar_simple.c
-test_tar_ustar4_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar4_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar4_CPPFLAGS += -DTESTFILE=large-mtime/12-digit.tar
test_tar_ustar4_CPPFLAGS += -DTESTTS=8589934592L
test_tar_ustar5_SOURCES = lib/tar/test/tar_simple.c
-test_tar_ustar5_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar5_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar5_CPPFLAGS += -DTESTFILE=long-paths/ustar.tar
test_tar_ustar5_CPPFLAGS += -DLONG_NAME_TEST -DTESTTS=1542909670
test_tar_ustar6_SOURCES = lib/tar/test/tar_big_file.c
-test_tar_ustar6_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar6_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_ustar6_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_ustar6_CPPFLAGS += -DTESTFILE=file-size/12-digit.tar
test_tar_target_filled_SOURCES = lib/tar/test/tar_target_filled.c
-test_tar_target_filled_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_target_filled_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_target_filled_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_sparse_gnu_SOURCES = lib/tar/test/tar_sparse_gnu.c
-test_tar_sparse_gnu_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_sparse_gnu_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_sparse_gnu0_SOURCES = lib/tar/test/tar_sparse.c
-test_tar_sparse_gnu0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu0_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_sparse_gnu0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_sparse_gnu0_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu0-0.tar
test_tar_sparse_gnu1_SOURCES = lib/tar/test/tar_sparse.c
-test_tar_sparse_gnu1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu1_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_sparse_gnu1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_sparse_gnu1_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu0-1.tar
test_tar_sparse_gnu2_SOURCES = lib/tar/test/tar_sparse.c
-test_tar_sparse_gnu2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu2_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_sparse_gnu2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_sparse_gnu2_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu1-0.tar
test_tar_sparse_gnu3_SOURCES = lib/tar/test/tar_sparse.c
-test_tar_sparse_gnu3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu3_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_sparse_gnu3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_sparse_gnu3_CPPFLAGS += -DTESTFILE=sparse-files/gnu.tar
test_tar_xattr_bsd_SOURCES = lib/tar/test/tar_xattr.c
-test_tar_xattr_bsd_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_xattr_bsd_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_xattr_bsd_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_xattr_bsd_CPPFLAGS += -DTESTFILE=xattr/xattr-libarchive.tar
test_tar_xattr_schily_SOURCES = lib/tar/test/tar_xattr.c
-test_tar_xattr_schily_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_xattr_schily_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_xattr_schily_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_xattr_schily_CPPFLAGS += -DTESTFILE=xattr/xattr-schily.tar
test_tar_xattr_schily_bin_SOURCES = lib/tar/test/tar_xattr_bin.c
-test_tar_xattr_schily_bin_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_xattr_schily_bin_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_xattr_schily_bin_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_xattr_schily_bin_CPPFLAGS += -DTESTFILE=xattr/xattr-schily-binary.tar
test_tar_iterator_SOURCES = lib/tar/test/tar_iterator.c
-test_tar_iterator_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_iterator_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_iterator_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_iterator_CPPFLAGS += -DTESTFILE=format-acceptance/gnu.tar
test_tar_iterator2_SOURCES = lib/tar/test/tar_iterator2.c
-test_tar_iterator2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_iterator2_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_iterator2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_iterator2_CPPFLAGS += -DTESTFILE=iterator/sparse.tar
test_tar_iterator3_SOURCES = lib/tar/test/tar_iterator3.c
-test_tar_iterator3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_iterator3_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_iterator3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
tar_fuzz_SOURCES = lib/tar/test/tar_fuzz.c
-tar_fuzz_LDADD = libtar.a libio.a libutil.a libcompat.a
+tar_fuzz_LDADD = libtar.a libsquashfs.la libio.a libutil.a libcompat.a
test_tar_write_simple_SOURCES = lib/tar/test/tar_write_simple.c
-test_tar_write_simple_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_write_simple_LDADD = libtar.a libsquashfs.la libio.a libutil.a \
+ libcompat.a
test_tar_write_simple_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
test_tar_write_simple_CPPFLAGS += -DTESTFILE=write/simple.tar
diff --git a/lib/tar/src/cleanup.c b/lib/tar/src/cleanup.c
index 3ba8019..145f34d 100644
--- a/lib/tar/src/cleanup.c
+++ b/lib/tar/src/cleanup.c
@@ -7,6 +7,7 @@
#include "config.h"
#include "internal.h"
+#include "sqfs/xattr.h"
#include <stdlib.h>
#include <string.h>
@@ -23,7 +24,7 @@ void free_sparse_list(sparse_map_t *sparse)
void clear_header(tar_header_decoded_t *hdr)
{
- dir_entry_xattr_list_free(hdr->xattr);
+ sqfs_xattr_list_free(hdr->xattr);
free_sparse_list(hdr->sparse);
free(hdr->name);
free(hdr->link_target);
diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c
index b1be42d..216c528 100644
--- a/lib/tar/src/iterator.c
+++ b/lib/tar/src/iterator.c
@@ -6,6 +6,7 @@
*/
#include "tar/tar.h"
#include "sqfs/error.h"
+#include "sqfs/xattr.h"
#include "util/util.h"
#include <stdlib.h>
@@ -281,7 +282,7 @@ static int it_open_file_ro(dir_iterator_t *it, istream_t **out)
return 0;
}
-static int it_read_xattr(dir_iterator_t *it, dir_entry_xattr_t **out)
+static int it_read_xattr(dir_iterator_t *it, sqfs_xattr_t **out)
{
tar_iterator_t *tar = (tar_iterator_t *)it;
@@ -293,7 +294,7 @@ static int it_read_xattr(dir_iterator_t *it, dir_entry_xattr_t **out)
return tar->state < 0 ? tar->state : SQFS_ERROR_NO_ENTRY;
if (tar->current.xattr != NULL) {
- *out = dir_entry_xattr_list_copy(tar->current.xattr);
+ *out = sqfs_xattr_list_copy(tar->current.xattr);
if (*out == NULL)
return SQFS_ERROR_ALLOC;
}
diff --git a/lib/tar/src/pax_header.c b/lib/tar/src/pax_header.c
index 81f6ad4..74a1b24 100644
--- a/lib/tar/src/pax_header.c
+++ b/lib/tar/src/pax_header.c
@@ -7,6 +7,7 @@
#include "config.h"
#include "internal.h"
+#include "sqfs/xattr.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
@@ -140,27 +141,27 @@ fail:
return -1;
}
-static int pax_xattr_schily(tar_header_decoded_t *out,
- dir_entry_xattr_t *xattr)
+static int pax_xattr_schily(tar_header_decoded_t *out, sqfs_xattr_t *xattr)
{
xattr->next = out->xattr;
out->xattr = xattr;
return 0;
}
-static int pax_xattr_libarchive(tar_header_decoded_t *out,
- dir_entry_xattr_t *xattr)
+static int pax_xattr_libarchive(tar_header_decoded_t *out, sqfs_xattr_t *xattr)
{
+ char *key = (char *)xattr->data;
+ sqfs_u8 *value = xattr->data + (size_t)(xattr->value - xattr->data);
int ret;
ret = base64_decode((const char *)xattr->value, xattr->value_len,
- xattr->value, &xattr->value_len);
+ value, &xattr->value_len);
if (ret)
return -1;
- urldecode(xattr->key);
+ urldecode(key);
+ value[xattr->value_len] = '\0';
- xattr->value[xattr->value_len] = '\0';
xattr->next = out->xattr;
out->xattr = xattr;
return 0;
@@ -184,8 +185,7 @@ 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,
- dir_entry_xattr_t *xattr);
+ int (*xattr)(tar_header_decoded_t *out, sqfs_xattr_t *xattr);
} cb;
} pax_fields[] = {
{ "uid", PAX_UID, PAX_TYPE_UINT, { .uint = pax_uid } },
@@ -239,7 +239,7 @@ static int apply_handler(tar_header_decoded_t *out,
const struct pax_handler_t *field, const char *key,
const char *value, size_t valuelen)
{
- dir_entry_xattr_t *xattr;
+ sqfs_xattr_t *xattr;
sqfs_s64 s64val;
sqfs_u64 uval;
char *copy;
@@ -274,9 +274,9 @@ static int apply_handler(tar_header_decoded_t *out,
}
break;
case PAX_TYPE_PREFIXED_XATTR:
- xattr = dir_entry_xattr_create(key + strlen(field->name) + 1,
- (const sqfs_u8 *)value,
- valuelen);
+ xattr = sqfs_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 f5473ca..039d1fe 100644
--- a/lib/tar/src/write_header.c
+++ b/lib/tar/src/write_header.c
@@ -7,6 +7,7 @@
#include "config.h"
#include "internal.h"
+#include "sqfs/xattr.h"
#include <string.h>
#include <stdlib.h>
@@ -144,15 +145,14 @@ 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 dir_entry_xattr_t *xattr)
+ const char *name, const sqfs_xattr_t *xattr)
{
static const char *prefix = "SCHILY.xattr.";
size_t len, total_size = 0;
- const dir_entry_xattr_t *it;
char *buffer, *ptr;
int ret;
- for (it = xattr; it != NULL; it = it->next) {
+ for (const sqfs_xattr_t *it = xattr; it != NULL; it = it->next) {
len = strlen(prefix) + strlen(it->key) + it->value_len + 3;
total_size += len + prefix_digit_len(len);
@@ -167,7 +167,7 @@ static int write_schily_xattr(ostream_t *fp, const struct stat *orig,
ptr = buffer;
- for (it = xattr; it != NULL; it = it->next) {
+ for (const sqfs_xattr_t *it = xattr; it != NULL; it = it->next) {
len = strlen(prefix) + strlen(it->key) + it->value_len + 3;
len += prefix_digit_len(len);
@@ -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 dir_entry_xattr_t *xattr,
+ const char *slink_target, const sqfs_xattr_t *xattr,
unsigned int counter)
{
const char *reason;
diff --git a/lib/tar/test/tar_write_simple.c b/lib/tar/test/tar_write_simple.c
index 738b469..8a41c8f 100644
--- a/lib/tar/test/tar_write_simple.c
+++ b/lib/tar/test/tar_write_simple.c
@@ -9,6 +9,7 @@
#include "io/ostream.h"
#include "io/file.h"
#include "util/test.h"
+#include "sqfs/xattr.h"
#include "compat.h"
/*****************************************************************************/
@@ -52,7 +53,7 @@ static const char *buffer_get_filename(ostream_t *strm)
#define TIME_STAMP (1057296600)
-static dir_entry_xattr_t *mkxattr_chain(void)
+static sqfs_xattr_t *mkxattr_chain(void)
{
static const uint8_t value[] = {
0x00, 0x00, 0x00, 0x02,
@@ -61,20 +62,20 @@ static dir_entry_xattr_t *mkxattr_chain(void)
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
- dir_entry_xattr_t *list;
+ sqfs_xattr_t *list;
- list = dir_entry_xattr_create("user.mime_type",
- (const sqfs_u8 *)"blob/magic", 10);
+ list = sqfs_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));
+ list->next = sqfs_xattr_create("security.capability",
+ value, sizeof(value));
TEST_NOT_NULL(list->next);
return list;
}
int main(int argc, char **argv)
{
- dir_entry_xattr_t *xattr;
+ sqfs_xattr_t *xattr;
struct stat sb;
istream_t *fp;
int ret;
@@ -154,7 +155,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);
- dir_entry_xattr_list_free(xattr);
+ sqfs_xattr_list_free(xattr);
ret = ostream_append(&mem_stream, ":-)\n", 4);
TEST_EQUAL_I(ret, 0);
diff --git a/lib/tar/test/tar_xattr.c b/lib/tar/test/tar_xattr.c
index 122d1db..1577fc7 100644
--- a/lib/tar/test/tar_xattr.c
+++ b/lib/tar/test/tar_xattr.c
@@ -8,6 +8,7 @@
#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/xattr.h"
int main(int argc, char **argv)
{
diff --git a/lib/tar/test/tar_xattr_bin.c b/lib/tar/test/tar_xattr_bin.c
index 90443a1..129d227 100644
--- a/lib/tar/test/tar_xattr_bin.c
+++ b/lib/tar/test/tar_xattr_bin.c
@@ -8,6 +8,7 @@
#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/xattr.h"
static const uint8_t value[] = {
0x00, 0x00, 0x00, 0x02,