From f017b99a77032d7da6ac3de854d9ac7185cb8f0c Mon Sep 17 00:00:00 2001 From: Morgan Weetman Date: Tue, 6 Jan 2015 13:54:49 +1100 Subject: [PATCH 4/8] find: -xattr now obeys symlink handling options * find/pred.c (pred_xattr): added tests for options.symlink_handling --- find/pred.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/find/pred.c b/find/pred.c index 37e9f0e..ddf9917 100644 --- a/find/pred.c +++ b/find/pred.c @@ -1169,7 +1169,11 @@ pred_xattr (const char *pathname, struct stat *stat_buf, struct predicate *pred_ bool ret = false; // get size of xattr list for the given path by passing an empty list - list_size = listxattr(pathname, empty, 0); + if (options.symlink_handling == SYMLINK_NEVER_DEREF) { + list_size = llistxattr(pathname, empty, 0); + } else { + list_size = listxattr(pathname, empty, 0); + } // allocate just enough memory to hold all xattrs list = malloc(list_size); @@ -1179,7 +1183,11 @@ pred_xattr (const char *pathname, struct stat *stat_buf, struct predicate *pred_ substrings = malloc(list_size); // retrieve the list of xattrs - listxattr(pathname, list, list_size); + if (options.symlink_handling == SYMLINK_NEVER_DEREF) { + llistxattr(pathname, list, list_size); + } else { + listxattr(pathname, list, list_size); + } // break list into asciiz strings for (i = 0, j = 0; i < list_size; i++) { -- 1.9.3