Skip to content

Commit 8be8e96

Browse files
francispravin5igaw
authored andcommitted
nvme-print: print Boot Partition Write Protection Config feature field
Print the fields of Boot Partition Write Protection Config feature. Signed-off-by: Francis Pravin <[email protected]>
1 parent a7a2c54 commit 8be8e96

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

nvme-print-json.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3886,6 +3886,16 @@ static void json_feature_show_fields_fdp_events(struct json_object *r, unsigned
38863886
}
38873887
}
38883888

3889+
static void json_feature_show_fields_bpwp(struct json_object *r, unsigned int result)
3890+
{
3891+
__u8 field;
3892+
3893+
field = NVME_FEAT_BPWPC_BP0WPS(result);
3894+
obj_add_str(r, "Boot Partition 0 Write Protection State", nvme_bpwps_to_string(field));
3895+
field = NVME_FEAT_BPWPC_BP1WPS(result);
3896+
obj_add_str(r, "Boot Partition 1 Write Protection State", nvme_bpwps_to_string(field));
3897+
}
3898+
38893899
static void json_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
38903900
{
38913901
struct json_object *r;
@@ -4022,6 +4032,9 @@ static void json_feature_show_fields(enum nvme_features_id fid, unsigned int res
40224032
case NVME_FEAT_FID_FDP_EVENTS:
40234033
json_feature_show_fields_fdp_events(r, result, buf);
40244034
break;
4035+
case NVME_FEAT_FID_BP_WRITE_PROTECT:
4036+
json_feature_show_fields_bpwp(r, result);
4037+
break;
40254038
default:
40264039
break;
40274040
}

nvme-print-stdout.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,6 +5224,14 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
52245224
d->evta & 0x1 ? "" : "Not ");
52255225
}
52265226
break;
5227+
case NVME_FEAT_FID_BP_WRITE_PROTECT:
5228+
field = NVME_FEAT_BPWPC_BP1WPS(result);
5229+
printf("\tBoot Partition 1 Write Protection State (BP1WPS): %s\n",
5230+
nvme_bpwps_to_string(field));
5231+
field = NVME_FEAT_BPWPC_BP0WPS(result);
5232+
printf("\tBoot Partition 0 Write Protection State (BP0WPS): %s\n",
5233+
nvme_bpwps_to_string(field));
5234+
break;
52275235
default:
52285236
break;
52295237
}

nvme-print.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,24 @@ const char *nvme_ns_wp_cfg_to_string(enum nvme_ns_write_protect_cfg state)
12021202
}
12031203
}
12041204

1205+
const char *nvme_bpwps_to_string(__u8 bpwps)
1206+
{
1207+
switch (bpwps) {
1208+
case NVME_FEAT_BPWPS_CHANGE_NOT_REQUESTED:
1209+
return "Change in state not requested";
1210+
case NVME_FEAT_BPWPS_WRITE_UNLOCKED:
1211+
return "Write Unlocked";
1212+
case NVME_FEAT_BPWPS_WRITE_LOCKED:
1213+
return "Write Locked";
1214+
case NVME_FEAT_BPWPS_WRITE_LOCKED_PWR_CYCLE:
1215+
return "Write Locked Until Power Cycle";
1216+
case NVME_FEAT_BPWPS_WRITE_PROTECTION_RPMB:
1217+
return "Write Protection controlled by RPMB";
1218+
default:
1219+
return "Reserved";
1220+
}
1221+
}
1222+
12051223
void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result,
12061224
void *buf, __u32 len, nvme_print_flags_t flags)
12071225
{

nvme-print.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ const char *nvme_pel_ehai_pit_to_string(enum nvme_pel_ehai_pit pit);
325325
const char *nvme_ssi_state_to_string(__u8 state);
326326
const char *nvme_time_scale_to_string(__u8 ts);
327327
const char *nvme_pls_mode_to_string(__u8 mode);
328+
const char *nvme_bpwps_to_string(__u8 bpwps);
328329

329330
void nvme_dev_full_path(nvme_ns_t n, char *path, size_t len);
330331
void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len);

0 commit comments

Comments
 (0)