[--disable-sqflow | -d]
[--hdr-digest | -g]
[--data-digest | -G]
+ [--output-format=<fmt> | -o <fmt>]
DESCRIPTION
-----------
--data-digest::
Generates/verifies data digest (TCP).
+-o <format>::
+--output-format=<format>::
+ Set the reporting format to 'normal' or 'json'. Only one output format can
+ be used at a time. When this option is specified, the device associated with
+ the connection will be printed. Nothing is printed otherwise.
+
EXAMPLES
--------
* Connect to a subsystem named nqn.2014-08.com.example:nvme:nvm-subsystem-sn-d78432
close(fd);
}
+static void print_connect_msg(int instance)
+{
+ printf("device: nvme%d\n", instance);
+}
+
+static void json_connect_msg(int instance)
+{
+ struct json_object *root;
+ char *dev_name = NULL;
+
+ if (asprintf(&dev_name, "nvme%d", instance) < 0)
+ return;
+
+ root = json_create_object();
+ json_object_add_value_string(root, "device", dev_name);
+
+ json_print_object(root, NULL);
+ printf("\n");
+ json_free_object(root);
+ free(dev_name);
+}
+
static char *hostnqn_read_file(void)
{
FILE *f;
{
char argstr[BUF_SIZE];
int instance, ret;
+ enum nvme_print_flags flags = -1;
OPT_ARGS(opts) = {
OPT_LIST("transport", 't', &fabrics_cfg.transport, "transport type"),
OPT_FLAG("disable-sqflow", 'd', &fabrics_cfg.disable_sqflow, "disable controller sq flow control (default false)"),
OPT_FLAG("hdr-digest", 'g', &fabrics_cfg.hdr_digest, "enable transport protocol header digest (TCP transport)"),
OPT_FLAG("data-digest", 'G', &fabrics_cfg.data_digest, "enable transport protocol data digest (TCP transport)"),
+ OPT_FMT("output-format", 'o', &fabrics_cfg.output_format, "Output format: normal|json"),
OPT_END()
};
+ fabrics_cfg.output_format = "";
fabrics_cfg.tos = -1;
ret = argconfig_parse(argc, argv, desc, opts);
if (ret)
goto out;
+ if (!strcmp(fabrics_cfg.output_format, ""))
+ flags = -1;
+ else if (!strcmp(fabrics_cfg.output_format, "normal"))
+ flags = NORMAL;
+ else if (!strcmp(fabrics_cfg.output_format, "json"))
+ flags = JSON;
+ else {
+ ret = -EINVAL;
+ goto out;
+ }
+
if (traddr_is_hostname(&fabrics_cfg)) {
ret = hostname2traddr(&fabrics_cfg);
if (ret)
instance = add_ctrl(argstr);
if (instance < 0)
ret = instance;
+ else {
+ if (flags == NORMAL)
+ print_connect_msg(instance);
+ else if (flags == JSON)
+ json_connect_msg(instance);
+ }
out:
return nvme_status_to_errno(ret, true);