aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-10 20:17:12 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-10 20:17:12 +0200
commit005c492c40ff833a99abd251872ec60661344474 (patch)
treebd25b3e08ee73dc3b17f2eac3cbcb94fa9a7fca0
parent02859aaeb29fb83167364291f1ce26b54c23803b (diff)
downloadbusybox-w32-005c492c40ff833a99abd251872ec60661344474.tar.gz
busybox-w32-005c492c40ff833a99abd251872ec60661344474.tar.bz2
busybox-w32-005c492c40ff833a99abd251872ec60661344474.zip
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.c16
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)
12826 12826
12827 if (*argptr == NULL) { 12827 if (*argptr == NULL) {
12828 if (symbolic_mode) { 12828 if (symbolic_mode) {
12829 char buf[sizeof("u=rwx,g=rwx,o=rwx")]; 12829 char buf[sizeof(",u=rwx,g=rwx,o=rwx")];
12830 char *p = buf; 12830 char *p = buf;
12831 int i; 12831 int i;
12832 12832
12833 i = 2; 12833 i = 2;
12834 for (;;) { 12834 for (;;) {
12835 unsigned bits; 12835 *p++ = ',';
12836
12837 *p++ = permuser[i]; 12836 *p++ = permuser[i];
12838 *p++ = '='; 12837 *p++ = '=';
12839 /* mask is 0..0uuugggooo. i=2 selects uuu bits */ 12838 /* mask is 0..0uuugggooo. i=2 selects uuu bits */
12840 bits = (mask >> (i*3)); 12839 if (!(mask & 0400)) *p++ = 'r';
12841 if (!(bits & 4)) *p++ = 'r'; 12840 if (!(mask & 0200)) *p++ = 'w';
12842 if (!(bits & 2)) *p++ = 'w'; 12841 if (!(mask & 0100)) *p++ = 'x';
12843 if (!(bits & 1)) *p++ = 'x'; 12842 mask <<= 3;
12844 if (--i < 0) 12843 if (--i < 0)
12845 break; 12844 break;
12846 *p++ = ',';
12847 } 12845 }
12848 *p = '\0'; 12846 *p = '\0';
12849 puts(buf); 12847 puts(buf + 1);
12850 } else { 12848 } else {
12851 out1fmt("%04o\n", mask); 12849 out1fmt("%04o\n", mask);
12852 } 12850 }