kernfs_name_hash(9)
π kernfs_name_hash(9) β the group chat version
okay so bestie, welcome to kernfs_name_hash, from the Kernel API Manual (section 9, kernel-land, very demure, very mindful). this little icon takes your namespace tag and your name and smashes them together into one lil number. it's giving β¨hashingβ¨ and honestly? it ate. let me walk you through it π«Ά
β¨ NAME β¨
kernfs_name_hash β calculate hash of @ns + @name
no cap, that's literally the whole job description. it hashes the ns and the name together. that's it, that's the function π
π SYNOPSIS π
unsigned int kernfs_name_hash (const char *name , const struct ns_common
*ns );
so it hands you back an unsigned int, and you feed it a const char * for the name plus a const struct ns_common * for the namespace. two ingredients, one hash. chef's kiss π
πΈ ARGUMENTS πΈ
nameβ null terminated string to hash. yes bestie, null terminated, we are not doing the "whoops no terminator" thing today πnsβ the namespace tag to hash. it gets mixed in with the name so different namespaces don't collide on the same name. iconic behaviour, honestly π
β RETURN β
a 31-bit hash of ns + name β and the reason it's 31-bit is so it fits in an off_t. the way that's such a specific flex π 31 bits, not 32, because off_t said "leave room for my sign bit babes". periodt.
π¦ SEE ALSO π¦
kernel file ./fs/kernfs/dir.c β that's where the source lives, go say hi to it π
and then the whole extended friend group, fr fr:
kernfs_path_from_node_locked(9)kernfs_name(9)kernfs_path_from_node(9)pr_cont_kernfs_name(9)pr_cont_kernfs_path(9)kernfs_get_parent(9)kernfs_link_sibling(9)kernfs_unlink_sibling(9)kernfs_get_active(9)kernfs_put_active(9)kernfs_drain(9)kernfs_get(9)kernfs_put(9)kernfs_node_from_dentry(9)kernfs_add_one(9)kernfs_find_ns(9)kernfs_find_and_get_ns(9)kernfs_walk_and_get_ns(9)kernfs_create_root(9)kernfs_destroy_root(9)kernfs_root_to_node(9)kernfs_create_dir_ns(9)kernfs_create_empty_dir(9)kernfs_next_descendant_post(9)kernfs_activate(9)kernfs_show(9)kernfs_remove(9)kernfs_break_active_protection(9)kernfs_unbreak_active_protection(9)kernfs_remove_self(9)kernfs_remove_by_name_ns(9)kernfs_rename_ns(9)
like, the whole squad showed up to the function. main character energy all around π
ngl bestie, the only real vibe check here: it's a hash, it's 31 bits so it plays nice withoff_t, and it mixesnswithname. don't overthink it, just enjoy the immaculate code π
and that's the page! this one came out of ./fs/kernfs and it's dated October 2026 β so mark your calendar, screenshot it, send it to the group chat, and remember: kernfs_name_hash(9), kernel API manual, section 9. slay πβ¨π
π¦ 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