[stgt] [PATCH] fix display of TYPE_PT device type

Alexander Nezhinsky alexandern at Voltaire.COM
Fri Jul 30 17:28:33 CEST 2010


New device type TYPE_PT (passthrough) was not added to disk_type_names
array. Thus "Type:" in --op show was (null).

This patch adds the new device type, displays Unknown instead of (null)
when printing device types.

Adding TYPE_PT to disk_type_names alone does not help detecting it
there, because the type of device_type field in struct lu_phy_attr
(accessed as lu->attrs.device_type when printing) is char,
while the value of TYPE_PT is 0xff. Comparison fails as 0xff is
interpreted as -1. Thus this patch changes the type of device_type
field to unsigned char.

Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
---
 usr/target.c |    5 ++++-
 usr/tgtd.h   |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/usr/target.c b/usr/target.c
index bb5b0c8..53a27f5 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -1663,7 +1663,8 @@ static struct {
 	{TYPE_ENCLOSURE, "enclosure"},
 	{TYPE_RBC, "rbc"},
 	{TYPE_OSD, "osd"},
-	{TYPE_NO_LUN, "No LUN"}
+	{TYPE_NO_LUN, "No LUN"},
+	{TYPE_PT, "passthrough"}
 };
 
 static char *print_type(int type)
@@ -1677,6 +1678,8 @@ static char *print_type(int type)
 			break;
 		}
 	}
+	if (name == NULL)
+		name = "Unknown";
 	return name;
 }
 
diff --git a/usr/tgtd.h b/usr/tgtd.h
index e47b554..09c722d 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -60,7 +60,7 @@ struct lu_phy_attr {
 
 	uint16_t version_desc[VERSION_DESCRIPTOR_LEN];
 
-	char device_type;	/* Peripheral device type */
+	unsigned char device_type; /* Peripheral device type */
 	char qualifier;		/* Peripheral Qualifier */
 	char removable;		/* Removable media */
 	char online;		/* Logical Unit online */
--
1.6.5
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list