diff options
-rw-r--r-- | e2fsprogs/chattr.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c index b424e797b..1b12c9f37 100644 --- a/e2fsprogs/chattr.c +++ b/e2fsprogs/chattr.c | |||
@@ -85,7 +85,9 @@ static char** decode_arg(char **argv, struct globals *gp) | |||
85 | 85 | ||
86 | fl = &gp->af; | 86 | fl = &gp->af; |
87 | if (opt == '-') { | 87 | if (opt == '-') { |
88 | gp->flags |= OPT_REM; | 88 | /* gp->flags |= OPT_REM; - WRONG, it can be an option */ |
89 | /* testcase: chattr =ae -R FILE should not complain "= is incompatible with - and +" */ | ||
90 | /* (and should not read flags, with =FLAGS they can be just set directly) */ | ||
89 | fl = &gp->rf; | 91 | fl = &gp->rf; |
90 | } else if (opt == '+') { | 92 | } else if (opt == '+') { |
91 | gp->flags |= OPT_ADD; | 93 | gp->flags |= OPT_ADD; |
@@ -115,7 +117,7 @@ static char** decode_arg(char **argv, struct globals *gp) | |||
115 | if (*arg == 'v') { | 117 | if (*arg == 'v') { |
116 | if (!*++argv) | 118 | if (!*++argv) |
117 | bb_show_usage(); | 119 | bb_show_usage(); |
118 | gp->version = xatoul(*argv); | 120 | gp->version = xatou(*argv); |
119 | gp->flags |= OPT_SET_VER; | 121 | gp->flags |= OPT_SET_VER; |
120 | continue; | 122 | continue; |
121 | } | 123 | } |
@@ -127,8 +129,9 @@ static char** decode_arg(char **argv, struct globals *gp) | |||
127 | continue; | 129 | continue; |
128 | } | 130 | } |
129 | /* not a known option, try as an attribute */ | 131 | /* not a known option, try as an attribute */ |
132 | gp->flags |= OPT_REM; | ||
130 | } | 133 | } |
131 | *fl |= get_flag(*arg); | 134 | *fl |= get_flag(*arg); /* aborts on bad flag letter */ |
132 | } | 135 | } |
133 | 136 | ||
134 | return argv; | 137 | return argv; |
@@ -241,7 +244,7 @@ int chattr_main(int argc UNUSED_PARAM, char **argv) | |||
241 | if (g.rf & g.af) | 244 | if (g.rf & g.af) |
242 | bb_simple_error_msg_and_die("can't set and unset a flag"); | 245 | bb_simple_error_msg_and_die("can't set and unset a flag"); |
243 | if (!g.flags) | 246 | if (!g.flags) |
244 | bb_simple_error_msg_and_die("must use '-v', =, - or +"); | 247 | bb_simple_error_msg_and_die("must use -v, -p, =, - or +"); |
245 | 248 | ||
246 | /* now run chattr on all the files passed to us */ | 249 | /* now run chattr on all the files passed to us */ |
247 | do change_attributes(*argv, &g); while (*++argv); | 250 | do change_attributes(*argv, &g); while (*++argv); |