key_unlink(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

Hey so this is key_unlink(9), a page from the Kernel API Manual β€” the kernel-key-management lore, iykyk. Grab a snack, we're detaching a key from a keyring and it's literally not that deep. πŸŽ€


✨ NAME ✨

key_unlink β€” unlink the first link to a key from a keyring. That's it, that's the whole vibe. πŸ’«

✨ SYNOPSIS ✨

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

✨ ARGUMENTS ✨

  • keyring β€” the keyring we're removing the link from. Like, the group chat you're leaving, not the message. 🫢
  • key β€” the key that the link points at. The message, in this extremely good analogy.

✨ DESCRIPTION ✨

Okay so the whole job: remove a link from a keyring to a key. One link. First one. Slay.

Heads up though β€” this function will write-lock the keyring's semaphore. So like, it's holding the door, nobody else is coming through while it does its thing. Respect the lock bestie. πŸ”’

Return values, because of course there are return values:

  • 0 if it's successful β€” icon behavior, no notes πŸ’…
  • -ENOTDIR if the keyring... isn't a keyring?? like you passed the wrong thing entirely 😭
  • -ENOENT if the key isn't linked to by the keyring β€” the link you're looking for doesn't exist, ghosted fr fr πŸ‘»
  • -ENOMEM if there's insufficient memory β€” the universe said no 🫠
⚠️ Big important caveat: it is assumed that the caller has already checked that it's permitted for a link to be removed. That means the keyring should have Write permission, and β€” plot twist β€” no permissions are required on the key. Do your homework before you call this, okay? Don't make it weird. πŸ™ˆ

✨ SEE ALSO ✨

Kernel file ./security/keys/keyring.c

Plus the whole friend group:


✨ that's the whole page, you ate that ✨ This little number lives in ./security/keys and it's dated October 2026 β€” so mark your calendar bestie, and go unlink responsibly πŸ’–πŸ¦‹

πŸ“¦ where this page comes from