summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2019-03-26 10:19:03 -0700
committerLee Duncan <lduncan@suse.com>2019-03-26 10:19:03 -0700
commit7ee90fae96214c1d648a0edbb0c050235cd77517 (patch)
tree679e554290f302339950a2f532f49b2d15f2ff4c
parentd1f75b6d912ab03c0897a8cfdc378d3bdc563f13 (diff)
downloadopen-iscsi-7ee90fae96214c1d648a0edbb0c050235cd77517.tar.gz
Fix output of node printing for multiple paths.
The output of "iscsiadmm -m node -P*" changed when libopeniscsiusr was merged, and an earlier attempt was made to clean it up (see commit 59806c99fb3f). This commit fixes output so that. Before this fix, if one had multiple paths to the same target, the output of "iscsiadm -m node -P1" would be: > Target: iqn.2008-04.net.gonzoleeman:01:disk1 > Portal: 10.0.0.1:3260,1 > Iface Name: default > Target: iqn.2008-04.net.gonzoleeman:01:disk1 > Portal: 10.0.1.1:3260,2 > Iface Name: default But this commit fixes the output to be that of iscsiadm before the libopeniscsiusr merge, i.e.: > Target: iqn.2008-04.net.gonzoleeman:01:disk1 > Portal: 10.0.0.1:3260,1 > Iface Name: default > Portal: 10.0.1.1:3260,2 > Iface Name: default
-rw-r--r--usr/iscsiadm.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 22d62db..a8f6f4a 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -689,13 +689,12 @@ static void print_node_flat(struct iscsi_node *node)
iscsi_node_target_name_get(node));
}
-// The 'iface_mode' argument is only used for command
-// `iscsiadm -m iface -P 1`
static void print_nodes_tree(struct iscsi_node **nodes, uint32_t node_count,
enum _print_node_tree_mode print_mode)
{
unsigned int i;
struct iscsi_node *cur_node = NULL;
+ struct iscsi_node *prev_node = NULL;
const char *prefix = NULL;
if (print_mode == _PRINT_MODE_IFACE)
@@ -707,14 +706,24 @@ 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];
- printf("%sTarget: %s\n", prefix,
- iscsi_node_target_name_get(cur_node));
+ /*
+ * Print the target line if this is our first pass, or
+ * if if it does not match the prevous target. Always print
+ * the Portal line. The original code seemed to want to
+ * suppres duplicates here, as well, but it evidently
+ * didn't work that way, so let's not regress output format
+ */
+ if (!prev_node || strcmp(iscsi_node_target_name_get(prev_node),
+ iscsi_node_target_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));
+ prev_node = cur_node;
}
}