Lines Matching +full:const +full:- +full:op +full:- +full:mode
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
51 #include "un-namespace.h"
77 * Given the old mode and an array of bitcmd structures, apply the operations
78 * described in the bitcmd structures to the old mode, and return the new mode.
79 * Note that there is no '=' command; a strict assignment is just a '-' (clear
83 getmode(const void *bbox, mode_t omode) in getmode()
85 const BITCMD *set; in getmode()
88 set = (const BITCMD *)bbox; in getmode()
91 switch(set->cmd) { in getmode()
94 * where the bits are in the mode so that we can do shifts to in getmode()
108 common: if (set->cmd2 & CMD2_CLR) { in getmode()
110 (set->cmd2 & CMD2_SET) ? S_IRWXO : value; in getmode()
111 if (set->cmd2 & CMD2_UBITS) in getmode()
112 newmode &= ~((clrval<<6) & set->bits); in getmode()
113 if (set->cmd2 & CMD2_GBITS) in getmode()
114 newmode &= ~((clrval<<3) & set->bits); in getmode()
115 if (set->cmd2 & CMD2_OBITS) in getmode()
116 newmode &= ~(clrval & set->bits); in getmode()
118 if (set->cmd2 & CMD2_SET) { in getmode()
119 if (set->cmd2 & CMD2_UBITS) in getmode()
120 newmode |= (value<<6) & set->bits; in getmode()
121 if (set->cmd2 & CMD2_GBITS) in getmode()
122 newmode |= (value<<3) & set->bits; in getmode()
123 if (set->cmd2 & CMD2_OBITS) in getmode()
124 newmode |= value & set->bits; in getmode()
129 newmode |= set->bits; in getmode()
132 case '-': in getmode()
133 newmode &= ~set->bits; in getmode()
138 newmode |= set->bits; in getmode()
144 (void)printf("getmode:%04o -> %04o\n", omode, newmode); in getmode()
157 set = newset + (set - saveset); \
159 endset = newset + (setlen - 2); \
166 setmode(const char *p) in setmode()
169 char op, *ep; in setmode() local
192 endset = set + (setlen - 2); in setmode()
195 * If an absolute number, get it and return; disallow non-octal digits in setmode()
213 set->cmd = 0; in setmode()
219 * each clause of the symbolic mode. in setmode()
243 getop: if ((op = *p++) != '+' && op != '-' && op != '=') { in setmode()
247 if (op == '=') in setmode()
257 /* If only "other" bits ignore set-id. */ in setmode()
282 * to flush out any partial mode that we have, in setmode()
283 * and then do the copying of the mode bits. in setmode()
286 ADDCMD(op, who, perm, mask); in setmode()
289 if (op == '=') in setmode()
291 if (op == '+' && permXbits) { in setmode()
295 ADDCMD(*p, who, op, mask); in setmode()
303 if (perm || (op == '=' && !equalopdone)) { in setmode()
304 if (op == '=') in setmode()
306 ADDCMD(op, who, perm, mask); in setmode()
323 set->cmd = 0; in setmode()
372 addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask) in addcmd() argument
374 switch (op) { in addcmd()
376 set->cmd = '-'; in addcmd()
377 set->bits = who ? who : STANDARD_BITS; in addcmd()
380 op = '+'; in addcmd()
383 case '-': in addcmd()
385 set->cmd = op; in addcmd()
386 set->bits = (who ? who : mask) & oparg; in addcmd()
392 set->cmd = op; in addcmd()
394 set->cmd2 = ((who & S_IRUSR) ? CMD2_UBITS : 0) | in addcmd()
397 set->bits = (mode_t)~0; in addcmd()
399 set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS; in addcmd()
400 set->bits = mask; in addcmd()
404 set->cmd2 |= CMD2_SET; in addcmd()
405 else if (oparg == '-') in addcmd()
406 set->cmd2 |= CMD2_CLR; in addcmd()
408 set->cmd2 |= CMD2_SET|CMD2_CLR; in addcmd()
418 for (; set->cmd; ++set) in dumpmode()
420 set->cmd, set->bits, set->cmd2 ? " cmd2:" : "", in dumpmode()
421 set->cmd2 & CMD2_CLR ? " CLR" : "", in dumpmode()
422 set->cmd2 & CMD2_SET ? " SET" : "", in dumpmode()
423 set->cmd2 & CMD2_UBITS ? " UBITS" : "", in dumpmode()
424 set->cmd2 & CMD2_GBITS ? " GBITS" : "", in dumpmode()
425 set->cmd2 & CMD2_OBITS ? " OBITS" : ""); in dumpmode()
431 * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u',
439 int setbits, clrbits, Xbits, op; in compress_mode() local
443 while ((op = nset->cmd) != '+' && op != '-' && op != 'X') { in compress_mode()
445 if (!op) in compress_mode()
450 if ((op = nset->cmd) == '-') { in compress_mode()
451 clrbits |= nset->bits; in compress_mode()
452 setbits &= ~nset->bits; in compress_mode()
453 Xbits &= ~nset->bits; in compress_mode()
454 } else if (op == '+') { in compress_mode()
455 setbits |= nset->bits; in compress_mode()
456 clrbits &= ~nset->bits; in compress_mode()
457 Xbits &= ~nset->bits; in compress_mode()
458 } else if (op == 'X') in compress_mode()
459 Xbits |= nset->bits & ~setbits; in compress_mode()
464 set->cmd = '-'; in compress_mode()
465 set->cmd2 = 0; in compress_mode()
466 set->bits = clrbits; in compress_mode()
470 set->cmd = '+'; in compress_mode()
471 set->cmd2 = 0; in compress_mode()
472 set->bits = setbits; in compress_mode()
476 set->cmd = 'X'; in compress_mode()
477 set->cmd2 = 0; in compress_mode()
478 set->bits = Xbits; in compress_mode()