@@ -39,6 +39,7 @@ static int setup_global_range_handle_opts(char *opt, char **arg);
39
39
static int setpw_handle_opts (char * opt , char * * arg );
40
40
static int mbr_control_handle_opts (char * opt , char * * arg );
41
41
static int write_mbr_handle_opts (char * opt , char * * arg );
42
+ static int blocksid_handle_opts (char * opt , char * * arg );
42
43
43
44
static int handle_sed_discv (void );
44
45
static int handle_ownership (void );
@@ -51,6 +52,7 @@ static int handle_setup_global_range(void);
51
52
static int handle_setpw (void );
52
53
static int handle_mbr_control (void );
53
54
static int handle_write_mbr (void );
55
+ static int handle_blocksid (void );
54
56
55
57
static cli_option sed_discv_opts [] = {
56
58
{'d' , "device" , "Device node e.g. /dev/nvme0n1" , 1 , "DEVICE" , CLI_OPTION_REQUIRED },
@@ -105,6 +107,12 @@ static cli_option write_mbr_opts[] = {
105
107
{0 }
106
108
};
107
109
110
+ static cli_option blocksid_opts [] = {
111
+ {'d' , "device" , "Device node e.g. /dev/nvme0n1" , 1 , "DEVICE" , CLI_OPTION_REQUIRED },
112
+ {'r' , "hwreset" , "Clear events by setting Hardware Reset flag. Allowed values: 1/0" , 1 , "FMT" , CLI_OPTION_REQUIRED },
113
+ {0 }
114
+ };
115
+
108
116
static cli_command sedcli_commands [] = {
109
117
{
110
118
.name = "discovery" ,
@@ -206,6 +214,17 @@ static cli_command sedcli_commands[] = {
206
214
.flags = 0 ,
207
215
.help = NULL
208
216
},
217
+ {
218
+ .name = "block_sid" ,
219
+ .short_name = 'B' ,
220
+ .desc = "Issue BlockSID authentication command" ,
221
+ .long_desc = "Issue BlockSID authentication command" ,
222
+ .options = blocksid_opts ,
223
+ .command_handle_opts = blocksid_handle_opts ,
224
+ .handle = handle_blocksid ,
225
+ .flags = 0 ,
226
+ .help = NULL
227
+ },
209
228
{
210
229
.name = "version" ,
211
230
.short_name = 'V' ,
@@ -257,6 +276,7 @@ struct sedcli_options {
257
276
int enable ;
258
277
int done ;
259
278
int offset ;
279
+ bool hardware_reset ;
260
280
int non_destructive ;
261
281
};
262
282
@@ -422,6 +442,24 @@ int write_mbr_handle_opts(char *opt, char **arg)
422
442
return 0 ;
423
443
}
424
444
445
+ int blocksid_handle_opts (char * opt , char * * arg )
446
+ {
447
+ /* No reset BlockSID upon power events */
448
+ int hwreset_flag = 0 ;
449
+
450
+ if (!strcmp (opt , "device" )) {
451
+ strncpy (opts -> dev_path , arg [0 ], PATH_MAX - 1 );
452
+ } else if (!strcmp (opt , "hwreset" ) && strlen (arg [0 ]) == 1 ) {
453
+ if ((arg [0 ][0 ] != '0' ) && (arg [0 ][0 ] != '1' )) {
454
+ return - EINVAL ;
455
+ }
456
+ hwreset_flag = atoi (arg [0 ]);
457
+ opts -> hardware_reset = (hwreset_flag == 1 ) ? true : false;
458
+ }
459
+
460
+ return 0 ;
461
+ }
462
+
425
463
static void print_sed_status (int status )
426
464
{
427
465
const char * sed_status = NULL ;
@@ -1095,6 +1133,25 @@ static int handle_write_mbr(void)
1095
1133
return ret ;
1096
1134
}
1097
1135
1136
+ static int handle_blocksid (void )
1137
+ {
1138
+ struct sed_device * dev = NULL ;
1139
+ int ret = sed_init (& dev , opts -> dev_path );
1140
+
1141
+ if (ret ) {
1142
+ sedcli_printf (LOG_ERR , "Error in initializing the dev: %s\n" ,
1143
+ opts -> dev_path );
1144
+ return ret ;
1145
+ }
1146
+
1147
+ ret = sed_issue_blocksid_cmd (dev , opts -> hardware_reset );
1148
+
1149
+ print_sed_status (ret );
1150
+ sed_deinit (dev );
1151
+
1152
+ return ret ;
1153
+ }
1154
+
1098
1155
static int handle_version (void )
1099
1156
{
1100
1157
sedcli_printf (LOG_INFO , "sedcli %s\n" , SEDCLI_VERSION );
0 commit comments