aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
31enum { 31enum {
32 OPT_h = (1 << 0), 32 OPT_h = (1 << 0),
33 OPT_d = (1 << 1), 33 OPT_d = (1 << 1),
34 OPT_n = (1 << 2),
34}; 35};
35 36
36static int print_attr(const char *file, const char *name, char **buf, size_t *bufsize) 37static 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)
85 86
86 opt = getopt32(argv, "^" 87 opt = getopt32(argv, "^"
87 "hdn:" 88 "hdn:"
88 /* Min one arg; exactly one of -n or -d is required. */ 89 /* Min one arg; -d and -n are exclusive */
89 "\0" "-1:d:n:n--d:d--n" 90 "\0" "-1:n--d:d--n"
91 //getfattr 2.5.1 does not enforce this: ":d:n" /* exactly one of -n or -d is required */
90 , &name 92 , &name
91 ); 93 );
92 argv += optind; 94 argv += optind;
@@ -94,8 +96,11 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv)
94 96
95 do { 97 do {
96 int r; 98 int r;
97 if (opt & OPT_d) { 99//getfattr 2.5.1 with no -n/-d defaults to -d
100 if (!(opt & OPT_n)) {
98 ssize_t len = list_attr(*argv, &list, &listsize); 101 ssize_t len = list_attr(*argv, &list, &listsize);
102 if (len < 0)
103 goto err;
99 if (len > 0) { 104 if (len > 0) {
100 char *key; 105 char *key;
101 printf("# file: %s\n", *argv); 106 printf("# file: %s\n", *argv);
@@ -118,7 +123,7 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv)
118 err: 123 err:
119 bb_simple_perror_msg(*argv); 124 bb_simple_perror_msg(*argv);
120 status = EXIT_FAILURE; 125 status = EXIT_FAILURE;
121 // continue; maybe? 126 continue;
122 } 127 }
123 bb_putchar('\n'); 128 bb_putchar('\n');
124 } 129 }