Re: SCSI programming

From: John-Paul Stewart (jpstewart_at_binaryfoundry.ca)
Date: 10/29/05


Date: Sat, 29 Oct 2005 14:48:33 -0400

Martin Vorbrodt wrote:
>
> trying to figure few things out, mainly scsi adapter detection and device
> enumeration in a way which would be portable accross kernels and distros.
> ASPI alloes me to detect number of adapters, and later detect devices on
> every adapter, chanel, id, lun. now, how would i go about doing the same on
> linux.

Take a look at the file /proc/scsi/scsi. As an example, on my system it
shows:

Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
   Vendor: SEAGATE Model: ST336753LW Rev: 0003
   Type: Direct-Access ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 01 Lun: 00
   Vendor: SEAGATE Model: ST336753LW Rev: 0003
   Type: Direct-Access ANSI SCSI revision: 03
Host: scsi1 Channel: 00 Id: 03 Lun: 00
   Vendor: TOSHIBA Model: DVD-ROM SD-M1711 Rev: 1005
   Type: CD-ROM ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 04 Lun: 00
   Vendor: PLEXTOR Model: CD-R PX-W1210S Rev: 1.02
   Type: CD-ROM

So for each device is shows Host (adapter), channel, ID, and LUN. The
Type field is also of interest. Disks always show Direct-Access, Tapes
  say Sequential-Access, tape autoloaders show Medium Changer, SAF-TE
enclosures and the like should list themselves as Type: Processor, and
so on. All you need to do is take a look in that file, and since its
format is reasonably well defined that can be done programmatically.



Relevant Pages