fs/posix_acl.c
Source file repositories/reference/linux-study-clean/fs/posix_acl.c
File Facts
- System
- Linux kernel
- Corpus path
fs/posix_acl.c- Extension
.c- Size
- 31912 bytes
- Lines
- 1299
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/slab.hlinux/atomic.hlinux/fs.hlinux/sched.hlinux/cred.hlinux/posix_acl.hlinux/posix_acl_xattr.hlinux/xattr.hlinux/export.hlinux/user_namespace.hlinux/namei.hlinux/mnt_idmapping.hlinux/iversion.hlinux/security.hlinux/fsnotify.hlinux/filelock.hinternal.h
Detected Declarations
function Copyrightfunction set_cached_aclfunction __forget_cached_aclfunction forget_cached_aclfunction forget_all_cached_aclsfunction forget_cached_aclfunction posix_acl_initfunction posix_acl_allocfunction posix_acl_clonefunction posix_acl_validfunction FOREACH_ACL_ENTRYfunction posix_acl_equiv_modefunction FOREACH_ACL_ENTRYfunction posix_acl_from_modefunction posix_acl_permissionfunction FOREACH_ACL_ENTRYfunction openfunction FOREACH_ACL_ENTRYfunction __posix_acl_chmod_masqfunction FOREACH_ACL_ENTRYfunction __posix_acl_createfunction __posix_acl_chmodfunction posix_acl_chmodfunction posix_acl_createfunction CAP_FSETIDfunction posix_acl_fix_xattr_commonfunction posix_acl_from_xattrfunction posix_acl_to_xattrfunction vfs_posix_acl_to_xattrfunction set_posix_aclfunction posix_acl_listxattrfunction posix_acl_xattr_listfunction simple_set_aclfunction simple_acl_createfunction vfs_set_acl_idmapped_mntfunction vfs_set_aclfunction posix_acl_releasefunction vfs_remove_aclfunction do_set_aclfunction do_get_aclexport get_cached_aclexport get_cached_acl_rcuexport set_cached_aclexport forget_cached_aclexport forget_all_cached_aclsexport get_inode_aclexport posix_acl_initexport posix_acl_alloc
Annotated Snippet
switch (pa->e_tag) {
case ACL_USER_OBJ:
if (state == ACL_USER_OBJ) {
state = ACL_USER;
break;
}
return -EINVAL;
case ACL_USER:
if (state != ACL_USER)
return -EINVAL;
if (!kuid_has_mapping(user_ns, pa->e_uid))
return -EINVAL;
needs_mask = 1;
break;
case ACL_GROUP_OBJ:
if (state == ACL_USER) {
state = ACL_GROUP;
break;
}
return -EINVAL;
case ACL_GROUP:
if (state != ACL_GROUP)
return -EINVAL;
if (!kgid_has_mapping(user_ns, pa->e_gid))
return -EINVAL;
needs_mask = 1;
break;
case ACL_MASK:
if (state != ACL_GROUP)
return -EINVAL;
state = ACL_OTHER;
break;
case ACL_OTHER:
if (state == ACL_OTHER ||
(state == ACL_GROUP && !needs_mask)) {
state = 0;
break;
}
return -EINVAL;
default:
return -EINVAL;
}
}
if (state == 0)
return 0;
return -EINVAL;
}
EXPORT_SYMBOL(posix_acl_valid);
/*
* Returns 0 if the acl can be exactly represented in the traditional
* file mode permission bits, or else 1. Returns -E... on error.
*/
int
posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
{
const struct posix_acl_entry *pa, *pe;
umode_t mode = 0;
int not_equiv = 0;
/*
* A null ACL can always be presented as mode bits.
*/
if (!acl)
return 0;
FOREACH_ACL_ENTRY(pa, acl, pe) {
switch (pa->e_tag) {
case ACL_USER_OBJ:
mode |= (pa->e_perm & S_IRWXO) << 6;
break;
case ACL_GROUP_OBJ:
mode |= (pa->e_perm & S_IRWXO) << 3;
break;
case ACL_OTHER:
mode |= pa->e_perm & S_IRWXO;
break;
case ACL_MASK:
mode = (mode & ~S_IRWXG) |
((pa->e_perm & S_IRWXO) << 3);
not_equiv = 1;
break;
case ACL_USER:
case ACL_GROUP:
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/atomic.h`, `linux/fs.h`, `linux/sched.h`, `linux/cred.h`, `linux/posix_acl.h`, `linux/posix_acl_xattr.h`.
- Detected declarations: `function Copyright`, `function set_cached_acl`, `function __forget_cached_acl`, `function forget_cached_acl`, `function forget_all_cached_acls`, `function forget_cached_acl`, `function posix_acl_init`, `function posix_acl_alloc`, `function posix_acl_clone`, `function posix_acl_valid`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.