Subject: FTBFS on CentOS 6

From: Bruno Haible <[email-masked]>
Date: Thu, 16 Jan 2025 20:39:43 +0100

Building a snapshot of the current coreutils with current gnulib, I get
a compilation error on CentOS 5 and 6:

  CC       src/ls.o
../src/ls.c: In function 'gobble_file':
../src/ls.c:3556: error: 'XATTR_NAME_CAPS' undeclared (first use in this function)
../src/ls.c:3556: error: (Each undeclared identifier is reported only once
../src/ls.c:3556: error: for each function it appears in.)
make[2]: *** [src/ls.o] Error 1

The attached proposed patch fixes it.
This is a similar problem as we encountered in gnulib:
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=3266c08a315
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=73a13b94b94
The lesson is: Provide fallbacks for *all* XATTR_NAME_* values, since older
distros don't define them.

>From 79f8060636fcd1a7b92d07a973ed07c6ff1f9a04 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email-masked]>
Date: Thu, 16 Jan 2025 20:31:08 +0100
Subject: [PATCH] ls: Fix compilation error on CentOS 6

* src/ls.c (XATTR_NAME_CAPS): Define fallback.
---
 src/ls.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/ls.c b/src/ls.c
index a64ed57ab..321536021 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -122,6 +122,9 @@
 
 #if HAVE_LINUX_XATTR_H
 # include <linux/xattr.h>
+# ifndef XATTR_NAME_CAPS
+#  define XATTR_NAME_CAPS "security.capability"
+# endif
 #endif
 
 #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \
-- 
2.43.0