Update copyright years
[tar.git] / src / xattrs.c
blob7c00527c466a8cc81b422e7b49f5d458937c8a3d
1 /* Support for extended attributes.
3 Copyright (C) 2006-2022 Free Software Foundation, Inc.
5 This file is part of GNU tar.
7 GNU tar is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 GNU tar is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 Written by James Antill, on 2006-07-27. */
22 #include <config.h>
23 #include <system.h>
25 #include <fnmatch.h>
26 #include <quotearg.h>
28 #include "common.h"
30 #include "xattr-at.h"
31 #include "selinux-at.h"
33 #define XATTRS_PREFIX "SCHILY.xattr."
34 #define XATTRS_PREFIX_LEN (sizeof XATTRS_PREFIX - 1)
36 void
37 xheader_xattr_init (struct tar_stat_info *st)
39 xattr_map_init (&st->xattr_map);
41 st->acls_a_ptr = NULL;
42 st->acls_a_len = 0;
43 st->acls_d_ptr = NULL;
44 st->acls_d_len = 0;
45 st->cntx_name = NULL;
48 void
49 xattr_map_init (struct xattr_map *map)
51 memset (map, 0, sizeof *map);
54 void
55 xattr_map_free (struct xattr_map *xattr_map)
57 size_t i;
59 for (i = 0; i < xattr_map->xm_size; i++)
61 free (xattr_map->xm_map[i].xkey);
62 free (xattr_map->xm_map[i].xval_ptr);
64 free (xattr_map->xm_map);
67 void
68 xattr_map_add (struct xattr_map *map,
69 const char *key, const char *val, size_t len)
71 struct xattr_array *p;
73 if (map->xm_size == map->xm_max)
74 map->xm_map = x2nrealloc (map->xm_map, &map->xm_max,
75 sizeof (map->xm_map[0]));
76 p = &map->xm_map[map->xm_size];
77 p->xkey = xstrdup (key);
78 p->xval_ptr = xmemdup (val, len + 1);
79 p->xval_len = len;
80 map->xm_size++;
83 void
84 xheader_xattr_add (struct tar_stat_info *st,
85 const char *key, const char *val, size_t len)
87 size_t klen = strlen (key);
88 char *xkey = xmalloc (XATTRS_PREFIX_LEN + klen + 1);
89 char *tmp = xkey;
91 tmp = stpcpy (tmp, XATTRS_PREFIX);
92 stpcpy (tmp, key);
94 xattr_map_add (&st->xattr_map, xkey, val, len);
96 free (xkey);
99 void
100 xattr_map_copy (struct xattr_map *dst, const struct xattr_map *src)
102 size_t i;
104 for (i = 0; i < src->xm_size; i++)
105 xattr_map_add (dst, src->xm_map[i].xkey,
106 src->xm_map[i].xval_ptr,
107 src->xm_map[i].xval_len);
110 struct xattrs_mask_map
112 const char **masks;
113 size_t size;
114 size_t used;
117 /* list of fnmatch patterns */
118 static struct
120 /* lists of fnmatch patterns */
121 struct xattrs_mask_map incl;
122 struct xattrs_mask_map excl;
123 } xattrs_setup;
125 /* disable posix acls when problem found in gnulib script m4/acl.m4 */
126 #if ! USE_ACL
127 # undef HAVE_POSIX_ACLS
128 #endif
130 #ifdef HAVE_POSIX_ACLS
131 # include "acl.h"
132 # include <sys/acl.h>
133 #endif
135 #ifdef HAVE_POSIX_ACLS
137 /* acl-at wrappers, TODO: move to gnulib in future? */
138 static acl_t acl_get_file_at (int, const char *, acl_type_t);
139 static int acl_set_file_at (int, const char *, acl_type_t, acl_t);
140 static int file_has_acl_at (int, char const *, struct stat const *);
141 static int acl_delete_def_file_at (int, char const *);
143 /* acl_get_file_at */
144 #define AT_FUNC_NAME acl_get_file_at
145 #define AT_FUNC_RESULT acl_t
146 #define AT_FUNC_FAIL (acl_t)NULL
147 #define AT_FUNC_F1 acl_get_file
148 #define AT_FUNC_POST_FILE_PARAM_DECLS , acl_type_t type
149 #define AT_FUNC_POST_FILE_ARGS , type
150 #include "at-func.c"
151 #undef AT_FUNC_NAME
152 #undef AT_FUNC_F1
153 #undef AT_FUNC_RESULT
154 #undef AT_FUNC_FAIL
155 #undef AT_FUNC_POST_FILE_PARAM_DECLS
156 #undef AT_FUNC_POST_FILE_ARGS
158 /* acl_set_file_at */
159 #define AT_FUNC_NAME acl_set_file_at
160 #define AT_FUNC_F1 acl_set_file
161 #define AT_FUNC_POST_FILE_PARAM_DECLS , acl_type_t type, acl_t acl
162 #define AT_FUNC_POST_FILE_ARGS , type, acl
163 #include "at-func.c"
164 #undef AT_FUNC_NAME
165 #undef AT_FUNC_F1
166 #undef AT_FUNC_POST_FILE_PARAM_DECLS
167 #undef AT_FUNC_POST_FILE_ARGS
169 /* acl_delete_def_file_at */
170 #define AT_FUNC_NAME acl_delete_def_file_at
171 #define AT_FUNC_F1 acl_delete_def_file
172 #define AT_FUNC_POST_FILE_PARAM_DECLS
173 #define AT_FUNC_POST_FILE_ARGS
174 #include "at-func.c"
175 #undef AT_FUNC_NAME
176 #undef AT_FUNC_F1
177 #undef AT_FUNC_POST_FILE_PARAM_DECLS
178 #undef AT_FUNC_POST_FILE_ARGS
180 /* gnulib file_has_acl_at */
181 #define AT_FUNC_NAME file_has_acl_at
182 #define AT_FUNC_F1 file_has_acl
183 #define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat const *st
184 #define AT_FUNC_POST_FILE_ARGS , st
185 #include "at-func.c"
186 #undef AT_FUNC_NAME
187 #undef AT_FUNC_F1
188 #undef AT_FUNC_POST_FILE_PARAM_DECLS
189 #undef AT_FUNC_POST_FILE_ARGS
191 /* convert unix permissions into an ACL ... needed due to "default" ACLs */
192 static acl_t
193 perms2acl (int perms)
195 char val[] = "user::---,group::---,other::---";
196 /* 0123456789 123456789 123456789 123456789 */
198 /* user */
199 if (perms & 0400)
200 val[6] = 'r';
201 if (perms & 0200)
202 val[7] = 'w';
203 if (perms & 0100)
204 val[8] = 'x';
206 /* group */
207 if (perms & 0040)
208 val[17] = 'r';
209 if (perms & 0020)
210 val[18] = 'w';
211 if (perms & 0010)
212 val[19] = 'x';
214 /* other */
215 if (perms & 0004)
216 val[28] = 'r';
217 if (perms & 0002)
218 val[29] = 'w';
219 if (perms & 0001)
220 val[30] = 'x';
222 return acl_from_text (val);
225 static char *
226 skip_to_ext_fields (char *ptr)
228 /* skip tag name (user/group/default/mask) */
229 ptr += strcspn (ptr, ":,\n");
231 if (*ptr != ':')
232 return ptr;
233 ++ptr;
235 ptr += strcspn (ptr, ":,\n"); /* skip user/group name */
237 if (*ptr != ':')
238 return ptr;
239 ++ptr;
241 ptr += strcspn (ptr, ":,\n"); /* skip perms */
243 return ptr;
246 /* The POSIX draft allows extra fields after the three main ones. Star
247 uses this to add a fourth field for user/group which is the numeric ID.
248 This function removes such extra fields by overwriting them with the
249 characters that follow. */
250 static char *
251 fixup_extra_acl_fields (char *ptr)
253 char *src = ptr;
254 char *dst = ptr;
256 while (*src)
258 const char *old = src;
259 size_t len = 0;
261 src = skip_to_ext_fields (src);
262 len = src - old;
263 if (old != dst)
264 memmove (dst, old, len);
265 dst += len;
267 if (*src == ':') /* We have extra fields, skip them all */
268 src += strcspn (src, "\n,");
270 if ((*src == '\n') || (*src == ','))
271 *dst++ = *src++; /* also done when dst == src, but that's ok */
273 if (src != dst)
274 *dst = 0;
276 return ptr;
279 /* Set the "system.posix_acl_access/system.posix_acl_default" extended
280 attribute. Called only when acls_option > 0. */
281 static void
282 xattrs__acls_set (struct tar_stat_info const *st,
283 char const *file_name, int type,
284 char *ptr, size_t len, bool def)
286 acl_t acl;
288 if (ptr)
290 /* assert (strlen (ptr) == len); */
291 ptr = fixup_extra_acl_fields (ptr);
292 acl = acl_from_text (ptr);
294 else if (def)
296 /* No "default" IEEE 1003.1e ACL set for directory. At this moment,
297 FILE_NAME may already have inherited default acls from parent
298 directory; clean them up. */
299 if (acl_delete_def_file_at (chdir_fd, file_name))
300 WARNOPT (WARN_XATTR_WRITE,
301 (0, errno,
302 _("acl_delete_def_file_at: Cannot drop default POSIX ACLs "
303 "for file '%s'"),
304 file_name));
305 return;
307 else
308 acl = perms2acl (st->stat.st_mode);
310 if (!acl)
312 call_arg_warn ("acl_from_text", file_name);
313 return;
316 if (acl_set_file_at (chdir_fd, file_name, type, acl) == -1)
317 /* warn even if filesystem does not support acls */
318 WARNOPT (WARN_XATTR_WRITE,
319 (0, errno,
320 _ ("acl_set_file_at: Cannot set POSIX ACLs for file '%s'"),
321 file_name));
323 acl_free (acl);
326 /* Cleanup textual representation of the ACL in VAL by eliminating tab
327 characters and comments */
328 static void
329 xattrs_acls_cleanup (char *val, size_t *plen)
331 char *p, *q;
333 p = q = val + strcspn (val, "#\t");
334 while (*q)
336 if (*q == '\t')
337 q++;
338 else if (*q == '#')
340 while (*q != '\n')
341 q++;
343 else
344 *p++ = *q++;
346 *plen = p - val;
347 *p++ = 0;
350 static void
351 xattrs__acls_get_a (int parentfd, const char *file_name,
352 struct tar_stat_info *st,
353 char **ret_ptr, size_t * ret_len)
355 char *val = NULL;
356 acl_t acl;
358 if (!(acl = acl_get_file_at (parentfd, file_name, ACL_TYPE_ACCESS)))
360 if (errno != ENOTSUP)
361 call_arg_warn ("acl_get_file_at", file_name);
362 return;
365 val = acl_to_text (acl, NULL);
366 acl_free (acl);
368 if (!val)
370 call_arg_warn ("acl_to_text", file_name);
371 return;
374 *ret_ptr = xstrdup (val);
375 xattrs_acls_cleanup (*ret_ptr, ret_len);
376 acl_free (val);
379 /* "system.posix_acl_default" */
380 static void
381 xattrs__acls_get_d (int parentfd, char const *file_name,
382 struct tar_stat_info *st,
383 char **ret_ptr, size_t * ret_len)
385 char *val = NULL;
386 acl_t acl;
388 if (!(acl = acl_get_file_at (parentfd, file_name, ACL_TYPE_DEFAULT)))
390 if (errno != ENOTSUP)
391 call_arg_warn ("acl_get_file_at", file_name);
392 return;
395 val = acl_to_text (acl, NULL);
396 acl_free (acl);
398 if (!val)
400 call_arg_warn ("acl_to_text", file_name);
401 return;
404 *ret_ptr = xstrdup (val);
405 xattrs_acls_cleanup (*ret_ptr, ret_len);
406 acl_free (val);
408 #endif /* HAVE_POSIX_ACLS */
410 static void
411 acls_one_line (const char *prefix, char delim,
412 const char *aclstring, size_t len)
414 /* support both long and short text representation of posix acls */
415 struct obstack stk;
416 int pref_len = strlen (prefix);
417 const char *oldstring = aclstring;
418 int pos = 0;
420 if (!aclstring || !len)
421 return;
423 obstack_init (&stk);
424 while (pos <= len)
426 int move = strcspn (aclstring, ",\n");
427 if (!move)
428 break;
430 if (oldstring != aclstring)
431 obstack_1grow (&stk, delim);
433 obstack_grow (&stk, prefix, pref_len);
434 obstack_grow (&stk, aclstring, move);
436 pos += move + 1;
437 aclstring += move + 1;
440 obstack_1grow (&stk, '\0');
442 fprintf (stdlis, "%s", (char *) obstack_finish (&stk));
444 obstack_free (&stk, NULL);
447 void
448 xattrs_acls_get (int parentfd, char const *file_name,
449 struct tar_stat_info *st, int fd, int xisfile)
451 if (acls_option > 0)
453 #ifndef HAVE_POSIX_ACLS
454 static int done = 0;
455 if (!done)
456 WARN ((0, 0, _("POSIX ACL support is not available")));
457 done = 1;
458 #else
459 int err = file_has_acl_at (parentfd, file_name, &st->stat);
460 if (err == 0)
461 return;
462 if (err == -1)
464 call_arg_warn ("file_has_acl_at", file_name);
465 return;
468 xattrs__acls_get_a (parentfd, file_name, st,
469 &st->acls_a_ptr, &st->acls_a_len);
470 if (!xisfile)
471 xattrs__acls_get_d (parentfd, file_name, st,
472 &st->acls_d_ptr, &st->acls_d_len);
473 #endif
477 void
478 xattrs_acls_set (struct tar_stat_info const *st,
479 char const *file_name, char typeflag)
481 if (acls_option > 0 && typeflag != SYMTYPE)
483 #ifndef HAVE_POSIX_ACLS
484 static int done = 0;
485 if (!done)
486 WARN ((0, 0, _("POSIX ACL support is not available")));
487 done = 1;
488 #else
489 xattrs__acls_set (st, file_name, ACL_TYPE_ACCESS,
490 st->acls_a_ptr, st->acls_a_len, false);
491 if (typeflag == DIRTYPE || typeflag == GNUTYPE_DUMPDIR)
492 xattrs__acls_set (st, file_name, ACL_TYPE_DEFAULT,
493 st->acls_d_ptr, st->acls_d_len, true);
494 #endif
498 static void
499 mask_map_realloc (struct xattrs_mask_map *map)
501 if (map->used == map->size)
503 if (map->size == 0)
504 map->size = 4;
505 map->masks = x2nrealloc (map->masks, &map->size, sizeof (map->masks[0]));
509 void
510 xattrs_mask_add (const char *mask, bool incl)
512 struct xattrs_mask_map *mask_map =
513 incl ? &xattrs_setup.incl : &xattrs_setup.excl;
514 /* ensure there is enough space */
515 mask_map_realloc (mask_map);
516 /* just assign pointers -- we silently expect that pointer "mask" is valid
517 through the whole program (pointer to argv array) */
518 mask_map->masks[mask_map->used++] = mask;
521 static void
522 clear_mask_map (struct xattrs_mask_map *mask_map)
524 if (mask_map->size)
525 free (mask_map->masks);
528 void
529 xattrs_clear_setup (void)
531 clear_mask_map (&xattrs_setup.incl);
532 clear_mask_map (&xattrs_setup.excl);
535 static bool xattrs_masked_out (const char *kw, bool archiving);
537 /* get xattrs from file given by FILE_NAME or FD (when non-zero)
538 xattrs are checked against the user supplied include/exclude mask
539 if no mask is given this includes all the user.*, security.*, system.*,
540 etc. available domains */
541 void
542 xattrs_xattrs_get (int parentfd, char const *file_name,
543 struct tar_stat_info *st, int fd)
545 if (xattrs_option > 0)
547 #ifndef HAVE_XATTRS
548 static int done = 0;
549 if (!done)
550 WARN ((0, 0, _("XATTR support is not available")));
551 done = 1;
552 #else
553 static size_t xsz = 1024;
554 static char *xatrs = NULL;
555 ssize_t xret = -1;
557 if (!xatrs)
558 xatrs = x2nrealloc (xatrs, &xsz, 1);
560 while (((fd == 0) ?
561 ((xret =
562 llistxattrat (parentfd, file_name, xatrs, xsz)) == -1) :
563 ((xret = flistxattr (fd, xatrs, xsz)) == -1))
564 && (errno == ERANGE))
566 xatrs = x2nrealloc (xatrs, &xsz, 1);
569 if (xret == -1)
570 call_arg_warn ((fd == 0) ? "llistxattrat" : "flistxattr", file_name);
571 else
573 const char *attr = xatrs;
574 static size_t asz = 1024;
575 static char *val = NULL;
577 if (!val)
578 val = x2nrealloc (val, &asz, 1);
580 while (xret > 0)
582 size_t len = strlen (attr);
583 ssize_t aret = 0;
585 while (((fd == 0)
586 ? ((aret = lgetxattrat (parentfd, file_name, attr,
587 val, asz)) == -1)
588 : ((aret = fgetxattr (fd, attr, val, asz)) == -1))
589 && (errno == ERANGE))
591 val = x2nrealloc (val, &asz, 1);
594 if (aret != -1)
596 if (!xattrs_masked_out (attr, true))
597 xheader_xattr_add (st, attr, val, aret);
599 else if (errno != ENOATTR)
600 call_arg_warn ((fd == 0) ? "lgetxattrat"
601 : "fgetxattr", file_name);
603 attr += len + 1;
604 xret -= len + 1;
607 #endif
611 #ifdef HAVE_XATTRS
612 static void
613 xattrs__fd_set (struct tar_stat_info const *st,
614 char const *file_name, char typeflag,
615 const char *attr, const char *ptr, size_t len)
617 if (ptr)
619 const char *sysname = "setxattrat";
620 int ret = -1;
622 if (typeflag != SYMTYPE)
623 ret = setxattrat (chdir_fd, file_name, attr, ptr, len, 0);
624 else
626 sysname = "lsetxattr";
627 ret = lsetxattrat (chdir_fd, file_name, attr, ptr, len, 0);
630 if (ret == -1)
631 WARNOPT (WARN_XATTR_WRITE,
632 (0, errno,
633 _("%s: Cannot set '%s' extended attribute for file '%s'"),
634 sysname, attr, file_name));
637 #endif
639 /* lgetfileconat is called against FILE_NAME iff the FD parameter is set to
640 zero, otherwise the fgetfileconat is used against correct file descriptor */
641 void
642 xattrs_selinux_get (int parentfd, char const *file_name,
643 struct tar_stat_info *st, int fd)
645 if (selinux_context_option > 0)
647 #if HAVE_SELINUX_SELINUX_H != 1
648 static int done = 0;
649 if (!done)
650 WARN ((0, 0, _("SELinux support is not available")));
651 done = 1;
652 #else
653 int result = fd ?
654 fgetfilecon (fd, &st->cntx_name)
655 : lgetfileconat (parentfd, file_name, &st->cntx_name);
657 if (result == -1 && errno != ENODATA && errno != ENOTSUP)
658 call_arg_warn (fd ? "fgetfilecon" : "lgetfileconat", file_name);
659 #endif
663 void
664 xattrs_selinux_set (struct tar_stat_info const *st,
665 char const *file_name, char typeflag)
667 if (selinux_context_option > 0)
669 #if HAVE_SELINUX_SELINUX_H != 1
670 static int done = 0;
671 if (!done)
672 WARN ((0, 0, _("SELinux support is not available")));
673 done = 1;
674 #else
675 const char *sysname = "setfilecon";
676 int ret;
678 if (!st->cntx_name)
679 return;
681 if (typeflag != SYMTYPE)
683 ret = setfileconat (chdir_fd, file_name, st->cntx_name);
684 sysname = "setfileconat";
686 else
688 ret = lsetfileconat (chdir_fd, file_name, st->cntx_name);
689 sysname = "lsetfileconat";
692 if (ret == -1)
693 WARNOPT (WARN_XATTR_WRITE,
694 (0, errno,
695 _("%s: Cannot set SELinux context for file '%s'"),
696 sysname, file_name));
697 #endif
701 static bool
702 xattrs_matches_mask (const char *kw, struct xattrs_mask_map *mm)
704 int i;
706 if (!mm->size)
707 return false;
709 for (i = 0; i < mm->used; i++)
710 if (fnmatch (mm->masks[i], kw, 0) == 0)
711 return true;
713 return false;
716 #define USER_DOT_PFX "user."
718 static bool
719 xattrs_kw_included (const char *kw, bool archiving)
721 if (xattrs_setup.incl.size)
722 return xattrs_matches_mask (kw, &xattrs_setup.incl);
723 else if (archiving)
724 return true;
725 else
726 return strncmp (kw, USER_DOT_PFX, sizeof (USER_DOT_PFX) - 1) == 0;
729 static bool
730 xattrs_kw_excluded (const char *kw, bool archiving)
732 return xattrs_setup.excl.size ?
733 xattrs_matches_mask (kw, &xattrs_setup.excl) : false;
736 /* Check whether the xattr with keyword KW should be discarded from list of
737 attributes that are going to be archived/excluded (set ARCHIVING=true for
738 archiving, false for excluding) */
739 static bool
740 xattrs_masked_out (const char *kw, bool archiving)
742 return xattrs_kw_included (kw, archiving) ?
743 xattrs_kw_excluded (kw, archiving) : true;
746 void
747 xattrs_xattrs_set (struct tar_stat_info const *st,
748 char const *file_name, char typeflag, int later_run)
750 if (xattrs_option > 0)
752 #ifndef HAVE_XATTRS
753 static int done = 0;
754 if (!done)
755 WARN ((0, 0, _("XATTR support is not available")));
756 done = 1;
757 #else
758 size_t i;
760 if (!st->xattr_map.xm_size)
761 return;
763 for (i = 0; i < st->xattr_map.xm_size; i++)
765 char *keyword = st->xattr_map.xm_map[i].xkey + XATTRS_PREFIX_LEN;
767 /* TODO: this 'later_run' workaround is temporary solution -> once
768 capabilities should become fully supported by it's API and there
769 should exist something like xattrs_capabilities_set() call.
770 For a regular files: all extended attributes are restored during
771 the first run except 'security.capability' which is restored in
772 'later_run == 1'. */
773 if (typeflag == REGTYPE
774 && later_run == !!strcmp (keyword, "security.capability"))
775 continue;
777 if (xattrs_masked_out (keyword, false /* extracting */ ))
778 /* we don't want to restore this keyword */
779 continue;
781 xattrs__fd_set (st, file_name, typeflag, keyword,
782 st->xattr_map.xm_map[i].xval_ptr,
783 st->xattr_map.xm_map[i].xval_len);
785 #endif
789 void
790 xattrs_print_char (struct tar_stat_info const *st, char *output)
792 int i;
794 if (verbose_option < 2)
796 *output = 0;
797 return;
800 if (xattrs_option > 0 || selinux_context_option > 0 || acls_option > 0)
802 /* placeholders */
803 *output = ' ';
804 output[1] = 0;
807 if (xattrs_option > 0 && st->xattr_map.xm_size)
808 for (i = 0; i < st->xattr_map.xm_size; ++i)
810 char *keyword = st->xattr_map.xm_map[i].xkey + XATTRS_PREFIX_LEN;
811 if (!xattrs_masked_out (keyword, false /* like extracting */ ))
813 *output = '*';
814 break;
818 if (selinux_context_option > 0 && st->cntx_name)
819 *output = '.';
821 if (acls_option > 0 && (st->acls_a_len || st->acls_d_len))
822 *output = '+';
825 void
826 xattrs_print (struct tar_stat_info const *st)
828 if (verbose_option < 3)
829 return;
831 /* selinux */
832 if (selinux_context_option > 0 && st->cntx_name)
833 fprintf (stdlis, " s: %s\n", st->cntx_name);
835 /* acls */
836 if (acls_option > 0 && (st->acls_a_len || st->acls_d_len))
838 fprintf (stdlis, " a: ");
839 acls_one_line ("", ',', st->acls_a_ptr, st->acls_a_len);
840 if (st->acls_a_len && st->acls_d_len)
841 fprintf (stdlis, ",");
842 acls_one_line ("default:", ',', st->acls_d_ptr, st->acls_d_len);
843 fprintf (stdlis, "\n");
846 /* xattrs */
847 if (xattrs_option > 0 && st->xattr_map.xm_size)
849 int i;
851 for (i = 0; i < st->xattr_map.xm_size; ++i)
853 char *keyword = st->xattr_map.xm_map[i].xkey + XATTRS_PREFIX_LEN;
854 if (!xattrs_masked_out (keyword, false /* like extracting */ ))
855 fprintf (stdlis, " x: %lu %s\n",
856 (unsigned long) st->xattr_map.xm_map[i].xval_len, keyword);