nvme_write_zeros(2)

πŸ’… nvme_write_zeros β€” bestie's guide to the libnvme API manual

okay so this is nvme_write_zeros(2), a section 2 manual page from the libnvme API manual. yes it's a C function, yes it's about NVMe, yes we're doing this. sit down, hydrate, let's go 🫢


✨ NAME ✨

nvme_write_zeros β€” submit an nvme write zeroes command 🌸

that's it. that's the whole name section. iconic honestly.


✨ SYNOPSIS ✨

int nvme_write_zeros (struct nvme_io_args *args );

look at her. one function, one pointer, int return. lowkey the blueprint πŸ’œ


✨ ARGUMENTS ✨

  • args β€” a struct nvme_io_args argument structure. that's the one and only thing you hand over. just the struct, babe. that's it. no cap πŸ™ˆ

✨ DESCRIPTION ✨

so the Write Zeroes command does exactly what it says on the tin: it sets a range of logical blocks to zero. like, the whole range. just zeroes. everywhere. πŸ’€

and after this command completes successfully, the value returned by subsequent reads of logical blocks in that range shall be all bytes cleared to 0h β€” and they stay that way until a write occurs to this LBA range. so like. no take-backs until somebody actually writes there. periodt ✨

bestie note: this isn't a "maybe zeros", this is a "shall be all bytes cleared to 0h". the manpage is being very clear. that's a contract, not a vibe. πŸŽ€

✨ RETURN ✨

here's what comes back:

  • the nvme command status, if a response was received (go peek at enum nvme_status_field for the deets πŸ‘‘)
  • or -1 with errno set, otherwise 😭

so yeah, check your return value. always. she's not gonna warn you twice. πŸ’…


fr fr bestie, that's the whole page β€” no options list, no environment variables, no SEE ALSO. just a clean little function wearing a beautiful little struct. main character energy, honestly. ⭐

kisses, and go read your enum nvme_status_field before you come crying to me about a -1 🧚


that's a wrap on the July 2026 edition of nvme_write_zeros(2) from the libnvme API manual β€” catch you in the next page, mwah πŸŽ€πŸ’–

πŸ“¦ where this page comes from