[PATCH] Use same serial num in getconfig:unitserialnum as inquiry does

Ronnie Sahlberg ronniesahlberg
Tue May 6 22:18:55 CEST 2008


The feature GetConfiguration/Lun_Serial_Number is used to pull
the unit serial number from a device.
Use the same data that inq 0x80 uses to report the serial number
so that both methods (getconf and inq) report the same serial number
for the device.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
---
 usr/mmc.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/usr/mmc.c b/usr/mmc.c
index 074b9be..aaf26e9 100644
--- a/usr/mmc.c
+++ b/usr/mmc.c
@@ -833,6 +833,9 @@ static char *feature_dvd_plus_r(struct scsi_cmd
*cmd, char *data,
 static char *feature_lun_serial_no(struct scsi_cmd *cmd, char *data,
 				   int only_current)
 {
+	struct lu_phy_attr *attrs;
+	struct vpd *vpd_pg;
+
 	/* feature code */
 	*data++ = 0x01;
 	*data++ = 0x08;
@@ -843,15 +846,13 @@ static char *feature_lun_serial_no(struct
scsi_cmd *cmd, char *data,
 	/* additional length */
 	*data++ = 8;

-	/* XXX */
-	*data++ = 'D';
-	*data++ = 'V';
-	*data++ = 'D';
-	*data++ = '#';
-	*data++ = '1';
-	*data++ = '2';
-	*data++ = '3';
-	*data++ = '4';
+	/* serial number */
+	attrs = &cmd->dev->attrs;
+	vpd_pg = attrs->lu_vpd[PCODE_OFFSET(0x80)];
+	if (vpd_pg->size == 8) {
+		memcpy(data, vpd_pg->data, 8);
+	}
+	data += 8;

 	return data;
 }
-- 
1.5.5



More information about the stgt mailing list