Provide functions for manipulating arrays of extended attributes

* src/common.h (xheader_xattr_free,xheader_xattr_copy): Remove protos.
(xattr_map_init,xattr_map_copy)
(xattr_map_add,xattr_map_free): New protos.
* src/tar.h (xattr_map): New struct.
(tar_stat_info): Replace xattr_map_size and xattr_map with one
field: xattr_map.
* src/xattrs.c (XATTRS_PREFIX,XATTRS_PREFIX_LEN): New defines.
(xheader_xattr_init,xattr_map_init)
(xattr_map_free,xattr_map_add)
(xheader_xattr_add,xattr_map_copy): New functions.
All uses changed.
* src/create.c (start_header): Update to use struct xattr_map.
* src/extract.c: Update to use struct xattr_map.
* src/tar.c: Likewise.
* src/xheader.c (xheader_xattr_init,xheader_xattr_free)
(xheader_xattr_add,xheader_xattr_copy): Remove.
(xattr_coder,xattr_decoder): Use xattr_map_ functions.
This commit is contained in:
Sergey Poznyakoff
2021-09-02 21:01:58 +03:00
parent a339f05cd2
commit 66262c10d1
7 changed files with 123 additions and 134 deletions
+3 -8
View File
@@ -966,14 +966,9 @@ start_header (struct tar_stat_info *st)
xheader_store ("RHT.security.selinux", st, NULL);
if (xattrs_option > 0)
{
size_t scan_xattr = 0;
struct xattr_array *xattr_map = st->xattr_map;
while (scan_xattr < st->xattr_map_size)
{
xheader_store (xattr_map[scan_xattr].xkey, st, &scan_xattr);
++scan_xattr;
}
size_t i;
for (i = 0; i < st->xattr_map.xm_size; i++)
xheader_store (st->xattr_map.xm_map[i].xkey, st, &i);
}
}