diff options
author | Lee Duncan <lduncan@suse.com> | 2019-01-23 11:19:06 -0800 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2019-01-23 11:19:06 -0800 |
commit | 59806c99fb3f86277a0d596c6f4c9a58446edc91 (patch) | |
tree | 1f704f283c066567c45d1602dc13a37af1034a7e | |
parent | 364d757606271ff34e08e11a223b252cf40db7a8 (diff) | |
download | open-iscsi-59806c99fb3f86277a0d596c6f4c9a58446edc91.tar.gz |
Fix output for iscsiadm node/iface print level P1
The output from 'iscsiadm -m node -P1' and 'iscsiadm -m iface -P1'
has regressed with the introduction of libopeniscsiusr.
The pre-lib output for 'iscsiadm -m node -P1' before was:
>Target: <TARGET-IQN>
> Portal: <IP-ADDRESS>:<PORT>,1
> Iface Name: default
repeated for each Node in the node datbase, and the output
of 'iscsiadm -m iface -P1' before the change was:
>Iface: default
> Target: <TARGET-IQN>
> Portal: <IP-ADDRESS>:<PORT>,1
repeated once for each Node in the database that uses the
'default' interface (i.e. usually all nodes).
In both of these cases, the output contained details for each
and every node in the database. But this evidently wasn't the
intention if one looks at the code. The code appears to try
to only print the details for each 'Target' if and only if
those details are different than the previous line. In other
words, the code looks like it wants to suppress the 'Portal'
and 'Iface Name' lines if they are the same as the previously-
listed target. This explains why libopeniscsiusr implemented
the output of iscsiadm to suppress this info on all but the
first target, assuming the Portal and IfaceName were the
same.
The fix is to simplify print_nodes_tree() to print details
for every Node, since that is how the output worked
before the libopeniscsiusr update.
-rw-r--r-- | usr/iscsiadm.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c index 25c6cdc..7cb4b97 100644 --- a/usr/iscsiadm.c +++ b/usr/iscsiadm.c @@ -694,9 +694,8 @@ static void print_node_flat(struct iscsi_node *node) static void print_nodes_tree(struct iscsi_node **nodes, uint32_t node_count, enum _print_node_tree_mode print_mode) { - uint32_t i = 0; + unsigned int i; struct iscsi_node *cur_node = NULL; - struct iscsi_node *pre_node = NULL; const char *prefix = NULL; if (print_mode == _PRINT_MODE_IFACE) @@ -708,27 +707,14 @@ static void print_nodes_tree(struct iscsi_node **nodes, uint32_t node_count, // is no need to create hash table for this. for (i = 0; i < node_count; ++i) { cur_node = nodes[i]; - if ( i != 0) - pre_node = nodes[i - 1]; - if ((pre_node == NULL) || - (strcmp(iscsi_node_target_name_get(cur_node), - iscsi_node_target_name_get(pre_node)) != 0)) - printf("%sTarget: %s\n", prefix, - iscsi_node_target_name_get(cur_node)); - if ((pre_node == NULL) || - (strcmp(iscsi_node_conn_address_get(cur_node), - iscsi_node_conn_address_get(pre_node)) != 0) || - (iscsi_node_conn_port_get(cur_node) != - iscsi_node_conn_port_get(pre_node))) - printf("%s\tPortal: %s,%d\n", prefix, - iscsi_node_portal_get(cur_node), - iscsi_node_tpgt_get(cur_node)); - if ((pre_node == NULL) || - (strcmp(iscsi_node_iface_name_get(cur_node), - iscsi_node_iface_name_get(pre_node)) != 0)) - if (print_mode == _PRINT_MODE_NODE) - printf("\t\tIface Name: %s\n", - iscsi_node_iface_name_get(cur_node)); + printf("%sTarget: %s\n", prefix, + iscsi_node_target_name_get(cur_node)); + printf("%s\tPortal: %s,%d\n", prefix, + iscsi_node_portal_get(cur_node), + iscsi_node_tpgt_get(cur_node)); + if (print_mode == _PRINT_MODE_NODE) + printf("\t\tIface Name: %s\n", + iscsi_node_iface_name_get(cur_node)); } } |