Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -4020,19 +4020,22 @@ static void json_feature_show_fields_sw_progress(struct json_object *r, unsigned
obj_add_uint(r, "Pre-boot Software Load Count (PBSLC)", result & 0xff);
}

static void json_feature_show_fields_host_id(struct json_object *r, unsigned char *buf)
static void json_feature_show_fields_host_id(struct json_object *r,
unsigned int result, unsigned char *hostid)
{
uint64_t ull = 0;
int i;
bool exhid;

if (buf) {
for (i = sizeof(ull) / sizeof(*buf); i; i--) {
ull |= buf[i - 1];
if (i - 1)
ull <<= BYTE_TO_BIT(sizeof(buf[i]));
}
obj_add_uint64(r, "Host Identifier (HOSTID)", ull);
}
if (!hostid)
return;

nvme_feature_decode_host_id(result, &exhid);

if (exhid)
obj_add_str(r, "Host Identifier (HOSTID)",
uint128_t_to_l10n_string(le128_to_cpu(hostid)));
else
obj_add_uint64(r, "Host Identifier (HOSTID)",
le64_to_cpu(*(__le64 *)hostid));
}

static void json_feature_show_fields_resv_mask(struct json_object *r, unsigned int result)
Expand Down Expand Up @@ -4296,7 +4299,7 @@ static void json_feature_show_fields(enum nvme_features_id fid, unsigned int res
json_feature_show_fields_sw_progress(r, result);
break;
case NVME_FEAT_FID_HOST_ID:
json_feature_show_fields_host_id(r, buf);
json_feature_show_fields_host_id(r, result, buf);
break;
case NVME_FEAT_FID_RESV_MASK:
json_feature_show_fields_resv_mask(r, result);
Expand Down
14 changes: 4 additions & 10 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -5135,25 +5135,19 @@ static void stdout_host_metadata(enum nvme_features_id fid,

static void stdout_feat_host_id(unsigned int result, unsigned char *hostid)
{
uint64_t ull;
bool exhid;

if (!hostid)
return;

nvme_feature_decode_host_id(result, &exhid);

if (exhid) {
if (exhid)
printf("\tHost Identifier (HOSTID): %s\n",
uint128_t_to_l10n_string(le128_to_cpu(hostid)));
return;
}

ull = hostid[7]; ull <<= 8; ull |= hostid[6]; ull <<= 8;
ull |= hostid[5]; ull <<= 8; ull |= hostid[4]; ull <<= 8;
ull |= hostid[3]; ull <<= 8; ull |= hostid[2]; ull <<= 8;
ull |= hostid[1]; ull <<= 8; ull |= hostid[0];
printf("\tHost Identifier (HOSTID): %" PRIu64 "\n", ull);
else
printf("\tHost Identifier (HOSTID): %" PRIu64 "\n",
le64_to_cpu(*(__le64 *)hostid));
}

static void stdout_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
Expand Down