@@ -5173,11 +5173,13 @@ static int ns_rescan(int argc, char **argv, struct command *cmd, struct plugin *
5173
5173
static int sanitize_cmd (int argc , char * * argv , struct command * cmd , struct plugin * plugin )
5174
5174
{
5175
5175
const char * desc = "Send a sanitize command." ;
5176
+ const char * emvs_desc = "Enter media verification state." ;
5176
5177
const char * no_dealloc_desc = "No deallocate after sanitize." ;
5177
5178
const char * oipbp_desc = "Overwrite invert pattern between passes." ;
5178
5179
const char * owpass_desc = "Overwrite pass count." ;
5179
5180
const char * ause_desc = "Allow unrestricted sanitize exit." ;
5180
- const char * sanact_desc = "Sanitize action: 1 = Exit failure mode, 2 = Start block erase, 3 = Start overwrite, 4 = Start crypto erase" ;
5181
+ const char * sanact_desc = "Sanitize action: 1 = Exit failure mode, 2 = Start block erase,"
5182
+ "3 = Start overwrite, 4 = Start crypto erase, 5 = Exit media verification" ;
5181
5183
const char * ovrpat_desc = "Overwrite pattern." ;
5182
5184
5183
5185
_cleanup_nvme_dev_ struct nvme_dev * dev = NULL ;
@@ -5190,6 +5192,7 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
5190
5192
bool ause ;
5191
5193
__u8 sanact ;
5192
5194
__u32 ovrpat ;
5195
+ bool emvs ;
5193
5196
};
5194
5197
5195
5198
struct config cfg = {
@@ -5199,13 +5202,15 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
5199
5202
.ause = false,
5200
5203
.sanact = 0 ,
5201
5204
.ovrpat = 0 ,
5205
+ .emvs = false,
5202
5206
};
5203
5207
5204
5208
OPT_VALS (sanact ) = {
5205
5209
VAL_BYTE ("exit-failure" , NVME_SANITIZE_SANACT_EXIT_FAILURE ),
5206
5210
VAL_BYTE ("start-block-erase" , NVME_SANITIZE_SANACT_START_BLOCK_ERASE ),
5207
5211
VAL_BYTE ("start-overwrite" , NVME_SANITIZE_SANACT_START_OVERWRITE ),
5208
5212
VAL_BYTE ("start-crypto-erase" , NVME_SANITIZE_SANACT_START_CRYPTO_ERASE ),
5213
+ VAL_BYTE ("exit-media-verification" , NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF ),
5209
5214
VAL_END ()
5210
5215
};
5211
5216
@@ -5215,7 +5220,8 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
5215
5220
OPT_BYTE ("owpass" , 'n' , & cfg .owpass , owpass_desc ),
5216
5221
OPT_FLAG ("ause" , 'u' , & cfg .ause , ause_desc ),
5217
5222
OPT_BYTE ("sanact" , 'a' , & cfg .sanact , sanact_desc , sanact ),
5218
- OPT_UINT ("ovrpat" , 'p' , & cfg .ovrpat , ovrpat_desc ));
5223
+ OPT_UINT ("ovrpat" , 'p' , & cfg .ovrpat , ovrpat_desc ),
5224
+ OPT_FLAG ("emvs" , 'e' , & cfg .emvs , emvs_desc ));
5219
5225
5220
5226
err = parse_and_open (& dev , argc , argv , desc , opts );
5221
5227
if (err )
@@ -5226,16 +5232,20 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
5226
5232
case NVME_SANITIZE_SANACT_START_BLOCK_ERASE :
5227
5233
case NVME_SANITIZE_SANACT_START_OVERWRITE :
5228
5234
case NVME_SANITIZE_SANACT_START_CRYPTO_ERASE :
5235
+ case NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF :
5229
5236
break ;
5230
5237
default :
5231
5238
nvme_show_error ("Invalid Sanitize Action" );
5232
5239
return - EINVAL ;
5233
5240
}
5234
5241
5235
- if (cfg .sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE ) {
5236
- if (cfg .ause || cfg . no_dealloc ) {
5242
+ if (cfg .ause || cfg . no_dealloc ) {
5243
+ if (cfg .sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE ) {
5237
5244
nvme_show_error ("SANACT is Exit Failure Mode" );
5238
5245
return - EINVAL ;
5246
+ } else if (cfg .sanact == NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF ) {
5247
+ nvme_show_error ("SANACT is Exit Media Verification State" );
5248
+ return - EINVAL ;
5239
5249
}
5240
5250
}
5241
5251
@@ -5260,7 +5270,9 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
5260
5270
.nodas = cfg .no_dealloc ,
5261
5271
.ovrpat = cfg .ovrpat ,
5262
5272
.result = NULL ,
5273
+ .emvs = cfg .emvs ,
5263
5274
};
5275
+
5264
5276
err = nvme_cli_sanitize_nvm (dev , & args );
5265
5277
if (err < 0 )
5266
5278
nvme_show_error ("sanitize: %s" , nvme_strerror (errno ));
0 commit comments