libnvme_get_nsid(9)
π libnvme_get_nsid(9) β the libnvme API manual, bestie edition π
okay so bestie, welcome to libnvme_get_nsid from the libnvme API manual!! this one is short and sweet and honestly kind of iconic for a slightly cursed reason, so let's get into it β¨
πΈ NAME πΈ
libnvme_get_nsid β retrieve the NSID from a namespace file descriptor π
like, that's it. that's the whole job. you hand it a namespace fd and it gives you the namespace id back. slay.
β¨ SYNOPSIS β¨
int libnvme_get_nsid (struct libnvme_transport_handle *hdl , __u32 *nsid );
no cap, that's the whole signature. two args, one int coming back at you π«Ά
π¦ ARGUMENTS π¦
hdlβ the transport handle π your whole vibe-checked connection situation, passed in as astruct libnvme_transport_handle *.nsidβ a user pointer to the namespace id π it's__u32 *, and it's where the answer lands. you provide the space, the function fills it in.
π DESCRIPTION π
okay so here's the tea β β this one should only be sent to namespace handles, not to controllers. like, do not come for controllers with this function, they are not the main character here π
and now for the part that's giving "who designed this" energy π: the kernel's interface returns the nsid as the return value. yes, the return value. that's the whole mechanism.
and that is, in the original's own words, unfortunate for many architectures that are incapable of distinguishing a namespace id > 0x80000000 from a negative error number πππ
like bestie, imagine your namespace id is out here living its life above 0x80000000 and the architecture just cannot tell it apart from a negative error number. the audacity. not me crying about integer sign semantics at 2am π
so yeah β keep it namespace-handle-only, and keep that quirk in mind. iykyk π
π₯ RETURN π₯
0β the nsid was set successfully, we love a clean win β- negative error code β otherwise π something went sideways
π§ sign-off π§
that's the whole page, bestie!! this gem comes from libnvme_get_nsid, dated October 2026, and it lives in the source/version tag libnvme_get_nsid on both ends of the page π
go forth and get your nsids, but only from namespace handles, fr fr ππ«Άπ
π¦ where this page comes from
- arch rolling: nvme-cli 3.2-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms