chattr: fix "chattr =ae -R FILE"
-R is not an "unset these flags" argument, thus no conflict with "=". function old new delta .rodata 103684 103686 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
85a5bc9148
commit
5709b51a75
@ -85,7 +85,9 @@ static char** decode_arg(char **argv, struct globals *gp)
|
|||||||
|
|
||||||
fl = &gp->af;
|
fl = &gp->af;
|
||||||
if (opt == '-') {
|
if (opt == '-') {
|
||||||
gp->flags |= OPT_REM;
|
/* gp->flags |= OPT_REM; - WRONG, it can be an option */
|
||||||
|
/* testcase: chattr =ae -R FILE should not complain "= is incompatible with - and +" */
|
||||||
|
/* (and should not read flags, with =FLAGS they can be just set directly) */
|
||||||
fl = &gp->rf;
|
fl = &gp->rf;
|
||||||
} else if (opt == '+') {
|
} else if (opt == '+') {
|
||||||
gp->flags |= OPT_ADD;
|
gp->flags |= OPT_ADD;
|
||||||
@ -115,7 +117,7 @@ static char** decode_arg(char **argv, struct globals *gp)
|
|||||||
if (*arg == 'v') {
|
if (*arg == 'v') {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
gp->version = xatoul(*argv);
|
gp->version = xatou(*argv);
|
||||||
gp->flags |= OPT_SET_VER;
|
gp->flags |= OPT_SET_VER;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -127,8 +129,9 @@ static char** decode_arg(char **argv, struct globals *gp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* not a known option, try as an attribute */
|
/* not a known option, try as an attribute */
|
||||||
|
gp->flags |= OPT_REM;
|
||||||
}
|
}
|
||||||
*fl |= get_flag(*arg);
|
*fl |= get_flag(*arg); /* aborts on bad flag letter */
|
||||||
}
|
}
|
||||||
|
|
||||||
return argv;
|
return argv;
|
||||||
@ -241,7 +244,7 @@ int chattr_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (g.rf & g.af)
|
if (g.rf & g.af)
|
||||||
bb_simple_error_msg_and_die("can't set and unset a flag");
|
bb_simple_error_msg_and_die("can't set and unset a flag");
|
||||||
if (!g.flags)
|
if (!g.flags)
|
||||||
bb_simple_error_msg_and_die("must use '-v', =, - or +");
|
bb_simple_error_msg_and_die("must use -v, -p, =, - or +");
|
||||||
|
|
||||||
/* now run chattr on all the files passed to us */
|
/* now run chattr on all the files passed to us */
|
||||||
do change_attributes(*argv, &g); while (*++argv);
|
do change_attributes(*argv, &g); while (*++argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user