NVME_SET_FEATURES_WRITE_PROTECT2(2)
π nvme_set_features_write_protect2(2) π
okay bestie, welcome to the libnvme API manual β¨ today's main character is nvme_set_features_write_protect2, and she's here to set the write protect feature on your nvme device. yes, that's the whole vibe. let's get into it π
β¨ SYNOPSIS β¨
int nvme_set_features_write_protect2 (int fd , __u32 nsid , enum
nvme_feat_nswpcfg_state state , bool save , __u32 *result );
like yes, she takes five things and gives you back an int. iconic behavior honestly π
πΈ ARGUMENTS πΈ
fdβ the file descriptor of your nvme device. your little handle to the hardware, your backstage pass π«Άnsidβ the Namespace ID. which namespace are we talking to? this one, bestie.stateβ the Write Protection State. it's anenum nvme_feat_nswpcfg_state, so it wants one of those specific state values, not just whatever.saveβ save value across power states. abool. set it and the setting survives the lights going off β¨resultβ the command completion result from CQE dword0. that's a__u32 *, so she writes back into your pointer, no cap.
π₯ RETURN π₯
so here's the tea β β you get back the nvme command status if a response was received (peep enum nvme_status_field for the full menu of possibilities), or -1 with errno set otherwise. that's it, that's the whole deal. check your errno when you see that -1, fr fr π
lowkey important: those two outcomes are genuinely different situations, so don't just check for failure and move on β one is a real command status, the other is the classic-1+errnocombo. handle both, bestie π
and that's the whole page, you ate it π π sending you off with the deets: this one's from the libnvme API manual, dated July 2026 β go forth and write-protect responsibly, 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