ns_tree_node_add(9)
π ns_tree_node_add(9) π
okay so bestie, welcome to the Kernel API Manual β¨ β this is the page for ns_tree_node_add, and honestly? it's giving "one function, two data structures, zero chill" π
let's get into it.
π NAME π
ns_tree_node_add β Add a node to a namespace tree πΈ
β¨ SYNOPSIS β¨
struct rb_node * ns_tree_node_add (struct ns_tree_node *node , struct
ns_tree_root *root , int (*cmp)(struct rb_node *, const struct rb_node
*) );
like. look at that signature. she's iconic, she's long, she returns a struct rb_node * and we love her for it π«Ά
π ARGUMENTS π
nodeβ the node you're adding, bestie. the actual star of the show πrootβ the tree root you're adding it to. gotta know where home is π‘cmpβ the comparison function for rbtree insertion. ngl she's doing a lot of the heavy lifting here, respect her π
π¦ DESCRIPTION π¦
okay so here's the vibe: this function adds the node to both the rbtree and the list, and it maintains sorted order the whole time β¨ no cap, both structures stay in sync.
and the reason the list is maintained in the same order as the rbtree? so you can do efficient iteration π« literally that's the whole point β iterate the list, get rbtree order, chef's kiss π§
π RETURN π
NULLβ if the insertion succeeded π (yes bestie, NULL means success here, do not panic, this is not an error, i promise π)- existing node β if a duplicate was found π
β οΈ lowkey important: read that return value carefully. NULL = slay, worked fine. a node pointer = duplicate already exists. the vibes are inverted from what you'd expect, so don't get caught out π
π SEE ALSO π
Kernel file ./kernel/nstree.c, plus the whole friend group:
ns_tree_node_init(9)ns_tree_root_init(9)ns_tree_node_empty(9)ns_tree_node_del(9)__ns_tree_adjoined_rcu(9)__ns_tree_gen_id(9)
go give them a read, they're all icons in their own right π
and that's the page, bestie!! π this one came to you straight from ./kernel and it's dated October 2026 β so if you're reading this in some other timeline, wyd π anyway ily, go add some nodes, and remember: NULL means you ate π₯π
π¦ 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