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 an enum nvme_feat_nswpcfg_state, so it wants one of those specific state values, not just whatever.
  • save β€” save value across power states. a bool. 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 + errno combo. 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