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β astruct nvme_io_argsargument 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_fieldfor the deets π) - or
-1witherrnoset, 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
- 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