d_obtain_alias(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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

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