.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw},
- {NULL}
+
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, NULL, 0);
+ fd = parse_and_open(argc, argv, desc, opts, NULL, 0);
if (fd < 0) {
err = fd;
goto ret;
.data_area = 3,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-file", 'o', "FILE", CFG_STRING, &cfg.file_name, required_argument, fname},
- {"host-generate", 'g', "NUM", CFG_POSITIVE, &cfg.host_gen, required_argument, hgen},
- {"controller-init", 'c', "", CFG_NONE, &cfg.ctrl_init, no_argument, cgen},
- {"data-area", 'd', "NUM", CFG_POSITIVE, &cfg.data_area, required_argument, dgen},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FILE("output-file", 'o', &cfg.file_name, fname),
+ OPT_UINT("host-generate", 'g', &cfg.host_gen, hgen),
+ OPT_FLAG("controller-init", 'c', &cfg.ctrl_init, cgen),
+ OPT_UINT("data-area", 'd', &cfg.data_area, dgen),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.group_id = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format},
- {"group-id", 'g', "NUM", CFG_SHORT, &cfg.group_id, required_argument, group_id},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_UINT("group-id", 'g', &cfg.group_id, group_id),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
static int get_effects_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
const char *desc = "Retrieve command effects log page and print the table.";
- const char *raw_binary = "show infos in binary format";
- const char *human_readable = "show infos in readable format";
+ const char *raw = "show log in binary format";
+ const char *human_readable = "show log in readable format";
struct nvme_effects_log_page effects;
int err, fd;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format},
- {"human-readable",'H', "", CFG_NONE, &cfg.human_readable,no_argument, human_readable},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
"error log entries from a given device "\
"in either decoded format (default) or binary.";
const char *log_entries = "number of entries to retrieve";
- const char *raw_binary = "dump in binary format";
+ const char *raw = "dump in binary format";
struct nvme_id_ctrl ctrl;
int err, fmt, fd;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries, required_argument, log_entries},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("log-entries", 'e', &cfg.log_entries, log_entries),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
{
const char *desc = "Retrieve the firmware log for the "\
"specified device in either decoded format (default) or binary.";
- const char *raw_binary = "use binary output";
+ const char *raw = "use binary output";
int err, fmt, fd;
struct nvme_firmware_log_page fw_log;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
const char *lsp = "log specific field";
const char *lpo = "log page offset specifies the location within a log page from where to start returning data";
const char *rae = "retain an asynchronous event";
- const char *raw_binary = "output in raw format";
+ const char *raw = "output in raw format";
const char *uuid_index = "UUID index";
int err, fd;
.uuid_index = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"log-id", 'i', "NUM", CFG_POSITIVE, &cfg.log_id, required_argument, log_id},
- {"log-len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len, required_argument, log_len},
- {"aen", 'a', "NUM", CFG_POSITIVE, &cfg.aen, required_argument, aen},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"lpo", 'o', "NUM", CFG_LONG, &cfg.lpo, required_argument, lpo},
- {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, required_argument, lsp},
- {"rae", 'r', "", CFG_NONE, &cfg.rae, no_argument, rae},
- {"uuid-index", 'U', "NUM", CFG_BYTE, &cfg.uuid_index, required_argument, uuid_index},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("log-id", 'i', &cfg.log_id, log_id),
+ OPT_UINT("log-len", 'l', &cfg.log_len, log_len),
+ OPT_UINT("aen", 'a', &cfg.aen, aen),
+ OPT_LONG("lpo", 'o', &cfg.lpo, lpo),
+ OPT_BYTE("lsp", 's', &cfg.lsp, lsp),
+ OPT_FLAG("rae", 'r', &cfg.rae, rae),
+ OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
static int sanitize_log(int argc, char **argv, struct command *command, struct plugin *plugin)
{
const char *desc = "Retrieve sanitize log and show it.";
- const char *raw_binary = "show infos in binary format";
- const char *human_readable = "show infos in readable format";
- int fd;
- int ret;
- int fmt;
+ const char *raw = "show log in binary format";
+ const char *human_readable = "show log in readable format";
+ int fd, ret, fmt;
unsigned int flags = 0;
struct nvme_sanitize_log_page sanitize_log;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format},
- {"human-readable",'H', "", CFG_NONE, &cfg.human_readable,no_argument, human_readable},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
ret = fd;
goto ret;
.cntid = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, required_argument, controller},
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_SHRT("cntid", 'c', &cfg.cntid, controller),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.namespace_id = 1,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"all", 'a', "", CFG_NONE, &cfg.all, no_argument, all},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_FLAG("all", 'a', &cfg.all, all),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
};
struct config cfg = {
- .namespace_id = 0,
- .timeout = NVME_IOCTL_TIMEOUT,
+ .namespace_id = 0,
+ .timeout = NVME_IOCTL_TIMEOUT,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"timeout", 't', "NUM", CFG_POSITIVE, &cfg.timeout, required_argument, timeout},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("timeout", 't', &cfg.timeout, timeout),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.cntlist = "",
.namespace_id = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"controllers", 'c', "LIST", CFG_STRING, &cfg.cntlist, required_argument, cont},
- {NULL}
+
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_LIST("controllers", 'c', &cfg.cntlist, cont),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
};
struct config cfg = {
- .flbas = 0xff,
- .bs = 0x00,
- .timeout = NVME_IOCTL_TIMEOUT,
+ .flbas = 0xff,
+ .bs = 0x00,
+ .timeout = NVME_IOCTL_TIMEOUT,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"nsze", 's', "NUM", CFG_LONG_SUFFIX, &cfg.nsze, required_argument, nsze},
- {"ncap", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.ncap, required_argument, ncap},
- {"flbas", 'f', "NUM", CFG_BYTE, &cfg.flbas, required_argument, flbas},
- {"dps", 'd', "NUM", CFG_BYTE, &cfg.dps, required_argument, dps},
- {"nmic", 'm', "NUM", CFG_BYTE, &cfg.nmic, required_argument, nmic},
- {"block-size", 'b', "NUM", CFG_LONG_SUFFIX, &cfg.bs, required_argument, bs},
- {"timeout", 't', "NUM", CFG_POSITIVE, &cfg.timeout, required_argument, timeout},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_SUFFIX("nsze", 's', &cfg.nsze, nsze),
+ OPT_SUFFIX("ncap", 'c', &cfg.ncap, ncap),
+ OPT_BYTE("flbas", 'f', &cfg.flbas, flbas),
+ OPT_BYTE("dps", 'd', &cfg.dps, dps),
+ OPT_BYTE("nmic", 'm', &cfg.nmic, nmic),
+ OPT_SUFFIX("block-size", 'b', &cfg.bs, bs),
+ OPT_UINT("timeout", 't', &cfg.timeout, timeout),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
int fmt, ret, subcnt = 0;
char *subsysnqn = NULL;
const char *desc = "Retrieve information for subsystems";
+ __u32 namespace_id;
struct config {
- __u32 namespace_id;
char *output_format;
};
struct config cfg = {
- .namespace_id = NVME_NSID_ALL,
.output_format = "normal",
};
- const struct argconfig_commandline_options opts[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format,
- required_argument, "Output Format: normal|json"},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"),
+ OPT_END()
};
ret = argconfig_parse(argc, argv, desc, opts, &cfg, sizeof(cfg));
devicename = basename(argv[optind]);
if (sscanf(devicename, "nvme%dn%d", &id,
- &cfg.namespace_id) != 2) {
+ &namespace_id) != 2) {
fprintf(stderr, "%s is not a NVMe namespace device\n",
argv[optind]);
ret = -EINVAL;
goto free;
}
- slist = get_subsys_list(&subcnt, subsysnqn, cfg.namespace_id);
-
+ slist = get_subsys_list(&subcnt, subsysnqn, namespace_id);
if (fmt == JSON)
json_print_nvme_subsystem_list(slist, subcnt);
else
static int list(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
const char *desc = "Retrieve basic information for all NVMe namespaces";
+ const char *verbose = "Increase output verbosity";
struct nvme_topology t;
int fmt, ret = 0;
.verbose = 0,
};
- const struct argconfig_commandline_options opts[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, "Output Format: normal|json"},
- {"verbose", 'v', "FLAG", CFG_INCREMENT, &cfg.verbose, no_argument, "Increase output verbosity"},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("verbose", 'v', &cfg.verbose, verbose),
+ OPT_END()
};
ret = argconfig_parse(argc, argv, desc, opts, &cfg, sizeof(cfg));
"controller in human-readable or "\
"binary format. May also return vendor-specific "\
"controller attributes in hex-dump if requested.";
- const char *vendor_specific = "dump binary vendor infos";
- const char *raw_binary = "show infos in binary format";
- const char *human_readable = "show infos in readable format";
+ const char *vendor_specific = "dump binary vendor field";
+ const char *raw = "show identify in binary format";
+ const char *human_readable = "show identify in readable format";
int err, fmt, fd;
unsigned int flags = 0;
struct nvme_id_ctrl ctrl;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"vendor-specific", 'v', "", CFG_NONE, &cfg.vendor_specific, no_argument, vendor_specific},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FLAG("vendor-specific", 'v', &cfg.vendor_specific, vendor_specific),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
const char *desc = "Send Namespace Identification Descriptors command to the "\
"given device, returns the namespace identification descriptors "\
"of the specific namespace in either human-readable or binary format.";
- const char *raw_binary = "show infos in binary format";
+ const char *raw = "show descriptors in binary format";
const char *namespace_id = "identifier of desired namespace";
int err, fmt, fd;
void *nsdescs;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
"in either human-readable or binary format. Can also return "\
"binary vendor-specific namespace attributes.";
const char *force = "Return this namespace, even if not attaced (1.2 devices only)";
- const char *vendor_specific = "dump binary vendor infos";
- const char *raw_binary = "show infos in binary format";
- const char *human_readable = "show infos in readable format";
+ const char *vendor_specific = "dump binary vendor fields";
+ const char *raw = "show identify in binary format";
+ const char *human_readable = "show identify in readable format";
const char *namespace_id = "identifier of desired namespace";
struct nvme_id_ns ns;
int err, fmt, fd;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"force", 'f', "", CFG_NONE, &cfg.force, no_argument, force},
- {"vendor-specific", 'v', "", CFG_NONE, &cfg.vendor_specific, no_argument, vendor_specific},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_FLAG("force", 'f', &cfg.force, force),
+ OPT_FLAG("vendor-specific", 'v', &cfg.vendor_specific, vendor_specific),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"nvmset_id", 'i', "NUM", CFG_POSITIVE, &cfg.nvmset_id, required_argument, nvmset_id},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("nvmset_id", 'i', &cfg.nvmset_id, nvmset_id),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
const char *desc = "Send an Identify UUID List command to the "\
"given device, returns list of supported Vendor Specific UUIDs "\
"in either human-readable or binary format.";
- const char *raw_binary = "show infos in binary format";
- const char *human_readable = "show infos in readable format";
+ const char *raw = "show uuid in binary format";
+ const char *human_readable = "show uuid in readable format";
struct nvme_id_uuid_list uuid_list;
int err, fmt, fd;
unsigned int flags = 0;
struct config cfg = {
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0)
return fd;
+
fmt = validate_output_format(cfg.output_format);
if (fmt < 0) {
err = fmt;
goto close_fd;
}
+
if (cfg.raw_binary)
fmt = BINARY;
if (cfg.human_readable)
flags |= HUMAN;
+
err = nvme_identify_uuid(fd, &uuid_list);
if (!err) {
if (fmt == BINARY)
int err = 0, nsid, fd;
const char *desc = "Get namespce ID of a the block device.";
- const struct argconfig_commandline_options command_line_options[] = {
- {NULL},
+ OPT_ARGS(opts) = {
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, NULL, 0);
+ fd = parse_and_open(argc, argv, desc, opts, NULL, 0);
if (fd < 0) {
err = fd;
goto ret;
.cdw11 = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"cntlid", 'c', "NUM", CFG_POSITIVE, &cfg.cntlid, required_argument, cntlid},
- {"rt", 'r', "NUM", CFG_POSITIVE, &cfg.rt, required_argument, rt},
- {"act", 'a', "NUM", CFG_POSITIVE, &cfg.act, required_argument, act},
- {"nr", 'n', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, nr},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("cntlid", 'c', &cfg.cntlid, cntlid),
+ OPT_UINT("rt", 'r', &cfg.rt, rt),
+ OPT_UINT("act", 'a', &cfg.act, act),
+ OPT_UINT("nr", 'n', &cfg.cdw11, nr),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.num_entries = ARRAY_SIZE(sc_list->sc_entry),
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, required_argument, controller},
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"num-entries", 'e', "NUM", CFG_POSITIVE, &cfg.num_entries, required_argument, num_entries},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_SHRT("cntid", 'c', &cfg.cntid, controller),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("num-entries", 'e', &cfg.num_entries, num_entries),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.cdw10 = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"self-test-code", 's', "NUM", CFG_POSITIVE, &cfg.cdw10, required_argument, self_test_code},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("self-test-code", 's', &cfg.cdw10, self_test_code),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
"saveable, it may be modified by set-feature. Default values "\
"are vendor-specific and not changeable. Use set-feature to "\
"change saveable Features.";
- const char *raw_binary = "show infos in binary format";
+ const char *raw = "show feature in binary format";
const char *namespace_id = "identifier of desired namespace";
const char *feature_id = "feature identifier";
const char *sel = "[0-3]: current/default/saved/supported";
const char *data_len = "buffer len if data is returned through host memory buffer";
const char *cdw11 = "dword 11 for interrupt vector config";
- const char *human_readable = "show infos in readable format";
+ const char *human_readable = "show feature in readable format";
int err, fd;
__u32 result;
void *buf = NULL;
.data_len = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"feature-id", 'f', "NUM", CFG_POSITIVE, &cfg.feature_id, required_argument, feature_id},
- {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, required_argument, sel},
- {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, cdw11},
- {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id),
+ OPT_BYTE("sel", 's', &cfg.sel, sel),
+ OPT_UINT("data-len", 'l', &cfg.data_len, data_len),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),
+ OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.offset = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, required_argument, fw},
- {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, required_argument, xfer},
- {"offset", 'o', "NUM", CFG_POSITIVE, &cfg.offset, required_argument, offset},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FILE("fw", 'f', &cfg.fw, fw),
+ OPT_UINT("xfer", 'x', &cfg.xfer, xfer),
+ OPT_UINT("offset", 'o', &cfg.offset, offset),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.bpid = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, required_argument, slot},
- {"action", 'a', "NUM", CFG_BYTE, &cfg.action, required_argument, action},
- {"bpid", 'b', "NUM", CFG_BYTE, &cfg.bpid, required_argument, bpid},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_BYTE("slot", 's', &cfg.slot, slot),
+ OPT_BYTE("action", 'a', &cfg.action, action),
+ OPT_BYTE("bpid", 'b', &cfg.bpid, bpid),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
const char *desc = "Resets the NVMe subsystem\n";
int err, fd;
- const struct argconfig_commandline_options command_line_options[] = {
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, NULL, 0);
+ fd = parse_and_open(argc, argv, desc, opts, NULL, 0);
if (fd < 0) {
err = fd;
goto ret;
const char *desc = "Resets the NVMe controller\n";
int err, fd;
- const struct argconfig_commandline_options command_line_options[] = {
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, NULL, 0);
+ fd = parse_and_open(argc, argv, desc, opts, NULL, 0);
if (fd < 0) {
err = fd;
goto ret;
const char *desc = "Rescans the NVMe namespaces\n";
int err, fd;
- const struct argconfig_commandline_options command_line_options[] = {
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, NULL, 0);
+ fd = parse_and_open(argc, argv, desc, opts, NULL, 0);
if (fd < 0) {
err = fd;
goto ret;
.ovrpat = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"no-dealloc", 'd', "", CFG_NONE, &cfg.no_dealloc, no_argument, no_dealloc_desc},
- {"oipbp", 'i', "", CFG_NONE, &cfg.oipbp, no_argument, oipbp_desc},
- {"owpass", 'n', "NUM", CFG_BYTE, &cfg.owpass, required_argument, owpass_desc},
- {"ause", 'u', "", CFG_NONE, &cfg.ause, no_argument, ause_desc},
- {"sanact", 'a', "NUM", CFG_BYTE, &cfg.sanact, required_argument, sanact_desc},
- {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, required_argument, ovrpat_desc},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FLAG("no-dealloc", 'd', &cfg.no_dealloc, no_dealloc_desc),
+ OPT_FLAG("oipbp", 'i', &cfg.oipbp, oipbp_desc),
+ OPT_BYTE("owpass", 'n', &cfg.owpass, owpass_desc),
+ OPT_FLAG("ause", 'u', &cfg.ause, ause_desc),
+ OPT_BYTE("sanact", 'a', &cfg.sanact, sanact_desc),
+ OPT_UINT("ovrpat", 'p', &cfg.ovrpat, ovrpat_desc),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, NULL, 0);
+ fd = parse_and_open(argc, argv, desc, opts, NULL, 0);
if (fd < 0) {
ret = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
"for NVMe over Fabric. Property offset must be one of:\n"
"CAP=0x0, VS=0x8, CC=0x14, CSTS=0x1c, NSSR=0x20";
const char *offset = "offset of the requested property";
- const char *human_readable = "show infos in readable format";
+ const char *human_readable = "show property in readable format";
int fd, err;
uint64_t value;
.human_readable = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"offset", 'o', "NUM", CFG_POSITIVE, &cfg.offset, required_argument, offset},
- {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("offset", 'o', &cfg.offset, offset),
+ OPT_FLAG("human-readable",'H', &cfg.human_readable, human_readable),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.value = -1,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"offset", 'o', "NUM", CFG_POSITIVE, &cfg.offset, required_argument, offset},
- {"value", 'v', "NUM", CFG_POSITIVE, &cfg.value, required_argument, value},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("offset", 'o', &cfg.offset, offset),
+ OPT_UINT("value", 'v', &cfg.value, value),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.bs = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"timeout", 't', "NUM", CFG_POSITIVE, &cfg.timeout, required_argument, timeout},
- {"lbaf", 'l', "NUM", CFG_BYTE, &cfg.lbaf, required_argument, lbaf},
- {"ses", 's', "NUM", CFG_BYTE, &cfg.ses, required_argument, ses},
- {"pi", 'i', "NUM", CFG_BYTE, &cfg.pi, required_argument, pi},
- {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil, required_argument, pil},
- {"ms", 'm', "NUM", CFG_BYTE, &cfg.ms, required_argument, ms},
- {"reset", 'r', "", CFG_NONE, &cfg.reset, no_argument, reset},
- {"force", 'f', "NUM", CFG_NONE, &cfg.force, no_argument, force},
- {"block-size", 'b', "NUM", CFG_LONG_SUFFIX, &cfg.bs, required_argument, bs},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("timeout", 't', &cfg.timeout, timeout),
+ OPT_BYTE("lbaf", 'l', &cfg.lbaf, lbaf),
+ OPT_BYTE("ses", 's', &cfg.ses, ses),
+ OPT_BYTE("pi", 'i', &cfg.pi, pi),
+ OPT_BYTE("pil", 'p', &cfg.pil, pil),
+ OPT_BYTE("ms", 'm', &cfg.ms, ms),
+ OPT_FLAG("reset", 'r', &cfg.reset, reset),
+ OPT_FLAG("force", 'f', &cfg.force, force),
+ OPT_SUFFIX("block-size", 'b', &cfg.bs, bs),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.save = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"feature-id", 'f', "NUM", CFG_POSITIVE, &cfg.feature_id, required_argument, feature_id},
- {"value", 'v', "NUM", CFG_POSITIVE, &cfg.value, required_argument, value},
- {"cdw12", 'c', "NUM", CFG_POSITIVE, &cfg.cdw12, required_argument, cdw12},
- {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len},
- {"data", 'd', "FILE", CFG_STRING, &cfg.file, required_argument, data},
- {"save", 's', "", CFG_NONE, &cfg.save, no_argument, save},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("feature-id", 'f', &cfg.feature_id, feature_id),
+ OPT_UINT("value", 'v', &cfg.value, value),
+ OPT_UINT("cdw12", 'c', &cfg.cdw12, cdw12),
+ OPT_UINT("data-len", 'l', &cfg.data_len, data_len),
+ OPT_FILE("data", 'd', &cfg.file, data),
+ OPT_FLAG("save", 's', &cfg.save, save),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.tl = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"file", 'f', "FILE", CFG_STRING, &cfg.file, required_argument, file},
- {"nssf", 'N', "NUM", CFG_BYTE, &cfg.nssf, required_argument, nssf},
- {"secp", 'p', "NUM", CFG_BYTE, &cfg.secp, required_argument, secp},
- {"spsp", 's', "NUM", CFG_SHORT, &cfg.spsp, required_argument, spsp},
- {"tl", 't', "NUM", CFG_POSITIVE, &cfg.tl, required_argument, tl},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_FILE("file", 'f', &cfg.file, file),
+ OPT_BYTE("nssf", 'N', &cfg.nssf, nssf),
+ OPT_BYTE("secp", 'p', &cfg.secp, secp),
+ OPT_SHRT("spsp", 's', &cfg.spsp, spsp),
+ OPT_UINT("tl", 't', &cfg.tl, tl),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
{
const char *desc = "Set directive parameters of the "\
"specified directive type.";
- const char *raw_binary = "show infos in binary format";
+ const char *raw = "show directive in binary format";
const char *namespace_id = "identifier of desired namespace";
const char *data_len = "buffer len (if) data is returned";
const char *dtype = "directive type";
const char *doper = "directive operation";
const char *endir = "directive enable";
const char *ttype = "target directive type to be enabled/disabled";
- const char *human_readable = "show infos in readable format";
+ const char *human_readable = "show directive in readable format";
int err, fd;
__u32 result;
__u32 dw12 = 0;
.endir = 1,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len},
- {"raw-binary", 'b', "FLAG",CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, required_argument, dtype},
- {"target-dir", 'T', "NUM", CFG_BYTE, &cfg.ttype, required_argument, ttype},
- {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, required_argument, dspec},
- {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, required_argument, doper},
- {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, required_argument, endir},
- {"human-readable", 'H', "FLAG",CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("data-len", 'l', &cfg.data_len, data_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),
+ 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),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.block_count = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block},
- {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),
+ OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.app_tag = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block},
- {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count},
- {"deac", 'd', "", CFG_NONE, &cfg.deac, no_argument, deac},
- {"limited-retry", 'l', "", CFG_NONE, &cfg.limited_retry, no_argument, limited_retry},
- {"force-unit-access", 'f', "", CFG_NONE, &cfg.force_unit_access, no_argument, force},
- {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, required_argument, prinfo},
- {"ref-tag", 'r', "NUM", CFG_POSITIVE, &cfg.ref_tag, required_argument, ref_tag},
- {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.app_tag_mask, required_argument, app_tag_mask},
- {"app-tag", 'a', "NUM", CFG_SHORT, &cfg.app_tag, required_argument, app_tag},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),
+ OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),
+ OPT_FLAG("deac", 'd', &cfg.deac, deac),
+ OPT_FLAG("limited-retry", 'l', &cfg.limited_retry, limited_retry),
+ OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force),
+ OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo),
+ OPT_UINT("ref-tag", 'r', &cfg.ref_tag, ref_tag),
+ OPT_SHRT("app-tag-mask", 'm', &cfg.app_tag_mask, app_tag_mask),
+ OPT_SHRT("app-tag", 'a', &cfg.app_tag, app_tag),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.cdw11 = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"ctx-attrs", 'a', "LIST", CFG_STRING, &cfg.ctx_attrs, required_argument, context_attrs},
- {"blocks", 'b', "LIST", CFG_STRING, &cfg.blocks, required_argument, blocks},
- {"slbs", 's', "LIST", CFG_STRING, &cfg.slbas, required_argument, starting_blocks},
- {"ad", 'd', "", CFG_NONE, &cfg.ad, no_argument, ad},
- {"idw", 'w', "", CFG_NONE, &cfg.idw, no_argument, idw},
- {"idr", 'r', "", CFG_NONE, &cfg.idr, no_argument, idr},
- {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, cdw11},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_LIST("ctx-attrs", 'a', &cfg.ctx_attrs, context_attrs),
+ OPT_LIST("blocks", 'b', &cfg.blocks, blocks),
+ OPT_LIST("slbs", 's', &cfg.slbas, starting_blocks),
+ OPT_FLAG("ad", 'd', &cfg.ad, ad),
+ OPT_FLAG("idw", 'w', &cfg.idw, idw),
+ OPT_FLAG("idr", 'r', &cfg.idr, idr),
+ OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.namespace_id = NVME_NSID_ALL,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.racqa = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"crkey", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.crkey, required_argument, crkey},
- {"prkey", 'p', "NUM", CFG_LONG_SUFFIX, &cfg.prkey, required_argument, prkey},
- {"rtype", 't', "NUM", CFG_BYTE, &cfg.rtype, required_argument, rtype},
- {"racqa", 'a', "NUM", CFG_BYTE, &cfg.racqa, required_argument, racqa},
- {"iekey", 'i', "", CFG_NONE, &cfg.iekey, no_argument, iekey},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_LONG("crkey", 'c', &cfg.crkey, crkey),
+ OPT_LONG("prkey", 'p', &cfg.prkey, prkey),
+ OPT_BYTE("rtype", 't', &cfg.rtype, rtype),
+ OPT_BYTE("racqa", 'a', &cfg.racqa, racqa),
+ OPT_FLAG("iekey", 'i', &cfg.iekey, iekey),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.cptpl = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"crkey", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.crkey, required_argument, crkey},
- {"nrkey", 'k', "NUM", CFG_LONG_SUFFIX, &cfg.nrkey, required_argument, nrkey},
- {"rrega", 'r', "NUM", CFG_BYTE, &cfg.rrega, required_argument, rrega},
- {"cptpl", 'p', "NUM", CFG_BYTE, &cfg.cptpl, required_argument, cptpl},
- {"iekey", 'i', "", CFG_NONE, &cfg.iekey, no_argument, iekey},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_LONG("crkey", 'c', &cfg.crkey, crkey),
+ OPT_LONG("nrkey", 'k', &cfg.nrkey, nrkey),
+ OPT_BYTE("rrega", 'r', &cfg.rrega, rrega),
+ OPT_BYTE("cptpl", 'p', &cfg.cptpl, cptpl),
+ OPT_FLAG("iekey", 'i', &cfg.iekey, iekey),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.iekey = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"crkey", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.crkey, required_argument, crkey},
- {"rtype", 't', "NUM", CFG_BYTE, &cfg.rtype, required_argument, rtype},
- {"rrela", 'a', "NUM", CFG_BYTE, &cfg.rrela, required_argument, rrela},
- {"iekey", 'i', "", CFG_NONE, &cfg.iekey, no_argument, iekey},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_LONG("crkey", 'c', &cfg.crkey, crkey),
+ OPT_BYTE("rtype", 't', &cfg.rtype, rtype),
+ OPT_BYTE("rrela", 'a', &cfg.rrela, rrela),
+ OPT_FLAG("iekey", 'i', &cfg.iekey, iekey),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
const char *namespace_id = "identifier of desired namespace";
const char *numd = "number of dwords to transfer";
const char *cdw11 = "command dword 11 value";
- const char *raw_binary = "dump output in binary format";
+ const char *raw = "dump output in binary format";
int err, fmt, fd, size;
struct nvme_reservation_status *status;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"numd", 'd', "NUM", CFG_POSITIVE, &cfg.numd, required_argument, numd},
- {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, cdw11},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format },
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("numd", 'd', &cfg.numd, numd),
+ OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.app_tag = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block},
- {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count},
- {"data-size", 'z', "NUM", CFG_LONG_SUFFIX, &cfg.data_size, required_argument, data_size},
- {"metadata-size", 'y', "NUM", CFG_LONG_SUFFIX, &cfg.metadata_size, required_argument, metadata_size},
- {"ref-tag", 'r', "NUM", CFG_POSITIVE, &cfg.ref_tag, required_argument, ref_tag},
- {"data", 'd', "FILE", CFG_STRING, &cfg.data, required_argument, data},
- {"metadata", 'M', "FILE", CFG_STRING, &cfg.metadata, required_argument, metadata},
- {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, required_argument, prinfo},
- {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.app_tag_mask, required_argument, app_tag_mask},
- {"app-tag", 'a', "NUM", CFG_SHORT, &cfg.app_tag, required_argument, app_tag},
- {"limited-retry", 'l', "", CFG_NONE, &cfg.limited_retry, no_argument, limited_retry},
- {"force-unit-access", 'f', "", CFG_NONE, &cfg.force_unit_access, no_argument, force},
- {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, required_argument, dtype},
- {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, required_argument, dspec},
- {"dsm", 'D', "NUM", CFG_SHORT, &cfg.dsmgmt, required_argument, dsm},
- {"show-command", 'v', "", CFG_NONE, &cfg.show, no_argument, show},
- {"dry-run", 'w', "", CFG_NONE, &cfg.dry_run, no_argument, dry},
- {"latency", 't', "", CFG_NONE, &cfg.latency, no_argument, latency},
- {NULL}
- };
-
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ OPT_ARGS(opts) = {
+ OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),
+ OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),
+ OPT_SUFFIX("data-size", 'z', &cfg.data_size, data_size),
+ OPT_SUFFIX("metadata-size", 'y', &cfg.metadata_size, metadata_size),
+ OPT_UINT("ref-tag", 'r', &cfg.ref_tag, ref_tag),
+ OPT_FILE("data", 'd', &cfg.data, data),
+ OPT_FILE("metadata", 'M', &cfg.metadata, metadata),
+ OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo),
+ OPT_SHRT("app-tag-mask", 'm', &cfg.app_tag_mask, app_tag_mask),
+ OPT_SHRT("app-tag", 'a', &cfg.app_tag, app_tag),
+ OPT_FLAG("limited-retry", 'l', &cfg.limited_retry, limited_retry),
+ OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force),
+ OPT_BYTE("dir-type", 'T', &cfg.dtype, dtype),
+ OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec),
+ OPT_SHRT("dsm", 'D', &cfg.dsmgmt, dsm),
+ OPT_FLAG("show-command", 'v', &cfg.show, show),
+ OPT_FLAG("dry-run", 'w', &cfg.dry_run, dry),
+ OPT_FLAG("latency", 't', &cfg.latency, latency),
+ OPT_END()
+ };
+
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.force_unit_access = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block},
- {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count},
- {"limited-retry", 'l', "", CFG_NONE, &cfg.limited_retry, no_argument, limited_retry},
- {"force-unit-access", 'f', "", CFG_NONE, &cfg.force_unit_access, no_argument, force},
- {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, required_argument, prinfo},
- {"ref-tag", 'r', "NUM", CFG_POSITIVE, &cfg.ref_tag, required_argument, ref_tag},
- {"app-tag", 'a', "NUM", CFG_SHORT, &cfg.app_tag, required_argument, app_tag},
- {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.app_tag_mask, required_argument, app_tag_mask},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),
+ OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),
+ OPT_FLAG("limited-retry", 'l', &cfg.limited_retry, limited_retry),
+ OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force),
+ OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo),
+ OPT_UINT("ref-tag", 'r', &cfg.ref_tag, ref_tag),
+ OPT_SHRT("app-tag", 'a', &cfg.app_tag, app_tag),
+ OPT_SHRT("app-tag-mask", 'm', &cfg.app_tag_mask, app_tag_mask),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0)
return fd;
const char *secp = "security protocol (cf. SPC-4)";
const char *spsp = "security-protocol-specific (cf. SPC-4)";
const char *al = "allocation length (cf. SPC-4)";
- const char *raw_binary = "dump output in binary format";
+ const char *raw = "dump output in binary format";
const char *namespace_id = "desired namespace";
const char *nssf = "NVMe Security Specific Field";
int err, fd;
.al = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"size", 'x', "NUM", CFG_POSITIVE, &cfg.size, required_argument, size},
- {"nssf", 'N', "NUM", CFG_BYTE, &cfg.nssf, required_argument, nssf},
- {"secp", 'p', "NUM", CFG_BYTE, &cfg.secp, required_argument, secp},
- {"spsp", 's', "NUM", CFG_SHORT, &cfg.spsp, required_argument, spsp},
- {"al", 't', "NUM", CFG_POSITIVE, &cfg.al, required_argument, al},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("size", 'x', &cfg.size, size),
+ OPT_BYTE("nssf", 'N', &cfg.nssf, nssf),
+ OPT_BYTE("secp", 'p', &cfg.secp, secp),
+ OPT_SHRT("spsp", 's', &cfg.spsp, spsp),
+ OPT_UINT("al", 't', &cfg.al, al),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
.output_format = "normal",
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"start-lba", 's', "NUM", CFG_LONG_SUFFIX, &cfg.slba, required_argument, slba},
- {"max-dw", 'm', "NUM", CFG_POSITIVE, &cfg.mndw, required_argument, mndw},
- {"action", 'a', "NUM", CFG_BYTE, &cfg.atype, required_argument, atype},
- {"range-len", 'l', "NUM", CFG_SHORT, &cfg.rl, required_argument, rl},
- {"output-format", 'o', "FMT", CFG_STRING, &cfg.output_format, required_argument, output_format},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_SUFFIX("start-lba", 's', &cfg.slba, slba),
+ OPT_UINT("max-dw", 'm', &cfg.mndw, mndw),
+ OPT_BYTE("action", 'a', &cfg.atype, atype),
+ OPT_SHRT("range-len", 'l', &cfg.rl, rl),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_END()
};
- err = fd = parse_and_open(argc, argv, desc, command_line_options, &cfg,
+ err = fd = parse_and_open(argc, argv, desc, opts, &cfg,
sizeof(cfg));
if (fd < 0)
goto ret;
{
const char *desc = "Read directive parameters of the "\
"specified directive type.";
- const char *raw_binary = "show infos in binary format";
+ const char *raw = "show directive in binary format";
const char *namespace_id = "identifier of desired namespace";
const char *data_len = "buffer len (if) data is returned";
const char *dtype = "directive type";
const char *dspec = "directive specification associated with directive type";
const char *doper = "directive operation";
const char *nsr = "namespace stream requested";
- const char *human_readable = "show infos in readable format";
+ const char *human_readable = "show directive in readable format";
int err, fd;
__u32 result;
__u32 dw12 = 0;
.nsr = 0,
};
- const struct argconfig_commandline_options command_line_options[] = {
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len},
- {"raw-binary", 'b', "FLAG",CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, required_argument, dtype},
- {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, required_argument, dspec},
- {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, required_argument, doper},
- {"req-resource", 'r', "NUM", CFG_SHORT, &cfg.nsr, required_argument, nsr},
- {"human-readable", 'H', "FLAG",CFG_NONE, &cfg.human_readable, no_argument, human_readable},
- {NULL}
+ OPT_ARGS(opts) = {
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("data-len", 'l', &cfg.data_len, data_len),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),
+ OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec),
+ 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),
+ OPT_END()
};
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;
const char *wr = "set dataflow direction to send";
const char *prefill = "prefill buffers with known byte-value, default 0";
- const struct argconfig_commandline_options command_line_options[] = {
- {"opcode", 'o', "NUM", CFG_BYTE, &cfg.opcode, required_argument, opcode},
- {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, required_argument, flags},
- {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, required_argument, prefill},
- {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd, required_argument, rsvd},
- {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
- {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len},
- {"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len, required_argument, metadata_len},
- {"timeout", 't', "NUM", CFG_POSITIVE, &cfg.timeout, required_argument, timeout},
- {"cdw2", '2', "NUM", CFG_POSITIVE, &cfg.cdw2, required_argument, cdw2},
- {"cdw3", '3', "NUM", CFG_POSITIVE, &cfg.cdw3, required_argument, cdw3},
- {"cdw10", '4', "NUM", CFG_POSITIVE, &cfg.cdw10, required_argument, cdw10},
- {"cdw11", '5', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, cdw11},
- {"cdw12", '6', "NUM", CFG_POSITIVE, &cfg.cdw12, required_argument, cdw12},
- {"cdw13", '7', "NUM", CFG_POSITIVE, &cfg.cdw13, required_argument, cdw13},
- {"cdw14", '8', "NUM", CFG_POSITIVE, &cfg.cdw14, required_argument, cdw14},
- {"cdw15", '9', "NUM", CFG_POSITIVE, &cfg.cdw15, required_argument, cdw15},
- {"input-file", 'i', "FILE", CFG_STRING, &cfg.input_file, required_argument, input},
- {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
- {"show-command", 's', "", CFG_NONE, &cfg.show_command, no_argument, show},
- {"dry-run", 'd', "", CFG_NONE, &cfg.dry_run, no_argument, dry},
- {"read", 'r', "", CFG_NONE, &cfg.read, no_argument, re},
- {"write", 'w', "", CFG_NONE, &cfg.write, no_argument, wr},
- {NULL}
- };
-
- fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+ OPT_ARGS(opts) = {
+ OPT_BYTE("opcode", 'o', &cfg.opcode, opcode),
+ OPT_BYTE("flags", 'f', &cfg.flags, flags),
+ OPT_BYTE("prefill", 'p', &cfg.prefill, prefill),
+ OPT_SHRT("rsvd", 'R', &cfg.rsvd, rsvd),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
+ OPT_UINT("data-len", 'l', &cfg.data_len, data_len),
+ OPT_UINT("metadata-len", 'm', &cfg.metadata_len, metadata_len),
+ OPT_UINT("timeout", 't', &cfg.timeout, timeout),
+ OPT_UINT("cdw2", '2', &cfg.cdw2, cdw2),
+ OPT_UINT("cdw3", '3', &cfg.cdw3, cdw3),
+ OPT_UINT("cdw10", '4', &cfg.cdw10, cdw10),
+ OPT_UINT("cdw11", '5', &cfg.cdw11, cdw11),
+ OPT_UINT("cdw12", '6', &cfg.cdw12, cdw12),
+ OPT_UINT("cdw13", '7', &cfg.cdw13, cdw13),
+ OPT_UINT("cdw14", '8', &cfg.cdw14, cdw14),
+ OPT_UINT("cdw15", '9', &cfg.cdw15, cdw15),
+ OPT_FILE("input-file", 'i', &cfg.input_file, input),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_binary),
+ OPT_FLAG("show-command", 's', &cfg.show_command, show),
+ OPT_FLAG("dry-run", 'd', &cfg.dry_run, dry),
+ OPT_FLAG("read", 'r', &cfg.read, re),
+ OPT_FLAG("write", 'w', &cfg.write, wr),
+ OPT_END()
+ };
+
+ fd = parse_and_open(argc, argv, desc, opts, &cfg, sizeof(cfg));
if (fd < 0) {
err = fd;
goto ret;