ash: shrink umask code
function old new delta umaskcmd 258 248 -10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
02859aaeb2
commit
005c492c40
16
shell/ash.c
16
shell/ash.c
@ -12826,27 +12826,25 @@ umaskcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
|
|
||||||
if (*argptr == NULL) {
|
if (*argptr == NULL) {
|
||||||
if (symbolic_mode) {
|
if (symbolic_mode) {
|
||||||
char buf[sizeof("u=rwx,g=rwx,o=rwx")];
|
char buf[sizeof(",u=rwx,g=rwx,o=rwx")];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 2;
|
i = 2;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
unsigned bits;
|
*p++ = ',';
|
||||||
|
|
||||||
*p++ = permuser[i];
|
*p++ = permuser[i];
|
||||||
*p++ = '=';
|
*p++ = '=';
|
||||||
/* mask is 0..0uuugggooo. i=2 selects uuu bits */
|
/* mask is 0..0uuugggooo. i=2 selects uuu bits */
|
||||||
bits = (mask >> (i*3));
|
if (!(mask & 0400)) *p++ = 'r';
|
||||||
if (!(bits & 4)) *p++ = 'r';
|
if (!(mask & 0200)) *p++ = 'w';
|
||||||
if (!(bits & 2)) *p++ = 'w';
|
if (!(mask & 0100)) *p++ = 'x';
|
||||||
if (!(bits & 1)) *p++ = 'x';
|
mask <<= 3;
|
||||||
if (--i < 0)
|
if (--i < 0)
|
||||||
break;
|
break;
|
||||||
*p++ = ',';
|
|
||||||
}
|
}
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
puts(buf);
|
puts(buf + 1);
|
||||||
} else {
|
} else {
|
||||||
out1fmt("%04o\n", mask);
|
out1fmt("%04o\n", mask);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user