if (value)
obj_add_str(o, result_str, value);
else
- json_object_add_value_string(o, result_str, "Could not allocate string");
+ obj_add_str(o, result_str, "Could not allocate string");
free(value);
}
for (i = 0; i < sizeof(ns->nguid); i++)
nguid += sprintf(nguid, "%02x", ns->nguid[i]);
- json_object_add_value_string(root, "eui64", eui64_buf);
- json_object_add_value_string(root, "nguid", nguid_buf);
+ root_add_str("eui64", eui64_buf);
+ root_add_str("nguid", nguid_buf);
}
json_object_add_value_array(root, "lbafs", lbafs);
json_object_add_value_int(root, "vid", le16_to_cpu(ctrl->vid));
json_object_add_value_int(root, "ssvid", le16_to_cpu(ctrl->ssvid));
- json_object_add_value_string(root, "sn", sn);
- json_object_add_value_string(root, "mn", mn);
- json_object_add_value_string(root, "fr", fr);
+ root_add_str("sn", sn);
+ root_add_str("mn", mn);
+ root_add_str("fr", fr);
json_object_add_value_int(root, "rab", ctrl->rab);
json_object_add_value_int(root, "ieee", ieee);
json_object_add_value_int(root, "cmic", ctrl->cmic);
json_object_add_value_uint(root, "ctratt", le32_to_cpu(ctrl->ctratt));
json_object_add_value_int(root, "rrls", le16_to_cpu(ctrl->rrls));
json_object_add_value_int(root, "cntrltype", ctrl->cntrltype);
- json_object_add_value_string(root, "fguid", util_uuid_to_string(ctrl->fguid));
+ root_add_str("fguid", util_uuid_to_string(ctrl->fguid));
json_object_add_value_int(root, "crdt1", le16_to_cpu(ctrl->crdt1));
json_object_add_value_int(root, "crdt2", le16_to_cpu(ctrl->crdt2));
json_object_add_value_int(root, "crdt3", le16_to_cpu(ctrl->crdt3));
json_object_add_value_uint(root, "oaqd", le32_to_cpu(ctrl->oaqd));
if (strlen(subnqn))
- json_object_add_value_string(root, "subnqn", subnqn);
+ root_add_str("subnqn", subnqn);
json_object_add_value_uint(root, "ioccsz", le32_to_cpu(ctrl->ioccsz));
json_object_add_value_uint(root, "iorcsz", le32_to_cpu(ctrl->iorcsz));
sprintf(hostid + j * 2, "%02x",
status->regctl_eds[i].hostid[j]);
- json_object_add_value_string(rc, "hostid", hostid);
+ obj_add_str(rc, "hostid", hostid);
json_array_add_value_object(rcs, rc);
}
}
snprintf(str, sizeof(str), "%"PRIu64" (%s)",
le64_to_cpu(*frs),
util_fw_to_string(fw_log->frs[i]));
- json_object_add_value_string(fwsi, fmt, str);
+ obj_add_str(fwsi, fmt, str);
}
}
if (log->ns[0] == cpu_to_le32(0xffffffff))
return;
- json_object_add_value_string(root, "Changed Namespace List Log",
- devname);
+ root_add_str("Changed Namespace List Log", devname);
for (i = 0; i < NVME_ID_NS_LIST_MAX; i++) {
nsid = le32_to_cpu(log->ns[i]);
snprintf(fmt, sizeof(fmt), "[%4u]", i + 1);
snprintf(str, sizeof(str), "%#x", nsid);
- json_object_add_value_string(nsi, fmt, str);
+ obj_add_str(nsi, fmt, str);
}
json_object_add_value_object(root, devname, nsi);
__u32 nr_nsids;
int i, j;
- json_object_add_value_string(root, "Asymmetric Namespace Access Log for NVMe device",
- devname);
+ root_add_str("Asymmetric Namespace Access Log for NVMe device", devname);
json_object_add_value_uint64(root, "chgcnt", le64_to_cpu(hdr->chgcnt));
json_object_add_value_uint(root, "ngrps", le16_to_cpu(hdr->ngrps));
json_object_add_value_uint(desc, "grpid", le32_to_cpu(ana_desc->grpid));
json_object_add_value_uint(desc, "nnsids", le32_to_cpu(ana_desc->nnsids));
json_object_add_value_uint64(desc, "chgcnt", le64_to_cpu(ana_desc->chgcnt));
- json_object_add_value_string(desc, "state",
- nvme_ana_state_to_string(ana_desc->state));
+ obj_add_str(desc, "state", nvme_ana_state_to_string(ana_desc->state));
ns_list = json_create_array();
for (j = 0; j < le32_to_cpu(ana_desc->nnsids); j++) {
struct json_object *amso = json_create_object();
sprintf(json_str, "%"PRIx64"", *(uint64_t *)cap);
- json_object_add_value_string(root, "cap", json_str);
+ root_add_str("cap", json_str);
root_add_str("Controller Ready With Media Support (CRWMS)",
cap->crwms ? supported : not_supported);
json_single_property_human(offset, value64, root);
} else {
sprintf(json_str, "0x%02x", offset);
- json_object_add_value_string(root, "property", json_str);
+ root_add_str("property", json_str);
- json_object_add_value_string(root, "name", nvme_register_to_string(offset));
+ root_add_str("name", nvme_register_to_string(offset));
if (nvme_is_64bit_reg(offset))
sprintf(json_str, "%"PRIx64"", value64);
else
sprintf(json_str, "%x", value32);
- json_object_add_value_string(root, "value", json_str);
+ root_add_str("value", json_str);
}
json_print(root);
status_str = nvme_sstat_status_to_string(status);
sprintf(str, "(%d) %s", status & NVME_SANITIZE_SSTAT_STATUS_MASK,
status_str);
- json_object_add_value_string(sstat, "status", str);
+ obj_add_str(sstat, "status", str);
json_object_add_value_object(dev, "sstat", sstat);
json_object_add_value_uint(dev, "cdw10_info",
if ((seb >> bit) & 0x1)
snprintf(evt_str, sizeof(evt_str), "Support %s",
nvme_pel_event_to_string(bit + i * 8));
- json_object_add_value_string(root, key, evt_str);
+ root_add_str(key, evt_str);
}
}
}
json_object_add_value_uint64(root, "power_cycle_count", le64_to_cpu(pevent_log_head->pcc));
json_object_add_value_uint(root, "pci_vid", le16_to_cpu(pevent_log_head->vid));
json_object_add_value_uint(root, "pci_ssvid", le16_to_cpu(pevent_log_head->ssvid));
- json_object_add_value_string(root, "sn", sn);
- json_object_add_value_string(root, "mn", mn);
- json_object_add_value_string(root, "subnqn", subnqn);
+ root_add_str("sn", sn);
+ root_add_str("mn", mn);
+ root_add_str("subnqn", subnqn);
json_object_add_value_uint(root, "gen_number", le16_to_cpu(pevent_log_head->gen_number));
json_object_add_value_uint(root, "rci", le32_to_cpu(pevent_log_head->rci));
snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)", le64_to_cpu(fw_commit_event->old_fw_rev),
util_fw_to_string((char *)&fw_commit_event->old_fw_rev));
- json_object_add_value_string(valid_attrs, "old_fw_rev", fw_str);
+ obj_add_str(valid_attrs, "old_fw_rev", fw_str);
snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)", le64_to_cpu(fw_commit_event->new_fw_rev),
util_fw_to_string((char *)&fw_commit_event->new_fw_rev));
- json_object_add_value_string(valid_attrs, "new_fw_rev", fw_str);
+ obj_add_str(valid_attrs, "new_fw_rev", fw_str);
json_object_add_value_uint(valid_attrs, "fw_commit_action",
fw_commit_event->fw_commit_action);
json_object_add_value_uint(valid_attrs, "fw_slot", fw_commit_event->fw_slot);
fw_rev = pevent_log_info + offset;
snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)", le64_to_cpu(*fw_rev),
util_fw_to_string((char *)fw_rev));
- json_object_add_value_string(valid_attrs, "fw_rev", fw_str);
+ obj_add_str(valid_attrs, "fw_rev", fw_str);
for (i = 0; i < por_info_list; i++) {
por_event = pevent_log_info + offset + sizeof(*fw_rev) + i * sizeof(*por_event);
valid_attrs = json_create_object();
json_object_add_value_uint(valid_attrs, "event_number", i);
- json_object_add_value_string(valid_attrs, "event_type",
- nvme_pel_event_to_string(pevent_entry_head->etype));
+ obj_add_str(valid_attrs, "event_type",
+ nvme_pel_event_to_string(pevent_entry_head->etype));
json_object_add_value_uint(valid_attrs, "event_type_rev",
pevent_entry_head->etype_rev);
json_object_add_value_uint(valid_attrs, "event_header_len", pevent_entry_head->ehl);
switch (list->cmpc) {
case 1:
- json_object_add_value_string(root, "cmpc-definition",
+ root_add_str("cmpc-definition",
"Completed due to transferring the amount of data specified in the MNDW field");
break;
case 2:
- json_object_add_value_string(root, "cmpc-definition",
+ root_add_str("cmpc-definition",
"Completed due to having performed the action specified in the Action Type field over the number of logical blocks specified in the Range Length field");
break;
default:
json_object_add_value_array(root, json_str, lsde);
e = &list->descs[idx];
sprintf(json_str, "0x%016"PRIu64"", le64_to_cpu(e->dslba));
- json_object_add_value_string(lsde, "DSLBA", json_str);
+ obj_add_str(lsde, "DSLBA", json_str);
sprintf(json_str, "0x%08x", le32_to_cpu(e->nlb));
- json_object_add_value_string(lsde, "NLB", json_str);
+ obj_add_str(lsde, "NLB", json_str);
sprintf(json_str, "0x%02x", e->status);
- json_object_add_value_string(lsde, "Status", json_str);
+ obj_add_str(lsde, "Status", json_str);
}
json_print(root);
sprintf(printable++, "\n");
}
- json_object_add_value_string(root, "printable_eye", printable_start);
+ root_add_str("printable_eye", printable_start);
exit:
return printable_start;
nvme_ctrl_t c = nvme_path_get_ctrl(p);
path_attrs = json_create_object();
- json_object_add_value_string(path_attrs, "Name",
- nvme_ctrl_get_name(c));
- json_object_add_value_string(path_attrs, "Transport",
- nvme_ctrl_get_transport(c));
- json_object_add_value_string(path_attrs, "Address",
- nvme_ctrl_get_address(c));
- json_object_add_value_string(path_attrs, "State",
- nvme_ctrl_get_state(c));
- json_object_add_value_string(path_attrs, "ANAState",
- nvme_path_get_ana_state(p));
+ obj_add_str(path_attrs, "Name", nvme_ctrl_get_name(c));
+ obj_add_str(path_attrs, "Transport", nvme_ctrl_get_transport(c));
+ obj_add_str(path_attrs, "Address", nvme_ctrl_get_address(c));
+ obj_add_str(path_attrs, "State", nvme_ctrl_get_state(c));
+ obj_add_str(path_attrs, "ANAState", nvme_path_get_ana_state(p));
json_array_add_value_object(paths, path_attrs);
i++;
}
struct json_object *path_attrs;
path_attrs = json_create_object();
- json_object_add_value_string(path_attrs, "Name",
- nvme_ctrl_get_name(c));
- json_object_add_value_string(path_attrs, "Transport",
- nvme_ctrl_get_transport(c));
- json_object_add_value_string(path_attrs, "Address",
- nvme_ctrl_get_address(c));
- json_object_add_value_string(path_attrs, "State",
- nvme_ctrl_get_state(c));
+ obj_add_str(path_attrs, "Name", nvme_ctrl_get_name(c));
+ obj_add_str(path_attrs, "Transport", nvme_ctrl_get_transport(c));
+ obj_add_str(path_attrs, "Address", nvme_ctrl_get_address(c));
+ obj_add_str(path_attrs, "State", nvme_ctrl_get_state(c));
json_array_add_value_object(paths, path_attrs);
}
}
const char *hostid;
host_attrs = json_create_object();
- json_object_add_value_string(host_attrs, "HostNQN",
- nvme_host_get_hostnqn(h));
+ obj_add_str(host_attrs, "HostNQN", nvme_host_get_hostnqn(h));
hostid = nvme_host_get_hostid(h);
if (hostid)
- json_object_add_value_string(host_attrs, "HostID", hostid);
+ obj_add_str(host_attrs, "HostID", hostid);
subsystems = json_create_array();
nvme_for_each_subsystem(h, s) {
subsystem_attrs = json_create_object();
- json_object_add_value_string(subsystem_attrs, "Name",
- nvme_subsystem_get_name(s));
- json_object_add_value_string(subsystem_attrs, "NQN",
- nvme_subsystem_get_nqn(s));
- json_object_add_value_string(subsystem_attrs, "IOPolicy",
- nvme_subsystem_get_iopolicy(s));
+ obj_add_str(subsystem_attrs, "Name", nvme_subsystem_get_name(s));
+ obj_add_str(subsystem_attrs, "NQN", nvme_subsystem_get_nqn(s));
+ obj_add_str(subsystem_attrs, "IOPolicy", nvme_subsystem_get_iopolicy(s));
json_array_add_value_object(subsystems, subsystem_attrs);
paths = json_create_array();
json_object_add_value_int(elem, "loc", pos);
json_object_add_value_int(elem, "nidt", (int)cur->nidt);
json_object_add_value_int(elem, "nidl", (int)cur->nidl);
- json_object_add_value_string(elem, "type", nidt_name);
- json_object_add_value_string(elem, nidt_name, json_str);
+ obj_add_str(elem, "type", nidt_name);
+ obj_add_str(elem, nidt_name, json_str);
if (!json_array)
json_array = json_create_array();
le64_to_cpu(desc->wp));
json_object_add_value_uint64(zone, "cap",
le64_to_cpu(desc->zcap));
- json_object_add_value_string(zone, "state",
- nvme_zone_state_to_string(desc->zs >> 4));
- json_object_add_value_string(zone, "type",
- nvme_zone_type_to_string(desc->zt));
+ obj_add_str(zone, "state", nvme_zone_state_to_string(desc->zs >> 4));
+ obj_add_str(zone, "type", nvme_zone_type_to_string(desc->zt));
json_object_add_value_uint(zone, "attrs", desc->za);
json_object_add_value_uint(zone, "attrs_info", desc->zai);
json_object_add_value_array(zone, "ext_data",
ext_data);
} else {
- json_object_add_value_string(zone, "ext_data", "Not valid");
+ obj_add_str(zone, "ext_data", "Not valid");
}
}
memcpy(&uuid, uuid_list->entry[i].uuid, sizeof(uuid));
json_object_add_value_int(entry, "association",
uuid_list->entry[i].header & 0x3);
- json_object_add_value_string(entry, "uuid",
+ obj_add_str(entry, "uuid",
util_uuid_to_string(uuid));
json_array_add_value_object(entries, entry);
}
struct json_object *jsslist = json_create_array();
const char *hostid;
- json_object_add_value_string(hss, "HostNQN", nvme_host_get_hostnqn(h));
+ obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h));
hostid = nvme_host_get_hostid(h);
if (hostid)
- json_object_add_value_string(hss, "HostID", hostid);
+ obj_add_str(hss, "HostID", hostid);
nvme_for_each_subsystem(h , s) {
struct json_object *jss = json_create_object();
struct json_object *jctrls = json_create_array();
struct json_object *jnss = json_create_array();
- json_object_add_value_string(jss, "Subsystem", nvme_subsystem_get_name(s));
- json_object_add_value_string(jss, "SubsystemNQN", nvme_subsystem_get_nqn(s));
+ obj_add_str(jss, "Subsystem", nvme_subsystem_get_name(s));
+ obj_add_str(jss, "SubsystemNQN", nvme_subsystem_get_nqn(s));
nvme_subsystem_for_each_ctrl(s, c) {
struct json_object *jctrl = json_create_object();
struct json_object *jnss = json_create_array();
struct json_object *jpaths = json_create_array();
- json_object_add_value_string(jctrl, "Controller", nvme_ctrl_get_name(c));
- json_object_add_value_string(jctrl, "SerialNumber", nvme_ctrl_get_serial(c));
- json_object_add_value_string(jctrl, "ModelNumber", nvme_ctrl_get_model(c));
- json_object_add_value_string(jctrl, "Firmware", nvme_ctrl_get_firmware(c));
- json_object_add_value_string(jctrl, "Transport", nvme_ctrl_get_transport(c));
- json_object_add_value_string(jctrl, "Address", nvme_ctrl_get_address(c));
- json_object_add_value_string(jctrl, "Slot", nvme_ctrl_get_phy_slot(c));
+ obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c));
+ obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c));
+ obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c));
+ obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c));
+ obj_add_str(jctrl, "Transport", nvme_ctrl_get_transport(c));
+ obj_add_str(jctrl, "Address", nvme_ctrl_get_address(c));
+ obj_add_str(jctrl, "Slot", nvme_ctrl_get_phy_slot(c));
nvme_ctrl_for_each_ns(c, n) {
struct json_object *jns = json_create_object();
uint64_t nsze = nvme_ns_get_lba_count(n) * lba;
uint64_t nuse = nvme_ns_get_lba_util(n) * lba;
- json_object_add_value_string(jns, "NameSpace", nvme_ns_get_name(n));
- json_object_add_value_string(jns, "Generic", nvme_ns_get_generic_name(n));
+ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n));
+ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n));
json_object_add_value_int(jns, "NSID", nvme_ns_get_nsid(n));
json_object_add_value_uint64(jns, "UsedBytes", nuse);
json_object_add_value_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n));
nvme_ctrl_for_each_path(c, p) {
struct json_object *jpath = json_create_object();
- json_object_add_value_string(jpath, "Path", nvme_path_get_name(p));
- json_object_add_value_string(jpath, "ANAState", nvme_path_get_ana_state(p));
+ obj_add_str(jpath, "Path", nvme_path_get_name(p));
+ obj_add_str(jpath, "ANAState", nvme_path_get_ana_state(p));
json_array_add_value_object(jpaths, jpath);
}
uint64_t nsze = nvme_ns_get_lba_count(n) * lba;
uint64_t nuse = nvme_ns_get_lba_util(n) * lba;
- json_object_add_value_string(jns, "NameSpace", nvme_ns_get_name(n));
- json_object_add_value_string(jns, "Generic", nvme_ns_get_generic_name(n));
+ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n));
+ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n));
json_object_add_value_int(jns, "NSID", nvme_ns_get_nsid(n));
json_object_add_value_uint64(jns, "UsedBytes", nuse);
json_object_add_value_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n));
nvme_ctrl_t c = nvme_path_get_ctrl(p);
path_attrs = json_create_object();
- json_object_add_value_string(path_attrs, "Name",
- nvme_ctrl_get_name(c));
- json_object_add_value_string(path_attrs, "Transport",
- nvme_ctrl_get_transport(c));
- json_object_add_value_string(path_attrs, "Address",
- nvme_ctrl_get_address(c));
- json_object_add_value_string(path_attrs, "State",
- nvme_ctrl_get_state(c));
- json_object_add_value_string(path_attrs, "ANAState",
- nvme_path_get_ana_state(p));
+ obj_add_str(path_attrs, "Name", nvme_ctrl_get_name(c));
+ obj_add_str(path_attrs, "Transport", nvme_ctrl_get_transport(c));
+ obj_add_str(path_attrs, "Address", nvme_ctrl_get_address(c));
+ obj_add_str(path_attrs, "State", nvme_ctrl_get_state(c));
+ obj_add_str(path_attrs, "ANAState", nvme_path_get_ana_state(p));
json_array_add_value_object(paths, path_attrs);
}
json_object_add_value_array(ns_attrs, "Paths", paths);
ctrl = json_create_array();
ctrl_attrs = json_create_object();
- json_object_add_value_string(ctrl_attrs, "Name",
+ obj_add_str(ctrl_attrs, "Name",
nvme_ctrl_get_name(c));
- json_object_add_value_string(ctrl_attrs, "Transport",
+ obj_add_str(ctrl_attrs, "Transport",
nvme_ctrl_get_transport(c));
- json_object_add_value_string(ctrl_attrs, "Address",
+ obj_add_str(ctrl_attrs, "Address",
nvme_ctrl_get_address(c));
- json_object_add_value_string(ctrl_attrs, "State",
+ obj_add_str(ctrl_attrs, "State",
nvme_ctrl_get_state(c));
json_array_add_value_object(ctrl, ctrl_attrs);
const char *hostid;
host_attrs = json_create_object();
- json_object_add_value_string(host_attrs, "HostNQN",
- nvme_host_get_hostnqn(h));
+ obj_add_str(host_attrs, "HostNQN", nvme_host_get_hostnqn(h));
hostid = nvme_host_get_hostid(h);
if (hostid)
- json_object_add_value_string(host_attrs, "HostID", hostid);
+ obj_add_str(host_attrs, "HostID", hostid);
subsystems = json_create_array();
nvme_for_each_subsystem(h, s) {
subsystem_attrs = json_create_object();
- json_object_add_value_string(subsystem_attrs, "Name",
- nvme_subsystem_get_name(s));
- json_object_add_value_string(subsystem_attrs, "NQN",
- nvme_subsystem_get_nqn(s));
- json_object_add_value_string(subsystem_attrs, "IOPolicy",
- nvme_subsystem_get_iopolicy(s));
+ obj_add_str(subsystem_attrs, "Name", nvme_subsystem_get_name(s));
+ obj_add_str(subsystem_attrs, "NQN", nvme_subsystem_get_nqn(s));
+ obj_add_str(subsystem_attrs, "IOPolicy", nvme_subsystem_get_iopolicy(s));
json_array_add_value_object(subsystems, subsystem_attrs);
namespaces = json_create_array();
case NVME_DIRECTIVE_RECEIVE_IDENTIFY_DOPER_PARAM:
support = json_create_array();
json_object_add_value_array(root, "Directive support", support);
- json_object_add_value_string(support, "Identify Directive",
- *field & 0x1 ? "supported" : "not supported");
- json_object_add_value_string(support, "Stream Directive",
- *field & 0x2 ? "supported" : "not supported");
- json_object_add_value_string(support, "Data Placement Directive",
- *field & 0x4 ? "supported" : "not supported");
+ obj_add_str(support, "Identify Directive",
+ *field & 0x1 ? "supported" : "not supported");
+ obj_add_str(support, "Stream Directive",
+ *field & 0x2 ? "supported" : "not supported");
+ obj_add_str(support, "Data Placement Directive",
+ *field & 0x4 ? "supported" : "not supported");
enabled = json_create_array();
json_object_add_value_array(root, "Directive enabled", enabled);
- json_object_add_value_string(enabled, "Identify Directive",
- *(field + 32) & 0x1 ? "enabled" : "disabled");
- json_object_add_value_string(enabled, "Stream Directive",
- *(field + 32) & 0x2 ? "enabled" : "disabled");
- json_object_add_value_string(enabled, "Data Placement Directive",
- *(field + 32) & 0x4 ? "enabled" : "disabled");
+ obj_add_str(enabled, "Identify Directive",
+ *(field + 32) & 0x1 ? "enabled" : "disabled");
+ obj_add_str(enabled, "Stream Directive",
+ *(field + 32) & 0x2 ? "enabled" : "disabled");
+ obj_add_str(enabled, "Data Placement Directive",
+ *(field + 32) & 0x4 ? "enabled" : "disabled");
persistent = json_create_array();
json_object_add_value_array(root,
"Directive Persistent Across Controller Level Resets",
persistent);
- json_object_add_value_string(persistent, "Identify Directive",
- *(field + 32) & 0x1 ? "enabled" : "disabled");
- json_object_add_value_string(persistent, "Stream Directive",
- *(field + 32) & 0x2 ? "enabled" : "disabled");
- json_object_add_value_string(persistent, "Data Placement Directive",
- *(field + 32) & 0x4 ? "enabled" : "disabled");
+ obj_add_str(persistent, "Identify Directive",
+ *(field + 32) & 0x1 ? "enabled" : "disabled");
+ obj_add_str(persistent, "Stream Directive",
+ *(field + 32) & 0x2 ? "enabled" : "disabled");
+ obj_add_str(persistent, "Data Placement Directive",
+ *(field + 32) & 0x4 ? "enabled" : "disabled");
break;
default:
- json_object_add_value_string(root, error_str,
- "invalid directive operations for Identify Directives");
+ root_add_str(error_str, "invalid directive operations for Identify Directives");
break;
}
}
result & 0xffff);
break;
default:
- json_object_add_value_string(root, error_str,
+ root_add_str(error_str,
"invalid directive operations for Streams Directives");
break;
}
json_directive_show_fields_streams(doper, result, (__u16 *)field, root);
break;
default:
- json_object_add_value_string(root, error_str, "invalid directive type");
+ root_add_str(error_str, "invalid directive type");
break;
}
}
char json_str[STR_LEN];
sprintf(json_str, "%#x", type);
- json_object_add_value_string(root, "type", json_str);
+ root_add_str("type", json_str);
sprintf(json_str, "%#x", oper);
- json_object_add_value_string(root, "operation", json_str);
+ root_add_str("operation", json_str);
sprintf(json_str, "%#x", spec);
- json_object_add_value_string(root, "spec", json_str);
+ root_add_str("spec", json_str);
sprintf(json_str, "%#x", nsid);
- json_object_add_value_string(root, "nsid", json_str);
+ root_add_str("nsid", json_str);
sprintf(json_str, "%#x", result);
root_add_result(json_str);
struct nvmf_disc_log_entry *e = &log->entries[i];
struct json_object *entry = json_create_object();
- json_object_add_value_string(entry, "trtype",
- nvmf_trtype_str(e->trtype));
- json_object_add_value_string(entry, "adrfam",
- nvmf_adrfam_str(e->adrfam));
- json_object_add_value_string(entry, "subtype",
- nvmf_subtype_str(e->subtype));
- json_object_add_value_string(entry,"treq",
- nvmf_treq_str(e->treq));
+ obj_add_str(entry, "trtype", nvmf_trtype_str(e->trtype));
+ obj_add_str(entry, "adrfam", nvmf_adrfam_str(e->adrfam));
+ obj_add_str(entry, "subtype", nvmf_subtype_str(e->subtype));
+ obj_add_str(entry,"treq", nvmf_treq_str(e->treq));
json_object_add_value_uint(entry, "portid",
le16_to_cpu(e->portid));
- json_object_add_value_string(entry, "trsvcid", e->trsvcid);
- json_object_add_value_string(entry, "subnqn", e->subnqn);
- json_object_add_value_string(entry, "traddr", e->traddr);
- json_object_add_value_string(entry, "eflags",
- nvmf_eflags_str(le16_to_cpu(e->eflags)));
+ obj_add_str(entry, "trsvcid", e->trsvcid);
+ obj_add_str(entry, "subnqn", e->subnqn);
+ obj_add_str(entry, "traddr", e->traddr);
+ obj_add_str(entry, "eflags", nvmf_eflags_str(le16_to_cpu(e->eflags)));
switch (e->trtype) {
case NVMF_TRTYPE_RDMA:
- json_object_add_value_string(entry, "rdma_prtype",
- nvmf_prtype_str(e->tsas.rdma.prtype));
- json_object_add_value_string(entry, "rdma_qptype",
- nvmf_qptype_str(e->tsas.rdma.qptype));
- json_object_add_value_string(entry, "rdma_cms",
- nvmf_cms_str(e->tsas.rdma.cms));
+ obj_add_str(entry, "rdma_prtype", nvmf_prtype_str(e->tsas.rdma.prtype));
+ obj_add_str(entry, "rdma_qptype", nvmf_qptype_str(e->tsas.rdma.qptype));
+ obj_add_str(entry, "rdma_cms", nvmf_cms_str(e->tsas.rdma.cms));
json_object_add_value_uint(entry, "rdma_pkey",
le16_to_cpu(e->tsas.rdma.pkey));
break;
case NVMF_TRTYPE_TCP:
- json_object_add_value_string(entry, "sectype",
- nvmf_sectype_str(e->tsas.tcp.sectype));
+ obj_add_str(entry, "sectype", nvmf_sectype_str(e->tsas.tcp.sectype));
break;
default:
break;
{
struct json_object *root = json_create_object();
- json_object_add_value_string(root, "device", nvme_ctrl_get_name(c));
+ root_add_str("device", nvme_ctrl_get_name(c));
json_print(root);
}
int type;
if (status < 0) {
- json_object_add_value_string(root, error_str, nvme_strerror(errno));
+ root_add_str(error_str, nvme_strerror(errno));
return json_output_object(root);
}
switch (type) {
case NVME_STATUS_TYPE_NVME:
- json_object_add_value_string(root, error_str, nvme_status_to_string(val, false));
- json_object_add_value_string(root, "type", "nvme");
+ root_add_str(error_str, nvme_status_to_string(val, false));
+ root_add_str("type", "nvme");
break;
case NVME_STATUS_TYPE_MI:
- json_object_add_value_string(root, error_str, nvme_mi_status_to_string(val));
- json_object_add_value_string(root, "type", "nvme-mi");
+ root_add_str(error_str, nvme_mi_status_to_string(val));
+ root_add_str("type", "nvme-mi");
break;
default:
- json_object_add_value_string(root, "type", "unknown");
+ root_add_str("type", "unknown");
break;
}
value = NULL;
if (value)
- json_object_add_value_string(root, key, value);
+ root_add_str(key, value);
else
- json_object_add_value_string(root, key, "Could not allocate string");
+ root_add_str(key, "Could not allocate string");
free(value);
error = NULL;
if (error)
- json_object_add_value_string(root, error_str, error);
+ root_add_str(error_str, error);
else
- json_object_add_value_string(root, error_str, "Could not allocate string");
+ root_add_str(error_str, "Could not allocate string");
json_output_object(root);