nvme_set_fe...rite_protect(2)

✨ nvme_set_features_write_protect ✨

okay bestie so this one lives in the libnvme API manual and it's literally the glow-up you need when you wanna tell an NVMe device to lock its write protection down πŸ’…


🌸 NAME 🌸

nvme_set_features_write_protect β€” Set write protect feature

like, it sets the write protect feature. that's the whole thing. iconic behaviour honestly πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

int nvme_set_features_write_protect (int fd , enum
nvme_feat_nswpcfg_state state , bool save , __u32 *result );

look at her. four whole arguments. she's serving function signature realness 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • fd β€” File descriptor of nvme device. this is your lil handle to the actual drive, your VIP pass, your backstage bracelet fr 🎟️
  • state β€” Write Protection State. it's an enum nvme_feat_nswpcfg_state bestie, so it's one of the pre-approved vibes only, no freestyling 🧚
  • save β€” Save value across power states. it's a bool, so true means "remember this even after the lights go out" and false means "this is a now-thing, not a forever-thing" πŸ’œ
  • result β€” The command completion result from CQE dword0. pointer to a __u32 where the completion queue entry's dword0 drops its receipts πŸ“¬

πŸ’€ DESCRIPTION πŸ’€

Deprecated: doesn't support specifying a NSID. Use nvme_set_features_write_protect2 instead.

girl. that's it. that's the whole description. this function is the old one, and the thing it can't do is let you specify a NSID β€” and because of that you should go use nvme_set_features_write_protect2 instead. she's retired, she's still cute, but she's retired 🌈

no cap, if you're writing new code, don't be calling this one. pick the sequel. the sequel ate πŸ”₯


πŸ™ˆ RETURN πŸ™ˆ

The nvme command status if a response was received (see enum nvme_status_field) or -1 with errno set otherwise.

so like, two possible endings to this story:

  • you get a response β†’ she hands you the nvme command status, and you go look it up in enum nvme_status_field to find out which one πŸ’«
  • no response / something went sideways β†’ you get -1 and errno is set to tell you what actually happened 😭

check errno. always check errno. that's the whole lesson bestie πŸ’–


and that's the page!! ✨ this one is from the libnvme API manual, dated July 2026 β€” shoutout to the libnvme girlies for keeping the docs shipping, mwah πŸŽ€πŸ«Ά bye pookie, go use the 2 version πŸ’…

πŸ“¦ where this page comes from