Question

recently I have been trying all sorts of things with harddrives. Now I am stuck...

what I want to get is the serial,model,revision and WWN of harddrives.

for scsi all of the above is obtainable by a scsi inquiry. for SATA drives I use HDIO_GET_IDENTITY ioctl to obtain model,serial and revision but it doesnt include WWN. However I have not found how I can get thw WWN id for those drives. Anyone have some knowledge in this area?

Was it helpful?

Solution

In the end after the looking at linux/hdreg.h and some documentations from disk manufacterers I have found that the information IS included in HDIO_GET_IDENTITY IOCTL. But it is rather obscured.

http://lxr.free-electrons.com/source/include/linux/hdreg.h?v=2.6.32

at line 595 there are a few unspecified words. 4 of these words contain the WWN. you can get them like so:

sprintf(wwnstr,"0x%04x%04x%04x%04x",hd.words104_125[4],hd.words104_125[5],hd.words104_125[6],hd.words104_125[7]);

Anyway as has been noted a SCSI inquiry could be used to get the WWN data on SATA disks aswell. Here is some sample of a little program I wrote which sends an inquiry and obtains data.

this is a scsi disk and the WWN HEX is the WWN at offset 8 in vpd page 0x83 in the for of hex numbers, the WNN naa. is the string at offset 56 in the same page!

model:      ST3600057SS     
serial:     3SL1DBA00
revision:   EN03
wnn HEX:    0x5000C500286ACC13
wnn naa.:   0x5000C500286ACC10

However done on a SATA disk the same program will result in this:

model:      SAMSUNG HD103UJ 
serial:     S13PJ1DQ403064  
revision:   1AA0
wnn HEX:    0x533133504A314451
wnn naa.:   0x    

As you can seen the WWN is not specified as a string.

Is there are reason why the 2 WWN are not the same?

OTHER TIPS

You need to do a specific Page83 INQUIRY to the device in order to obtain its wwn as well as the serial number, model and revision.

I cover this (in part) at

https://www.jmcpdotcom.com/~jmcp/WhatIsAGuid.pdf

You need to set EVPD=1, page code = 0x83, and then look for a designator type of 0x2 (EUI-64) or 0x3 (NAA). EUI-64 based designators are covered in SPC-4rev 36 table 7.8.6.5 and NAA based are covered in SPC-4rev 36 table 7.8.6.6.

For a SATA-attached device, you should also review section 10.3.4 in the SCSI/ATA Translation Layer spec SAT-3.

Both SPC4 and SAT3 are available from http://www.t10.org.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top