|
|
c1f565 |
From c3fa3829e494c1875416058bb8d448a89f9e5e55 Mon Sep 17 00:00:00 2001
|
|
|
c1f565 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
c1f565 |
Date: Wed, 22 Dec 2010 14:13:27 +0100
|
|
|
c1f565 |
Subject: [PATCH] getfattr: return non-zero exit code on failure
|
|
|
c1f565 |
MIME-Version: 1.0
|
|
|
c1f565 |
Content-Type: text/plain; charset=UTF-8
|
|
|
c1f565 |
Content-Transfer-Encoding: 8bit
|
|
|
c1f565 |
|
|
|
c1f565 |
reported by Jean-Pierre André at https://bugzilla.redhat.com/660619
|
|
|
c1f565 |
---
|
|
|
c1f565 |
getfattr/getfattr.c | 7 ++++---
|
|
|
c1f565 |
test/attr.test | 4 ++++
|
|
|
c1f565 |
2 files changed, 8 insertions(+), 3 deletions(-)
|
|
|
c1f565 |
|
|
|
c1f565 |
diff --git a/getfattr/getfattr.c b/getfattr/getfattr.c
|
|
|
c1f565 |
index 7ced700..d8a7bc5 100644
|
|
|
c1f565 |
--- a/getfattr/getfattr.c
|
|
|
c1f565 |
+++ b/getfattr/getfattr.c
|
|
|
c1f565 |
@@ -355,6 +355,7 @@ int do_print(const char *path, const struct stat *stat, int walk_flags,
|
|
|
c1f565 |
void *unused)
|
|
|
c1f565 |
{
|
|
|
c1f565 |
int header_printed = 0;
|
|
|
c1f565 |
+ int err = 0;
|
|
|
c1f565 |
|
|
|
c1f565 |
if (walk_flags & WALK_TREE_FAILED) {
|
|
|
c1f565 |
fprintf(stderr, "%s: %s: %s\n", progname, xquote(path, "\n\r"),
|
|
|
c1f565 |
@@ -363,13 +364,13 @@ int do_print(const char *path, const struct stat *stat, int walk_flags,
|
|
|
c1f565 |
}
|
|
|
c1f565 |
|
|
|
c1f565 |
if (opt_name)
|
|
|
c1f565 |
- print_attribute(path, opt_name, &header_printed);
|
|
|
c1f565 |
+ err = print_attribute(path, opt_name, &header_printed);
|
|
|
c1f565 |
else
|
|
|
c1f565 |
- list_attributes(path, &header_printed);
|
|
|
c1f565 |
+ err = list_attributes(path, &header_printed);
|
|
|
c1f565 |
|
|
|
c1f565 |
if (header_printed)
|
|
|
c1f565 |
puts("");
|
|
|
c1f565 |
- return 0;
|
|
|
c1f565 |
+ return err;
|
|
|
c1f565 |
}
|
|
|
c1f565 |
|
|
|
c1f565 |
void help(void)
|
|
|
c1f565 |
diff --git a/test/attr.test b/test/attr.test
|
|
|
c1f565 |
index e8f134c..10f10d0 100644
|
|
|
c1f565 |
--- a/test/attr.test
|
|
|
c1f565 |
+++ b/test/attr.test
|
|
|
c1f565 |
@@ -22,6 +22,10 @@ Try various valid and invalid names
|
|
|
c1f565 |
> user.name
|
|
|
c1f565 |
>
|
|
|
c1f565 |
|
|
|
c1f565 |
+ $ setfattr -x user.name f
|
|
|
c1f565 |
+ $ sh -c 'getfattr -n user.name f && echo zero exit code'
|
|
|
c1f565 |
+ > f: user.name: No such attribute
|
|
|
c1f565 |
+
|
|
|
c1f565 |
$ setfattr -n user.n -v value f
|
|
|
c1f565 |
$ rm f
|
|
|
c1f565 |
|
|
|
c1f565 |
--
|
|
|
c1f565 |
1.7.3.3
|
|
|
c1f565 |
|