fs/nfsd/nfs4acl.c
Source file repositories/reference/linux-study-clean/fs/nfsd/nfs4acl.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfsd/nfs4acl.c- Extension
.c- Size
- 22924 bytes
- Lines
- 885
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/fs.hlinux/slab.hlinux/posix_acl.hnfsfh.hnfsd.hacl.hvfs.h
Detected Declarations
struct posix_acl_summarystruct posix_ace_statestruct posix_user_ace_statestruct posix_ace_state_arraystruct posix_acl_statefunction mask_from_posixfunction deny_mask_from_posixfunction low_mode_from_nfs4function nfsd4_get_nfs4_aclfunction summarize_posix_aclfunction FOREACH_ACL_ENTRYfunction _posix_to_nfsv4_onefunction pace_gtfunction posix_acl_validfunction sort_paclfunction init_statefunction free_statefunction add_to_maskfunction posix_state_to_aclfunction allow_bitsfunction deny_bitsfunction find_uidfunction find_gidfunction deny_bits_arrayfunction allow_bits_arrayfunction process_one_v4_acefunction nfs4_acl_nfsv4_to_posixfunction nfsd4_acl_to_attrfunction ace2typefunction nfs4_acl_bytesfunction nfs4_acl_get_whotypefunction nfs4_acl_write_who
Annotated Snippet
struct posix_acl_summary {
unsigned short owner;
unsigned short users;
unsigned short group;
unsigned short groups;
unsigned short other;
unsigned short mask;
};
static void
summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
{
struct posix_acl_entry *pa, *pe;
/*
* Only pas.users and pas.groups need initialization; previous
* posix_acl_valid() calls ensure that the other fields will be
* initialized in the following loop. But, just to placate gcc:
*/
memset(pas, 0, sizeof(*pas));
pas->mask = 07;
FOREACH_ACL_ENTRY(pa, acl, pe) {
switch (pa->e_tag) {
case ACL_USER_OBJ:
pas->owner = pa->e_perm;
break;
case ACL_GROUP_OBJ:
pas->group = pa->e_perm;
break;
case ACL_USER:
pas->users |= pa->e_perm;
break;
case ACL_GROUP:
pas->groups |= pa->e_perm;
break;
case ACL_OTHER:
pas->other = pa->e_perm;
break;
case ACL_MASK:
pas->mask = pa->e_perm;
break;
}
}
/* We'll only care about effective permissions: */
pas->users &= pas->mask;
pas->group &= pas->mask;
pas->groups &= pas->mask;
}
/* We assume the acl has been verified with posix_acl_valid. */
static void
_posix_to_nfsv4_one(struct posix_acl *pacl, struct nfs4_acl *acl,
unsigned int flags)
{
struct posix_acl_entry *pa, *group_owner_entry;
struct nfs4_ace *ace;
struct posix_acl_summary pas;
unsigned short deny;
int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
BUG_ON(pacl->a_count < 3);
summarize_posix_acl(pacl, &pas);
pa = pacl->a_entries;
ace = acl->aces + acl->naces;
/* We could deny everything not granted by the owner: */
deny = ~pas.owner;
/*
* but it is equivalent (and simpler) to deny only what is not
* granted by later entries:
*/
deny &= pas.users | pas.group | pas.groups | pas.other;
if (deny) {
ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
ace->flag = eflag;
ace->access_mask = deny_mask_from_posix(deny, flags);
ace->whotype = NFS4_ACL_WHO_OWNER;
ace++;
acl->naces++;
}
ace->type = NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE;
ace->flag = eflag;
ace->access_mask = mask_from_posix(pa->e_perm, flags | NFS4_ACL_OWNER);
ace->whotype = NFS4_ACL_WHO_OWNER;
ace++;
acl->naces++;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/slab.h`, `linux/posix_acl.h`, `nfsfh.h`, `nfsd.h`, `acl.h`, `vfs.h`.
- Detected declarations: `struct posix_acl_summary`, `struct posix_ace_state`, `struct posix_user_ace_state`, `struct posix_ace_state_array`, `struct posix_acl_state`, `function mask_from_posix`, `function deny_mask_from_posix`, `function low_mode_from_nfs4`, `function nfsd4_get_nfs4_acl`, `function summarize_posix_acl`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.