static void *mmap_registers(nvme_root_t r, struct nvme_dev *dev);
-static void *__nvme_alloc(size_t len, bool *huge) {
+static void *__nvme_alloc(size_t len, bool *huge)
+{
void *p;
if (!posix_memalign(&p, getpagesize(), len)) {
if (huge) {
if (p)
free_hugepage_region(p);
- }
- else
+ } else {
free(p);
+ }
}
void *nvme_alloc(size_t len, bool *huge)
};
OPT_ARGS(opts) = {
- OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable_log),
- OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_log),
- OPT_INT("csi", 'c', &cfg.csi, csi),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_log),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_log),
+ OPT_INT("csi", 'c', &cfg.csi, csi),
OPT_END()
};
};
OPT_ARGS(opts) = {
- OPT_FLAG("rae", 'r', &cfg.rae, rae),
- OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable_log),
- OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_log),
+ OPT_FLAG("rae", 'r', &cfg.rae, rae),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_log),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_log),
OPT_END()
};
};
OPT_ARGS(opts) = {
- OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable_log),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_log),
OPT_END()
};
};
OPT_ARGS(opts) = {
- OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable_log),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_log),
OPT_END()
};
i = flbas & NVME_NS_FLBAS_LOWER_MASK;
lbas = (1 << ns.lbaf[i].ds) + ns.lbaf[i].ms;
- if (suffix_si_parse(val, &endptr, (uint64_t*)num)) {
+ if (suffix_si_parse(val, &endptr, (uint64_t *)num)) {
nvme_show_error("Expected long suffixed integer argument for '%s-si' but got '%s'!",
opt, val);
return -errno;
if (err)
goto close_dev;
- if (cfg.csi != NVME_CSI_ZNS && (cfg.azr || cfg.rar || cfg.ror|| cfg.rnumzrwa)) {
+ if (cfg.csi != NVME_CSI_ZNS && (cfg.azr || cfg.rar || cfg.ror || cfg.rnumzrwa)) {
nvme_show_error("Invaild ZNS argument is given (CSI:%#x)", cfg.csi);
err = -EINVAL;
goto close_dev;
return err;
}
-static int id_domain(int argc, char **argv, struct command *cmd, struct plugin *plugin) {
+static int id_domain(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
const char *desc = "Send an Identify Domain List command to the "\
"given device, returns properties of the specified domain "\
"in either normal|json|binary format.";
" which provides the necessary log to determine the state of the device";
const char *namespace_id = "Indicate the namespace in which the device self-test"\
" has to be carried out";
- const char * self_test_code = "This field specifies the action taken by the device self-test command :\n"\
+ const char *self_test_code = "This field specifies the action taken by the device self-test command :\n"\
"0h Show current state of device self-test operation\n"\
"1h Start a short device self-test operation\n"\
"2h Start a extended device self-test operation\n"\
};
OPT_ARGS(opts) = {
- OPT_BYTE("feature-id", 'f', &cfg.feature_id, feature_id),
- OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
- OPT_BYTE("sel", 's', &cfg.sel, sel),
- OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),
- OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
- OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),
- OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index_specify),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_BYTE("feature-id", 'f', &cfg.feature_id, feature_id),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
+ OPT_BYTE("sel", 's', &cfg.sel, sel),
+ OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),
+ OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index_specify),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
OPT_END()
};
cfg.xfer = 4096;
else
cfg.xfer = ctrl.fwug * 4096;
- }
- else if (cfg.xfer % 4096)
+ } else if (cfg.xfer % 4096)
cfg.xfer = 4096;
if (cfg.xfer < HUGE_MIN)
};
OPT_ARGS(opts) = {
- OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
OPT_END()
};
};
OPT_ARGS(opts) = {
- OPT_UINT("offset", 'o', &cfg.offset, offset),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_UINT("offset", 'o', &cfg.offset, offset),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
OPT_END()
};
goto ret;
}
- if (cfg.lbaf != 0xff && cfg.bs !=0) {
+ if (cfg.lbaf != 0xff && cfg.bs != 0) {
nvme_show_error(
"Invalid specification of both LBAF and Block Size, please specify only one");
err = -EINVAL;
};
OPT_ARGS(opts) = {
- OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
- OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),
- OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),
- OPT_BYTE("target-dir", 'T', &cfg.ttype, ttype),
- OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),
- OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),
- OPT_SHRT("endir", 'e', &cfg.endir, endir),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable_directive),
- OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),
- OPT_FILE("input-file", 'i', &cfg.file, input),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
+ OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),
+ OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),
+ OPT_BYTE("target-dir", 'T', &cfg.ttype, ttype),
+ OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),
+ OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),
+ OPT_SHRT("endir", 'e', &cfg.endir, endir),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_directive),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),
+ OPT_FILE("input-file", 'i', &cfg.file, input),
OPT_END()
};
int err = 0;
int dfd, mfd;
int flags = opcode & 1 ? O_RDONLY : O_WRONLY | O_CREAT;
- int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH;
+ int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
__u16 control = 0, nblocks = 0;
__u32 dsmgmt = 0;
int logical_block_size = 0;
};
OPT_ARGS(opts) = {
- OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
- OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),
- OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),
- OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),
- OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),
- OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),
- OPT_SHRT("req-resource", 'r', &cfg.nsr, nsr),
- OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable_directive),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
+ OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),
+ OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),
+ OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),
+ OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),
+ OPT_SHRT("req-resource", 'r', &cfg.nsr, nsr),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_directive),
OPT_END()
};
const char *prefill = "prefill buffers with known byte-value, default 0";
int flags;
- int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH;
+ int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
void *data = NULL, *mdata = NULL;
int err = 0, dfd, mfd;
struct nvme_dev *dev;
int secret_len = 0, i;
unsigned int c;
- for (i = 0; i < strlen(cfg.secret); i+=2) {
+ for (i = 0; i < strlen(cfg.secret); i += 2) {
if (sscanf(&cfg.secret[i], "%02x", &c) != 1) {
nvme_show_error("Invalid secret '%s'", cfg.secret);
return -EINVAL;
int secret_len = 0, i;
unsigned int c;
- for (i = 0; i < strlen(cfg.secret); i+=2) {
+ for (i = 0; i < strlen(cfg.secret); i += 2) {
if (sscanf(&cfg.secret[i], "%02x", &c) != 1) {
nvme_show_error("Invalid secret '%s'", cfg.secret);
return -EINVAL;
const char *nmd1 = "nvme management dword 1 value";
const char *input = "data input or output file";
- int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH;
+ int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
void *data = NULL;
int err = 0;
bool send = admin_opcode == nvme_admin_nvme_mi_send ? true : false;