diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-10 20:17:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-10 20:17:12 +0200 |
commit | 005c492c40ff833a99abd251872ec60661344474 (patch) | |
tree | bd25b3e08ee73dc3b17f2eac3cbcb94fa9a7fca0 | |
parent | 02859aaeb29fb83167364291f1ce26b54c23803b (diff) |
ash: shrink umask code
function old new delta
umaskcmd 258 248 -10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c index b09681296..8a1628e81 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12826,27 +12826,25 @@ umaskcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) if (*argptr == NULL) { if (symbolic_mode) { - char buf[sizeof("u=rwx,g=rwx,o=rwx")]; + char buf[sizeof(",u=rwx,g=rwx,o=rwx")]; char *p = buf; int i; i = 2; for (;;) { - unsigned bits; - + *p++ = ','; *p++ = permuser[i]; *p++ = '='; /* mask is 0..0uuugggooo. i=2 selects uuu bits */ - bits = (mask >> (i*3)); - if (!(bits & 4)) *p++ = 'r'; - if (!(bits & 2)) *p++ = 'w'; - if (!(bits & 1)) *p++ = 'x'; + if (!(mask & 0400)) *p++ = 'r'; + if (!(mask & 0200)) *p++ = 'w'; + if (!(mask & 0100)) *p++ = 'x'; + mask <<= 3; if (--i < 0) break; - *p++ = ','; } *p = '\0'; - puts(buf); + puts(buf + 1); } else { out1fmt("%04o\n", mask); } |