commit:     9aae65c00064cfd661736998402ec21ede5acfbb
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 19 18:19:02 2025 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Apr 19 18:19:02 2025 +0000
URL:        https://gitweb.gentoo.org/proj/elfix.git/commit/?id=9aae65c0

install-xattr: do not fail when listxattr returns ENOTSUP

Bug: https://bugs.gentoo.org/769359
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 misc/install-xattr/install-xattr.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/misc/install-xattr/install-xattr.c 
b/misc/install-xattr/install-xattr.c
index 1f53273..8484f55 100644
--- a/misc/install-xattr/install-xattr.c
+++ b/misc/install-xattr/install-xattr.c
@@ -22,9 +22,11 @@
 
 #include <ctype.h>
 #include <err.h>
+#include <errno.h>
 #include <fnmatch.h>
 #include <getopt.h>
 #include <libgen.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <string.h>
@@ -115,14 +117,22 @@ copyxattr(const char *source, const char *target)
        static char *value = NULL ;    /* string of an xattr name's value       
      */
        static size_t value_size = 0;  /* size of the value string              
      */
 
-       lsize = xlistxattr(source, NULL, 0);
-       lxattr = xmalloc(lsize);
-       xlistxattr(source, lxattr, lsize);
+       lsize = listxattr(source, NULL, 0);
+
+       if (lsize < 0) {
+               perror("listxattr() failed");
+               if (errno == ENOTSUP)
+                       return;
+               exit(1);
+       }
 
        /* There's no xattrs at all. */
        if (lsize == 0)
                return;
 
+       lxattr = xmalloc(lsize);
+       lsize = xlistxattr(source, lxattr, lsize);
+
        i = 0;
        while (1) {
                while (lxattr[i++] == 0)

Reply via email to