The Hurd gained[0] support for moving the translator and author
fields out of the inode and into the "gnu.*" xattr namespace.

In anticipation of that, an xattr INDEX was reserved[1].  The Hurd has
now been brought into compliance[2] with that, and so has ext4[3].

[0] https://summerofcode.withgoogle.com/projects/#5869799859027968
[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3980bd3b406addb327d858aebd19e229ea340b9a
[2] 
https://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=a04c7bf83172faa7cb080fbe3b6c04a8415ca645
[3] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=88ee9d571b6d8ed345f877e05f685814412e359b

* src/xattrs.c (xattrs_kw_included): Cater for "gnu." prefix too.
* tests/testsuite.at (AT_XATTRS_GNU_PREREQ): New macro.
* tests/xattr09.at: Use it in new test.
* tests/Makefile.am,
tests/testsuite.at: Add it.
---
 src/xattrs.c       |  4 +++-
 tests/Makefile.am  |  1 +
 tests/testsuite.at | 11 +++++++++++
 tests/xattr09.at   | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 tests/xattr09.at

diff --git a/src/xattrs.c b/src/xattrs.c
index 4f5872c1..7ad4b179 100644
--- a/src/xattrs.c
+++ b/src/xattrs.c
@@ -706,12 +706,14 @@ static bool
 xattrs_kw_included (const char *kw, bool archiving)
 {
   static char const USER_DOT_PFX[] = "user.";
+  static char const GNU_DOT_PFX[] = "gnu.";
   if (xattrs_setup.incl.size)
     return xattrs_matches_mask (kw, &xattrs_setup.incl);
   else if (archiving)
     return true;
   else
-    return strncmp (kw, USER_DOT_PFX, sizeof (USER_DOT_PFX) - 1) == 0;
+    return strncmp (kw, USER_DOT_PFX, sizeof (USER_DOT_PFX) - 1) == 0
+      || strncmp (kw, GNU_DOT_PFX, sizeof (GNU_DOT_PFX) - 1) == 0;
 }
 
 static bool
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0625b021..2c468d0b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -294,6 +294,7 @@ TESTSUITE_AT = \
  xattr06.at\
  xattr07.at\
  xattr08.at\
+ xattr09.at\
  xform-h.at\
  xform01.at\
  xform02.at\
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 5979512a..776978a9 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -172,6 +172,16 @@ m4_define([AT_XATTRS_PREREQ],[
     AT_SKIP_TEST
   fi
 ])
+m4_define([AT_XATTRS_GNU_PREREQ],[
+  AT_XATTRS_UTILS_PREREQ
+  file=$(TMPDIR=. mktemp fiXXXXXX)
+  setfattr -n gnu.test -v ahoj $file
+  # check whether tar fails to store xattrs
+  err=$( tar --xattrs -cf /dev/null $file 2>&1 >/dev/null | wc -l )
+  if test "$err" != "0"; then
+    AT_SKIP_TEST
+  fi
+])
 m4_define([AT_SELINUX_PREREQ],[
   AT_SELINUX_UTILS_PREREQ
   file=$(TMPDIR=. mktemp fiXXXXXX)
@@ -519,6 +529,7 @@ m4_include([xattr05.at])
 m4_include([xattr06.at])
 m4_include([xattr07.at])
 m4_include([xattr08.at])
+m4_include([xattr09.at])
 
 m4_include([acls01.at])
 m4_include([acls02.at])
diff --git a/tests/xattr09.at b/tests/xattr09.at
new file mode 100644
index 00000000..a4e4b481
--- /dev/null
+++ b/tests/xattr09.at
@@ -0,0 +1,49 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+#
+# Test suite for GNU tar.
+# Copyright 2026 Free Software Foundation, Inc.
+
+# This file is part of GNU tar.
+
+# GNU tar is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# GNU tar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Test description:
+#
+# This tests basic support for gnu. namespace extended attributes.
+
+AT_SETUP([xattrs: basic gnu. namespace functionality])
+AT_KEYWORDS([xattrs xattr09 gnu])
+
+AT_TAR_CHECK([
+AT_XATTRS_GNU_PREREQ
+mkdir dir
+genfile --file dir/file
+
+setfattr -n gnu.test -v OurDirValue dir
+setfattr -n gnu.test -v OurFileValue dir/file
+
+tar --xattrs -cf archive.tar dir
+
+rm -rf dir
+tar --xattrs -xf archive.tar
+
+getfattr -h -n gnu.test dir         | grep -v -e '^#' -e ^$
+getfattr -h -n gnu.test dir/file    | grep -v -e '^#' -e ^$
+],
+[0],
+[gnu.test="OurDirValue"
+gnu.test="OurFileValue"
+])
+
+AT_CLEANUP
-- 
2.54.0


-- 
Reasonable | Free Software for Correctness | GNU Dezyne -- https://dezyne.org
+Sourcery+ | Correctness for Free Software | https://reasonable-sourcery.coop

Reply via email to