d_obtain_root(9)
β¨ NAME β¨ β d_obtain_root(9)
okay bestie, welcome to d_obtain_root(9) from the Kernel API Manual π
β the function that finds or allocates a dentry for a given inode, and honestly it's giving βroot of the filesystem main character energyβ πβ¨
π SYNOPSIS π
struct dentry * d_obtain_root (struct inode *inode );
π¦ ARGUMENTS π¦
inodeβ the inode you're allocating the dentry for, no cap π«Ά
π DESCRIPTION π
So the goal is: obtain an IS_ROOT dentry for the root of a filesystem. Slay π.
We must ensure that directory inodes only ever have one dentry β literally one, bestie. If a dentry is found, that one is returned instead of allocating a new one. Not me allocating a whole new dentry when one already exists π.
On successful return, the reference to the inode has been transferred to the dentry. In case of an error, the reference on the inode is released π«Ά.
A NULL or IS_ERR inode may be passed in, and the error will propagate to the return value β with a NULL inode replaced by ERR_PTR(-ESTALE). Yep, that's the plot twist πβ¨.
π₯ SEE ALSO π₯
Kernel file ./fs/dcache.c and this whole friend group π§:
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_alias(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)
Cute sign-off bestie π: this page comes from source/version ./fs, dated October 2026, and it's d_obtain_root(9) β byeee, drink water and check your dentries π
π«Ά
π¦ 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