key_create_or_update(9)
β¨ key_create_or_update β¨
okay so this is a page from the Kernel API Manual (yes, the kernel has lore too π
) and it's all about key_create_or_update β the function that either updates a key or creates one and instantiates it. literally both jobs in one icon, we love a multitasking main character π«Ά
πΈ SYNOPSIS πΈ
key_ref_t key_create_or_update (key_ref_t keyring_ref , const char *type
, const char *description , const void *payload , size_t plen ,
key_perm_t perm , unsigned long flags );
that's the whole signature bestie, take it in π§
π ARGUMENTS π
keyring_refβ a pointer to the destination keyring, and it's got the possession flag riding along with it πtypeβ the type of key, like what kind of key we're dealing with β¨descriptionβ the searchable description for the key, this is how you'll find it later, no cap πpayloadβ the data used to instantiate or update the key πplenβ the length ofpayload, keep it honest πpermβ the permissions mask for a new key πflagsβ the quota flags for a new key π«
π¦ DESCRIPTION π¦
here's the vibe: it searches the destination keyring for a key with the same description. if one turns up, bestie, it gets updated. if not, it creates and instantiates a brand new one and makes a link to it from that keyring. it's giving "find or create", periodt π
if perm is KEY_PERM_UNDEF then an appropriate key permissions mask will be concocted β like it just whips one up for you, iconic π§ͺβ¨
and now the return tea β it returns a pointer to the new key if it's successful. but if things go sideways:
-ENODEVβ the key type wasn't available π-ENOTDIRβ the thing you gave it wasn't a keyring, awkward π-EACCESβ the caller isn't permitted to modify the keyring, or the LSM did not permit creation of the key π
on success, the possession flag from the keyring ref will be tacked on to the key ref before it's returned. so cute, it carries the flag with it π
π SEE ALSO π
the kernel file ./security/keys/key.c (iykyk) plus all these faves:
key_alloc(9)key_payload_reserve(9)key_instantiate_and_link(9)key_reject_and_link(9)key_put(9)key_create(9)key_update(9)key_revoke(9)key_invalidate(9)generic_key_instantiate(9)register_key_type(9)unregister_key_type(9)
and that's the page, bestie! π this one lives in ./security/keys and it's dated October 2026 β go off, future manual βπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms