ns_tree_node_add(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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:

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