MCPcopy Create free account
hub / github.com/RsyncProject/rsync / tweak_mode

Function tweak_mode

chmod.c:218–236  ·  view source on GitHub ↗

Takes an existing file permission and a list of AND/OR changes, and * create a new permissions. */

Source from the content-addressed store, hash-verified

216/* Takes an existing file permission and a list of AND/OR changes, and
217 * create a new permissions. */
218int tweak_mode(int mode, struct chmod_mode_struct *chmod_modes)
219{
220 int IsX = mode & 0111;
221 int NonPerm = mode & ~CHMOD_BITS;
222
223 for ( ; chmod_modes; chmod_modes = chmod_modes->next) {
224 if ((chmod_modes->flags & FLAG_DIRS_ONLY) && !S_ISDIR(NonPerm))
225 continue;
226 if ((chmod_modes->flags & FLAG_FILES_ONLY) && S_ISDIR(NonPerm))
227 continue;
228 mode &= chmod_modes->ModeAND;
229 if ((chmod_modes->flags & FLAG_X_KEEP) && !IsX && !S_ISDIR(NonPerm))
230 mode |= chmod_modes->ModeOR & ~0111;
231 else
232 mode |= chmod_modes->ModeOR;
233 }
234
235 return mode | NonPerm;
236}
237
238/* Free the linked list created by parse_chmod. */
239int free_chmod_mode(struct chmod_mode_struct *chmod_modes)

Callers 3

set_file_attrsFunction · 0.85
recv_file_entryFunction · 0.85
send_file_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected