Skip to contentSkip to conversation

add scsi_level and revision support to lsscsci 0.03

PATCH New Patrick Mansfield 1 participant 1 message Jan 8, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add scsi_level and revision support to lsscsci 0.03

Doug -

This patch adds support for use of scsi_level and the output of revision to lsscsi 0.03. It should work even without scsi_level in the scsi sysfs attributes.

lsscsi -c now gives the exact same output as catting /proc/scsi/scsi.

lsscsi.c renamed from lsscsi.c-orig +8 -2
@@ -221,7 +221,7 @@
 	int hcil_arr[4];
 	char buff[NAME_LEN_MAX];
 	char value[NAME_LEN_MAX];
-	int type, k;
+	int type, scsi_level, k;
 
 	strcpy(buff, dir_name);
 	strcat(buff, "/");
@@ -254,7 +254,13 @@
 		printf("  Type:   %-33s", "???");
 	} else
 		printf("  Type:   %-33s", scsi_device_types[type]);
-	printf("ANSI SCSI revision: ??\n");
+	if (! get_value(buff, "scsi_level", value, NAME_LEN_MAX)) {
+		printf("ANSI SCSI revision: ?\n");
+	} else if (1 != sscanf(value, "%d", &scsi_level)) {
+		printf("ANSI SCSI revision: ??\n");
+	} else
+		printf("ANSI SCSI revision: %02x\n", (scsi_level - 1) ?
+		                            scsi_level - 1 : 1);
 	if (out_mask & MASK_NAME) {
 		if (get_value(buff, "name", value, NAME_LEN_MAX))
 			printf("  name: %s\n", value);

-- Patrick Mansfield