key_link(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

okay so bestie, welcome to key_link(9) from the Kernel API Manual πŸŽ€ β€” this is the page where the kernel learns how to introduce two of its little guys to each other. it's giving matchmaker energy fr fr πŸ’…


✨ NAME ✨

key_link β€” Link a key to a keyring πŸ¦‹

like... literally that. that's the whole assignment. link a key to a keyring. no cap πŸ‘‘


🌸 SYNOPSIS 🌸

int key_link (struct key *keyring , struct key *key );

two pointer arguments, one int coming back at you β€” classic signature behavior, we love to see it πŸ’œ


πŸŽ€ ARGUMENTS πŸŽ€

  • keyring β€” the keyring you're making the link in. the destination. the vibe. the group chat the key is getting added to 🫢
  • key β€” the key you're linking to. the new member. the main character being introduced 🌟

πŸ’€ DESCRIPTION πŸ’€

so what actually happens πŸ‘€ β€” this function makes a link in a keyring to a key, such that the keyring holds a reference on that key and the key can potentially be found by searching that keyring. lowkey important detail: "potentially" β€” that's the manpage's word, not mine, so don't come for me πŸ™ˆ

heads up on the side effects, because there are some and they're real:

  • this function is gonna write-lock the keyring's semaphore πŸ”’ β€” yes, it takes the lock, yes, that's normal, breathe
  • it also consumes some of the user's key data quota to hold the link πŸ“ so like... it's not free, bestie, there's a budget and you're spending from it

⭐ return values, aka the vibe check ⭐

  • 0 β€” slay, it worked, successful πŸ’–
  • -ENOTDIR β€” the keyring isn't a keyring 😭 like, wrong type entirely
  • -EKEYREVOKED β€” the keyring has been revoked πŸ’€ it's over, it's done
  • -ENFILE β€” the keyring is full 🫠 there's no room at the inn
  • -EDQUOT β€” insufficient key data quota remaining to add another link πŸ“ the budget said no
  • -ENOMEM β€” insufficient memory 🧠πŸ’₯ out of RAM, out of luck

⚠️ okay important caveat time, pay attention bestie: it is assumed that the caller has checked that it is permitted for a link to be made β€” the keyring should have Write permission and the key Link permission. that's on you, not on this function. it's not gonna do the permission check for you, it's not your mom πŸ™ˆ do your homework before you call it, fr fr ✨

🌈 SEE ALSO 🌈

the whole friend group, in the order the page listed them 🫢

Kernel file ./security/keys/keyring.c, then:

go read all of them, i'll wait πŸ’…πŸ“š


🧚 cute little sign-off 🧚

this gem lives under ./security/keys, dated October 2026, and it's page key_link(9) of the Kernel API Manual β€” mwah, bye bestie, go link some keys responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from