MCPcopy Create free account
hub / github.com/F-Stack/f-stack / flags_to_rights

Function flags_to_rights

freebsd/kern/vfs_syscalls.c:1023–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1021}
1022
1023static __inline void
1024flags_to_rights(int flags, cap_rights_t *rightsp)
1025{
1026
1027 if (flags & O_EXEC) {
1028 cap_rights_set_one(rightsp, CAP_FEXECVE);
1029 } else {
1030 switch ((flags & O_ACCMODE)) {
1031 case O_RDONLY:
1032 cap_rights_set_one(rightsp, CAP_READ);
1033 break;
1034 case O_RDWR:
1035 cap_rights_set_one(rightsp, CAP_READ);
1036 /* FALLTHROUGH */
1037 case O_WRONLY:
1038 cap_rights_set_one(rightsp, CAP_WRITE);
1039 if (!(flags & (O_APPEND | O_TRUNC)))
1040 cap_rights_set_one(rightsp, CAP_SEEK);
1041 break;
1042 }
1043 }
1044
1045 if (flags & O_CREAT)
1046 cap_rights_set_one(rightsp, CAP_CREATE);
1047
1048 if (flags & O_TRUNC)
1049 cap_rights_set_one(rightsp, CAP_FTRUNCATE);
1050
1051 if (flags & (O_SYNC | O_FSYNC))
1052 cap_rights_set_one(rightsp, CAP_FSYNC);
1053
1054 if (flags & (O_EXLOCK | O_SHLOCK))
1055 cap_rights_set_one(rightsp, CAP_FLOCK);
1056}
1057
1058/*
1059 * Check permissions, allocate an open file structure, and call the device

Callers 1

kern_openatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected