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 2
  • cdw3 β€” command dword 3
  • cdw10 β€” command dword 10
  • cdw11 β€” command dword 11
  • cdw12 β€” command dword 12
  • cdw13 β€” command dword 13
  • cdw14 β€” command dword 14
  • cdw15 β€” command dword 15
yes we jumped from cdw3 to cdw10, 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 command
  • metadata β€” 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_field for what those mean πŸŽ€
  • -1 with errno set, otherwise 😭 aka something went wrong, check errno, 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