d_alloc(9)
β¨ d_alloc(9) β¨
okay so bestie, welcome to the Kernel API Manual π
this one's a little function in ./fs/dcache.c that hands you a shiny new dcache entry. it's giving "small but iconic." π
πΈ NAME πΈ
d_alloc β allocate a dcache entry π¦
β SYNOPSIS β
struct dentry * d_alloc (struct dentry * parent , const struct qstr
*name );
like, that's the whole signature. struct dentry pointer out, parent + name in. no cap. π
π ARGUMENTS π
parentβ the parent of the entry you're allocating, i.e. who's adopting this lil dentry πnameβ theqstrof the name, the actual label it's gonna wear β¨
π DESCRIPTION π
So it allocates a dentry. That's the whole vibe. π«Ά
If there isn't enough memory available, it returns NULL β like, no dentry for you, bestie, the RAM said no π. On success the dentry is returned to you.
And here's the tea: the name you pass in gets copied. so the copy you passed in? you can reuse it after this call. it's not holding onto your string, it made its own. periodt. π
π SEE ALSO π
kernel file ./fs/dcache.c β and literally the whole dcache friend group, they all hang out together:
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_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)d_splice_alias(9)is_subdir(9)
π lowkey important reminder from the page itself: if memory's tight you get NULL back, so pls check your return value, bestie. don't be out here dereferencing nothing π
that's the whole page, angel π§ this one lives in ./fs and the manual's dated October 2026 β so like, future vibes only. mwah, go allocate something cute πβ¨πΈ
π¦ 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