nvme_io_passthru(2)
π nvme_io_passthru(2) π
okay bestie, so this is a page from the libnvme API manual, and it's all about one lil' function that yeets a passthrough command at your NVMe device. let's get into it π«Ά
β¨ NAME β¨
nvme_io_passthru β submit an nvme io passthrough command
like. it sends the thing. to the drive. that's the whole vibe π
πΈ SYNOPSIS πΈ
int nvme_io_passthru (int fd , __u8 opcode , __u8 flags , __u16 rsvd ,
__u32 nsid , __u32 cdw2 , __u32 cdw3 , __u32 cdw10 , __u32 cdw11 , __u32
cdw12 , __u32 cdw13 , __u32 cdw14 , __u32 cdw15 , __u32 data_len , void
*data , __u32 metadata_len , void *metadata , __u32 timeout_ms , __u32
*result );
that is a LOT of arguments, i know π she's high maintenance but she works. count them. i'll wait. π
π ARGUMENTS π
here's the full roster, no skips, no cuts, we're doing all of them because every single one matters:
fdβ file descriptor of the nvme device π¦ your ticket to the drive, basically.opcodeβ the nvme io command you're sending β¨ this is the choice, the main character of the call.flagsβ NVMe command flags (not used) π yes literally not used. it's there. it does nothing. we love a decoration.rsvdβ reserved for future use π hands off, it's saving that seat for later.nsidβ namespace identifier π which namespace are we talking to, bestie?cdw2β command dword 2cdw3β command dword 3cdw10β command dword 10cdw11β command dword 11cdw12β command dword 12cdw13β command dword 13cdw14β command dword 14cdw15β command dword 15
yes we jumped fromcdw3tocdw10, that's not a typo, that's just how NVMe rolls π the command dwords are exactly what they say on the tin β the raw dwords of the command.
data_lenβ length of the data transferred in this command, in bytes πdataβ pointer to user address of the data buffer πmetadata_lenβ length of metadata transferred in this commandmetadataβ pointer to user address of the metadata buffer π§timeout_msβ how long the kernel waits for the command to complete β³ patience is a virtue, and this is the exact amount of it.resultβ optional field to return the result from the CQE dword 0 β optional bestie!! you can pass nothing if you don't care about the tea.
π DESCRIPTION π
so this is the parameterized form of nvme_submit_io_passthru. the way it works is it sets up and submits a struct nvme_passthru_cmd for you β you bring the params, she brings the struct, teamwork periodt π€
known values for opcode are defined in enum nvme_io_opcode. so if you're wondering "what can i even put in opcode", that enum is your answer key, go look at it π
π₯ RETURN π₯
what you get back, depending:
- the nvme command status, if a response was received β see
enum nvme_status_fieldfor what those mean π -1witherrnoset, otherwise π aka something went wrong, checkerrno, you got this.
so yeah. that's nvme_io_passthru. feed her your fd, your opcode, all seventeen-ish dwords and buffers, and she'll handle the rest. slay π
β¨
this page dropped July 2026, it's from nvme_io_passthru in the libnvme API manual, and it's filed under section nvme_io_passthru(2) π©· ty for reading, mwah π«Ά
π¦ where this page comes from
- ubuntu stonking: libnvme-dev 1.16.2-1build1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms