fs/nfsd/nfs4idmap.c
Source file repositories/reference/linux-study-clean/fs/nfsd/nfs4idmap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfsd/nfs4idmap.c- Extension
.c- Size
- 18390 bytes
- Lines
- 733
- 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/module.hlinux/seq_file.hlinux/sched.hlinux/slab.hlinux/sunrpc/svc_xprt.hnet/net_namespace.hidmap.hnfsd.hnetns.hvfs.h
Detected Declarations
struct entfunction ent_initfunction ent_putfunction ent_allocfunction idtoname_hashfunction idtoname_upcallfunction idtoname_requestfunction idtoname_matchfunction idtoname_showfunction warn_no_idmapdfunction idtoname_parsefunction idtoname_lookupfunction idtoname_updatefunction nametoid_hashfunction nametoid_upcallfunction nametoid_requestfunction nametoid_matchfunction nametoid_showfunction nametoid_parsefunction nametoid_lookupfunction nametoid_updatefunction nfsd_idmap_initfunction nfsd_idmap_shutdownfunction idmap_lookupfunction rqst_authnamefunction idmap_name_to_idfunction encode_ascii_idfunction idmap_id_to_namefunction numeric_name_to_idfunction do_name_to_idfunction encode_name_from_idfunction nfsd_map_name_to_uidfunction nfsd_map_name_to_gidfunction nfsd4_encode_userfunction nfsd4_encode_group
Annotated Snippet
struct ent {
struct cache_head h;
int type; /* User / Group */
u32 id;
char name[IDMAP_NAMESZ];
char authname[IDMAP_NAMESZ];
struct rcu_head rcu_head;
};
/* Common entry handling */
#define ENT_HASHBITS 8
#define ENT_HASHMAX (1 << ENT_HASHBITS)
static void
ent_init(struct cache_head *cnew, struct cache_head *citm)
{
struct ent *new = container_of(cnew, struct ent, h);
struct ent *itm = container_of(citm, struct ent, h);
new->id = itm->id;
new->type = itm->type;
strscpy(new->name, itm->name, sizeof(new->name));
strscpy(new->authname, itm->authname, sizeof(new->authname));
}
static void
ent_put(struct kref *ref)
{
struct ent *map = container_of(ref, struct ent, h.ref);
kfree_rcu(map, rcu_head);
}
static struct cache_head *
ent_alloc(void)
{
struct ent *e = kmalloc_obj(*e);
if (e)
return &e->h;
else
return NULL;
}
/*
* ID -> Name cache
*/
static uint32_t
idtoname_hash(struct ent *ent)
{
uint32_t hash;
hash = hash_str(ent->authname, ENT_HASHBITS);
hash = hash_long(hash ^ ent->id, ENT_HASHBITS);
/* Flip LSB for user/group */
if (ent->type == IDMAP_TYPE_GROUP)
hash ^= 1;
return hash;
}
static int
idtoname_upcall(struct cache_detail *cd, struct cache_head *h)
{
return sunrpc_cache_upcall_warn(cd, h);
}
static void
idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
int *blen)
{
struct ent *ent = container_of(ch, struct ent, h);
char idstr[11];
qword_add(bpp, blen, ent->authname);
snprintf(idstr, sizeof(idstr), "%u", ent->id);
qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
qword_add(bpp, blen, idstr);
(*bpp)[-1] = '\n';
}
static int
idtoname_match(struct cache_head *ca, struct cache_head *cb)
{
struct ent *a = container_of(ca, struct ent, h);
struct ent *b = container_of(cb, struct ent, h);
Annotation
- Immediate include surface: `linux/module.h`, `linux/seq_file.h`, `linux/sched.h`, `linux/slab.h`, `linux/sunrpc/svc_xprt.h`, `net/net_namespace.h`, `idmap.h`, `nfsd.h`.
- Detected declarations: `struct ent`, `function ent_init`, `function ent_put`, `function ent_alloc`, `function idtoname_hash`, `function idtoname_upcall`, `function idtoname_request`, `function idtoname_match`, `function idtoname_show`, `function warn_no_idmapd`.
- 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.