kernfs_path_from_node(9)
π
kernfs_path_from_node β the kernfs_path_from_node(9) glow-up π
okay so bestie, you know how every single thing in the kernel lives at some address in a tree and you're like "but what's its path tho"? yeah. this is the function for that. welcome to the group chat π (also hi, this is section 9 of the Kernel API Manual, we're doing kernel internals today, vibe check passed β¨)
β¨ NAME β¨
kernfs_path_from_node β literally builds the path of node @to relative to @from. that's it. that's the whole job. slay. π
πΈ SYNOPSIS πΈ
int kernfs_path_from_node (struct kernfs_node *to , struct kernfs_node *from , char *buf , size_t buflen );
yes the spacing is exactly like that, don't come for me, it's what the manpage says π«Ά
π ARGUMENTS π
toβ thekernfs_nodeyou actually care about, the main character of this operation πfromβ the parentkernfs_nodethat we're building the path relative to. yeah, the starting point. the home base πbufβ the buffer whereto's path gets copied. drop it in here bestie πbuflenβ the size ofbuf. please make it big enough, i'm begging π
π¦ DESCRIPTION π¦
so what it does is: it builds to's path relative to from, and it writes that into buf. that's the whole thing. no cap. β¨
the big rule:fromandtomust be on the same kernfs-root. like, non-negotiable. same tree or it's not gonna work out π
and here's the part that's lowkey iconic: if from is not a parent of to, then it doesn't just give up β it hands you back a relative path (which includes '..'s) as needed to reach from from to to. so it'll walk you out and back in. path finding with extra steps, and honestly? we respect it π§
β RETURN β
it returns the length of the constructed path. π
and if the path would have been greater than buflen, then buf contains the truncated path with the trailing
nope, that's not me getting cut off β that's literally how the original ends. sentence just. stops. "with the trailing" and then nothing. leaving us on a cliffhanger, main character energy, absolute icon behavior ππ i'm not making anything up to fill it in either, so enjoy the mystery π
π SEE ALSO π
the whole squad, fr fr. also worth peeping the Kernel file ./fs/kernfs/dir.c. π«Ά
kernfs_path_from_node_locked(9)kernfs_name(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)
and that's the page!! π this little beauty comes to you from the Kernel file ./fs/kernfs, dated October 2026 β mwah, tysm, ily, go build some paths bestie π
β¨ππ¦
π¦ 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