summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Duncan <leeman.duncan@gmail.com>2019-03-26 10:25:16 -0700
committerGitHub <noreply@github.com>2019-03-26 10:25:16 -0700
commit0cf0a05ae0ff67d9b68a69b68df89f42258c3c53 (patch)
tree679e554290f302339950a2f532f49b2d15f2ff4c
parentd1f75b6d912ab03c0897a8cfdc378d3bdc563f13 (diff)
parent7ee90fae96214c1d648a0edbb0c050235cd77517 (diff)
downloadopen-iscsi-0cf0a05ae0ff67d9b68a69b68df89f42258c3c53.tar.gz
Merge pull request #162 from gonzoleeman/fix-node-print-v2
Fix output of node printing for multiple paths.
-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;
}
}