kernfs_name(9)
πΈ kernfs_name(9) β the kernel API manual, bestie edition πΈ
Okay so this is kernfs_name(9) from the Kernel API Manual (section 9, kernel-level, no cap) and it's honestly such a useful little guy. Let's get into it π
β¨ NAME β¨
kernfs_name β obtain the name of a given node. That's it, that's the whole gig π
π¦ SYNOPSIS π¦
int kernfs_name (struct kernfs_node *kn , char *buf , size_t buflen );
π ARGUMENTS π
knβ thekernfs_nodeof interest π like, the node you're curious aboutbufβ the buffer you want to copykn's name into π«Άbuflenβ the size ofbuf, in bytes, so we know how much room we've got
β DESCRIPTION β
So what it does is: copies the name of kn into buf of buflen bytes. The behavior is similar to strscpy β iykyk π
If kn is NULL, it fills the buffer with "(null)" instead. Nice of it honestly, no crash, just a polite little placeholder π
And the best part? This function can be called from any context. Literally any. Main character energy, it doesn't care where you call it from π₯
π RETURN π
It returns the resulting length of buf.
But listen β if buf isn't long enough, it gets filled up to buflen-1 and nul terminated, and the function returns -E2BIG. So watch your sizes bestie, or you'll get that negative back π
π SEE ALSO π
Kernel file ./fs/kernfs/dir.c β and these siblings of the kernfs family, all iconic:
kernfs_path_from_node_locked(9)kernfs_path_from_node(9)pr_cont_kernfs_name(9)pr_cont_kernfs_path(9)kernfs_get_parent(9)kernfs_name_hash(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)
That's the whole page babes, go forth and get those node names π
Source path: ./fs/kernfs β dated October 2026, and yes that's the whole credit line, 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