summaryrefslogtreecommitdiff
path: root/getfattr
diff options
context:
space:
mode:
Diffstat (limited to 'getfattr')
-rw-r--r--getfattr/getfattr.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/getfattr/getfattr.c b/getfattr/getfattr.c
index 94d3653..09115ec 100644
--- a/getfattr/getfattr.c
+++ b/getfattr/getfattr.c
@@ -347,15 +347,9 @@ int list_attributes(const char *path, int *header_printed)
int do_print(const char *path, const struct stat *stat,
int flag, struct FTW *ftw)
{
+ int saved_errno = errno;
int header_printed = 0;
- if (flag == FTW_DNR) {
- /* Item is a directory which can't be read. */
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(path),
- strerror(errno));
- return 0;
- }
-
/*
* Process the target of a symbolic link, and traverse the
* link, only if doing a logical walk, or if the symbolic link
@@ -375,6 +369,13 @@ int do_print(const char *path, const struct stat *stat,
if (header_printed)
puts("");
+ if (flag == FTW_DNR && opt_recursive) {
+ /* Item is a directory which can't be read. */
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(path),
+ strerror(saved_errno));
+ return 0;
+ }
+
/*
* We also get here in non-recursive mode. In that case,
* return something != 0 to abort nftw.