diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-07-17 09:36:17 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-07-17 09:36:17 +0200 |
| commit | a6a102ec4c8d96fcfb968c88fbdae80f6142c7bf (patch) | |
| tree | 57f620201e15a86c3a97a29677f805e10afe52f4 /miscutils | |
| parent | cf809e2f2dbf699035e4841e45070b947374a989 (diff) | |
| download | busybox-w32-a6a102ec4c8d96fcfb968c88fbdae80f6142c7bf.tar.gz busybox-w32-a6a102ec4c8d96fcfb968c88fbdae80f6142c7bf.tar.bz2 busybox-w32-a6a102ec4c8d96fcfb968c88fbdae80f6142c7bf.zip | |
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>
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/getfattr.c | 13 |
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 @@ | |||
| 31 | enum { | 31 | enum { |
| 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 | ||
| 36 | static int print_attr(const char *file, const char *name, char **buf, size_t *bufsize) | 37 | 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) | |||
| 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 | } |
