__next_ns(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __next_ns(9) β€” the kernel API manual, but make it make sense

okay bestie, welcome to the <pink>__next_ns</pink> page from the Kernel API Manual ✨ this one lives in the AppArmor corner of the kernel and it's literally just "find the next namespace to list" πŸŽ€ that's the whole NAME section, we ate πŸ’…


✨ SYNOPSIS ✨

struct aa_ns * __next_ns (struct aa_ns *root , struct aa_ns *ns );

that's it, that's the whole vibe check πŸ¦‹ two pointers in, one pointer out, no cap.


🌸 ARGUMENTS 🌸

  • root β€” the root namespace where the search stops πŸ›‘ it is NOT NULL, so do not come in here with a null, bestie, that's not the move πŸ™ˆ
  • ns β€” your current ns position, like where you're standing right now πŸ“ also NOT NULL. same energy. no nulls allowed, periodt.

πŸ’– DESCRIPTION πŸ’–

so the way this works is: it finds the next namespace after ns, but only the ones hanging out under root β€” and it handles all the locking needed while it switches the current namespace πŸ” like it does the whole lock choreography for you so you don't have to, which is honestly iconic of it πŸ‘‘


🌈 RETURN 🌈

you get the next namespace back πŸŽ‰ or NULL if you're already at the last namespace under root β€” that's the "no more, we're done here" signal πŸ’€

and the requirement, fr fr: ns->parent->lock has to be held. that's not optional, that's the whole deal 🫢


⭐ NOTE ⭐

heads up, bestie: it will not unlock root->lock 🚨 so don't go thinking it'll clean that up for you β€” that lock is yours to deal with, iykyk 😭


πŸ¦‹ SEE ALSO πŸ¦‹

kernel file ./security/apparmor/apparmorfs.c πŸ’œ and the whole friend group:


that's the page, babe πŸŽ€ this came out of ./security/apparmor, dated October 2026, and it's filed under __next_ns(9) β€” go forth and iterate your namespaces responsibly πŸ’…βœ¨πŸ”₯

πŸ“¦ where this page comes from