Switch to full style
In-depth technology research: finding new ways to recover data, accessing firmware, writing programs, reading bits off the platter, recovering data from dust.

Forum rules

Please do not post questions about data recovery cases here (use this forum instead). This forum is for topics on finding new ways to recover data. Accessing firmware, writing programs, reading bits off the platter, recovering data from dust...
Post a reply

Help Help Help! How to read serial number of SCSI hard disk?

November 24th, 2011, 21:57

Hello,

I want to find a source code can read the serial number of SCSI hard disk.
I have the source code to read it on IDE (SATA) disk, but not work for SCSI.

I have searched many many places, and finally I got this magic site.
I saw there are many software here, many of them can read serial number, and SCSI supported.

Could you any one give me some instractions or kindly give me some source code to let me continue to next step?


Thank you very much!

Re: Help Help Help! How to read serial number of SCSI hard d

November 25th, 2011, 15:08

This sounds like a nice "homework" question :)

You didn't say which OS you are trying to use - the API to send raw SCSI commands varies significantly between OS, but a few minutes with Google will allow you to find examples for many of the common OS versions. For Linux you can look at the sg3_utils package (e.g. the source to sg_inq).

FYI some SCSI disks include a serial number in the "vendor unique" area of a standard Inquiry response. Others include it only in the response to Inquiry VPD page 0x80.

Re: Help Help Help! How to read serial number of SCSI hard d

November 25th, 2011, 15:17

Code:
function SCSI_Inquery (hFile : THandle;var InqBuff : array of byte): Results;
var
CDBCmd : array [0..5] of byte;
Size : ulong;
SenseBuff : array [0..31] of byte;
begin
    CdbCmd[0] := $12; //   OperationCode := SCSIOP_INQUIRY;
    CdbCmd[1] := $00; //   Flags := CDB_INQUIRY_EVPD=0;  Vital product data
    CdbCmd[2] := $00; //   Total
    CdbCmd[3] := $00;
    CdbCmd[4] := 96; // AllocationLength
    CdbCmd[5] := $00;
     Size := 96;


    Result :=SCSI_IN_Command(hFile,CdbCmd,6,InqBuff,Size, SenseBuff, 3);
end;


////////////////
SetString( S, PAnsiChar(@InqBuff[8])+28, 9 );
  Trim(s);
  fSerial :=s;

Re: Help Help Help! How to read serial number of SCSI hard d

November 26th, 2011, 18:51

Two more open source references:
http://linux.die.net/man/8/sdparm
http://smartmontools.sourceforge.net/sm ... _scsi.html
Post a reply