Skip to content
Closed
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
29 changes: 26 additions & 3 deletions libnvme/src/nvme/cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string.h>
#include <errno.h>
#include <endian.h>
#include <stdlib.h>

enum nvme_cmd_dword_fields {
NVME_DEVICE_SELF_TEST_CDW10_STC_SHIFT = 0,
Expand Down Expand Up @@ -6569,13 +6570,35 @@ nvme_get_log_media_unit_stat(struct nvme_transport_handle *hdl,
*/
static inline int
nvme_get_log_support_cap_config_list(struct nvme_transport_handle *hdl,
__u16 domid, struct nvme_supported_cap_config_list_log *cap)
__u16 domid, struct nvme_supported_cap_config_list_log **cap)
{
struct nvme_supported_cap_config_list_log hdr, *log;
struct nvme_passthru_cmd cmd;
size_t size;
int err;

nvme_init_get_log_support_cap_config_list(&cmd, domid, &hdr);

err = nvme_get_log(hdl, &cmd, false, sizeof(hdr));
if (err)
return err;

nvme_init_get_log_support_cap_config_list(&cmd, domid, cap);
size = sizeof(hdr) +
sizeof(struct nvme_capacity_config_desc) * hdr.sccn;
log = (struct nvme_supported_cap_config_list_log *)malloc(size);
if (!log)
return -ENOMEM;

return nvme_get_log(hdl, &cmd, false, sizeof(*cap));
nvme_init_get_log_support_cap_config_list(&cmd, domid, log);

err = nvme_get_log(hdl, &cmd, false, size);
if (err) {
free(log);
return err;
}

*cap = log;
return 0;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,11 +2110,7 @@ static int get_supp_cap_config_log(int argc, char **argv, struct command *acmd,
if (cfg.raw_binary)
flags = BINARY;

cap_log = nvme_alloc(sizeof(*cap_log));
if (!cap_log)
return -ENOMEM;

err = nvme_get_log_support_cap_config_list(hdl, cfg.domainid, cap_log);
err = nvme_get_log_support_cap_config_list(hdl, cfg.domainid, &cap_log);
if (err) {
nvme_show_err(
"supported capacity configuration list log", err);
Expand Down