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