d_obtain_alias(9)
β¨ d_obtain_alias(9) β¨
okay so this is a page from the Kernel API Manual and bestie, it's genuinely kind of a banger. it's d_obtain_alias β yes, section 9, the grown-up kernel-functions section π
πΈ NAME πΈ
d_obtain_alias β find or allocate a DISCONNECTED dentry for a given inode
like, a dentry with no name attached. a dentry that's just vibing on its own. iconic honestly.
π SYNOPSIS π
struct dentry * d_obtain_alias (struct inode *inode );
that's the whole thing. one argument in, one struct dentry * out. periodt.
π¦ ARGUMENTS π¦
inodeβ the inode you want the dentry for. that's it, that's the parameter π
β DESCRIPTION β
so here's the situation: you want a dentry for an inode that came out of an NFS filehandle conversion, or some similar open by handle operation. that's the whole reason this function exists, and honestly? it ate.
the dentry you get back may be anonymous, or it may have a full name β that second one happens if the inode was already hanging out in the cache. surprise! it was already there. main character energy.
π¨ important caveat, no cap: when you call this on a directory inode, we must make sure that inode only ever has one dentry. so if a dentry is found, that one gets returned instead of allocating a shiny new one. one dentry per directory inode, we don't make the rules (we do, actually) π«Ά
on a successful return, the reference to the inode has been transferred to the dentry β it's the dentry's problem now, not yours π
in case of an error, the reference on the inode is released. so don't go freeing it again, that would be a whole situation π
and bc export operations are annoying, they made this easier for you: you can pass in a NULL or an IS_ERR inode, and the error just gets propagated to the return value. a NULL inode specifically gets replaced by ERR_PTR(-ESTALE). cute little convenience, we love to see it β¨
π SEE ALSO π
kernel file ./fs/dcache.c β go read it, it's right there:
d_drop(9)dentry_kill(9)__move_to_shrink_list(9)d_find_any_alias(9)d_find_alias(9)prune_dcache_sb(9)shrink_dcache_sb(9)enum d_walk_ret(9)d_walk(9)path_has_submounts(9)shrink_dcache_tree(9)d_invalidate(9)__d_alloc(9)d_alloc(9)d_alloc_pseudo(9)d_instantiate(9)d_obtain_root(9)d_add_ci(9)d_same_name(9)__d_lookup_rcu(9)d_lookup(9)__d_lookup(9)d_hash_and_lookup(9)d_delete(9)d_rehash(9)d_add(9)d_ancestor(9)d_splice_alias(9)is_subdir(9)
yeah that's a lot of dentry lore. iykyk π§
k bye bestie, this page dropped from ./fs back in October 2026 π go forth and obtain your aliases responsibly πΈβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms