d_obtain_root(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 🧚:


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