from_kgid(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– from_kgid β€” the Kernel API Manual, bestie edition πŸŽ€

okay so picture this: you're deep in the kernel, you've got a kgid (that's the kernel's own internal gid, the ✨real✨ one) and you need to hand it to userspace in somebody's user namespace. That's literally this function. It's the glow-up translator between kernelspace and your targ namespace, and honestly? iconic.


🌸 SYNOPSIS 🌸

gid_t from_kgid (struct user_namespace *targ , kgid_t kgid );

no cap, that's the whole signature. two args, one gid_t coming back at you 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • targ β€” the struct user_namespace * you want a gid in. like, where do you want this gid to live? that one. ✨
  • kgid β€” the kernel internal gid you're starting with (kgid_t). the raw material, the before picture πŸ’…

πŸ’œ DESCRIPTION πŸ’œ

So what happens is: it maps kgid into the user namespace that targ points at, and then returns the resulting gid to you. That's it. That's the function. πŸŽ€

There is always a mapping into the initial user_namespace β€” so like, the original namespace never ghosts you, that mapping is guaranteed to be there, fr fr.

⚠️ but bestie, listen: if kgid has no mapping in targ, you don't get a nice value back β€” you get (gid_t)-1. that's your "nope, not found" signal, so check for it. lowkey important. 🫢

🌈 SEE ALSO 🌈

the kernel file in question is ./kernel/user_namespace.c, and if you're gonna be messing with ids and namespaces, you'll want the whole bestie squad:


alright that's the page πŸ’… this lil slice of kernel API lives in ./kernel, it's the October 2026 vibes, and the whole thing is filed under from_kgid(9) β€” go map those gids, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from