d_splice_alias(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

d_splice_alias β€” splice a disconnected dentry into the tree if one exists. πŸ¦‹

okay so bestie, this is d_splice_alias(9) from the Kernel API Manual, and it’s literally the function that does exactly what the name says, no cap ✨

✨ SYNOPSIS ✨

struct dentry * d_splice_alias (struct inode *inode , struct dentry *dentry );

πŸŽ€ ARGUMENTS πŸŽ€

  • inode β€” the inode which may have a disconnected dentry. 🫢
  • dentry β€” a negative dentry which we want to point to the inode. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

okay, the logic is giving conditional queen, so stay with me:

  • if inode is a directory and has an IS_ROOT alias, then d_move that in place of the given dentry and return it; else simply d_add the inode to the dentry and return NULL. ✨
  • if a non-IS_ROOT directory is found, the filesystem is corrupt, and we should error out: directories can't have multiple aliases. 🚨 this is a hard no.
  • this is needed in the lookup routine of any filesystem that is exportable (via knfsd) so that we can build dcache paths to directories effectively. πŸ‘‘
  • if a dentry was found and moved, then it is returned. otherwise NULL is returned. this matches the expected return value of ->lookup. πŸ’―
  • cluster filesystems may call this function with a negative, hashed dentry. in that case, we know that the inode will be a regular file, and also this will only occur during atomic_open. so we need to check for the dentry being already hashed only in the final case. 🌈

🌸 SEE ALSO 🌸

Kernel file ./fs/dcache.c β€” the whole squad is: 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_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), is_subdir(9). 🫢


source/version ./fs, date October 2026 β€” that’s the tea, bestie, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from