Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-07-17 10:36:17 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-07-17 10:36:17 +0300
commita6a102ec4c8d96fcfb968c88fbdae80f6142c7bf (patch)
tree57f620201e15a86c3a97a29677f805e10afe52f4
parentcf809e2f2dbf699035e4841e45070b947374a989 (diff)
getfattr: fix "getfattr NOTEXIST" - now prints error msg
function old new delta getfattr_main 309 307 -2 .rodata 105395 105391 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/getfattr.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/miscutils/getfattr.c b/miscutils/getfattr.c
index 59b6f6bca..905aec65f 100644
--- a/miscutils/getfattr.c
+++ b/miscutils/getfattr.c
@@ -31,6 +31,7 @@
enum {
OPT_h = (1 << 0),
OPT_d = (1 << 1),
+ OPT_n = (1 << 2),
};
static int print_attr(const char *file, const char *name, char **buf, size_t *bufsize)
@@ -85,8 +86,9 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv)
opt = getopt32(argv, "^"
"hdn:"
- /* Min one arg; exactly one of -n or -d is required. */
- "\0" "-1:d:n:n--d:d--n"
+ /* Min one arg; -d and -n are exclusive */
+ "\0" "-1:n--d:d--n"
+ //getfattr 2.5.1 does not enforce this: ":d:n" /* exactly one of -n or -d is required */
, &name
);
argv += optind;
@@ -94,8 +96,11 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv)
do {
int r;
- if (opt & OPT_d) {
+//getfattr 2.5.1 with no -n/-d defaults to -d
+ if (!(opt & OPT_n)) {
ssize_t len = list_attr(*argv, &list, &listsize);
+ if (len < 0)
+ goto err;
if (len > 0) {
char *key;
printf("# file: %s\n", *argv);
@@ -118,7 +123,7 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv)
err:
bb_simple_perror_msg(*argv);
status = EXIT_FAILURE;
- // continue; maybe?
+ continue;
}
bb_putchar('\n');
}