Blob Blame Raw
From 181af9ac81bccbf8e63a755d48babb2e65de1d4e Mon Sep 17 00:00:00 2001
From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Date: Tue, 9 Jul 2013 08:17:15 -0400
Subject: [PATCH] iscsi tools: Print additional session info for flashnode
 session

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Signed-off-by: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com>
---
 usr/session_info.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/usr/session_info.c b/usr/session_info.c
index de156c6..2f48e65 100644
--- a/usr/session_info.c
+++ b/usr/session_info.c
@@ -64,20 +64,32 @@ void session_info_free_list(struct list_head *list)
 	}
 }
 
+static char *get_iscsi_node_type(struct session_info *info)
+{
+	int pid = iscsi_sysfs_session_user_created(info->sid);
+
+	if (!pid)
+		return "flash";
+	else
+		return "non-flash";
+}
+
 static int session_info_print_flat(void *data, struct session_info *info)
 {
 	struct iscsi_transport *t = iscsi_sysfs_get_transport_by_sid(info->sid);
 
 	if (strchr(info->persistent_address, '.'))
-		printf("%s: [%d] %s:%d,%d %s\n",
+		printf("%s: [%d] %s:%d,%d %s (%s)\n",
 			t ? t->name : UNKNOWN_VALUE,
 			info->sid, info->persistent_address,
-			info->persistent_port, info->tpgt, info->targetname);
+			info->persistent_port, info->tpgt, info->targetname,
+			get_iscsi_node_type(info));
 	else
-		printf("%s: [%d] [%s]:%d,%d %s\n",
+		printf("%s: [%d] [%s]:%d,%d %s (%s)\n",
 			t ? t->name : UNKNOWN_VALUE,
 			info->sid, info->persistent_address,
-			info->persistent_port, info->tpgt, info->targetname);
+			info->persistent_port, info->tpgt, info->targetname,
+			get_iscsi_node_type(info));
 	return 0;
 }
 
@@ -230,7 +242,8 @@ void session_info_print_tree(struct list_head *list, char *prefix,
 
 	list_for_each_entry(curr, list, list) {
 		if (!prev || strcmp(prev->targetname, curr->targetname)) {
-			printf("%sTarget: %s\n", prefix, curr->targetname);
+			printf("%sTarget: %s (%s)\n", prefix, curr->targetname,
+				get_iscsi_node_type(curr));
 			prev = NULL;
 		}
 
@@ -278,6 +291,7 @@ void session_info_print_tree(struct list_head *list, char *prefix,
 			printf("%s\t\tSID: %d\n", prefix, curr->sid);
 			print_iscsi_state(curr->sid, prefix);
 		}
+
 		if (flags & SESSION_INFO_ISCSI_TIM) {
 			printf("%s\t\t*********\n", prefix);
 			printf("%s\t\tTimeouts:\n", prefix);
-- 
1.8.3.1