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 anenum nvme_feat_nswpcfg_statebestie, so it's one of the pre-approved vibes only, no freestyling π§saveβ Save value across power states. it's abool, sotruemeans "remember this even after the lights go out" andfalsemeans "this is a now-thing, not a forever-thing" πresultβ The command completion result from CQE dword0. pointer to a__u32where 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_fieldto find out which one π« - no response / something went sideways β you get
-1anderrnois 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
- 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