Re: ioctl() and scsi_ioctl()

Douglas Gilbert (dgilbert@interlog.com)
Wed, 29 Dec 1999 22:24:52 -0500


Mike Eldridge wrote:

> I've got a couple of questions about scsi devices and
> scsi equivalents of ioctl() calls.
>
> The HDIO_GET_IDENTITY ioctl() call is very useful for
> IDE devices, and it has a couple of manpages. But I
> cannot find a simple-enough scsi equivalent. I've
> looked at the linux/scsi* headers as well as the scsi
> drivers in the kernel, even including the code that
> handles the /proc/scsi tree.
>
> I haven't found any simple documentation (manpage style
> =P) for scsi_ioctl.

Ioctl()s that get through to the scsi sub-system
are first checked against the "high" level driver
associated with the open device. This will be one of:
- sd [disks]
- sr [cdroms]
- st [tapes]
- sg [scanners, cdwriters, etc]
If no match is found then the ioctl is passed onto
the scsi midlevel (i.e. scsi_ioctl.c). If no match
is found then it may be passed onto the adapter
driver (e.g. the ide-scsi pseudo adapter driver
takes ioctl()s).

Ioctl()s in the scsi_ioctl.c file would apply to
all scsi devices, not just disks. 'man sd' on my
RH 6.0 found some documentation about several
ioctl()s supported by the scsi disk driver
but not the ioctl you are looking for. The
documentation in 'man 4 sd' seems a bit dated since
amongst other things the HDIO_REQ ioctl it describes
now seems to be called HDIO_GETGEO. Currently that
is the only "HDIO" ioctl supported in the scsi
sub-system.

> Anyhow, all I am looking for is a scsi-equivalent to
> ioctl(int d, HDIO_GET_IDENTITY, struct hd_driveid *hd)

Strange, I can find next to nothing about HDIO_GET_IDENTITY
in my man pages, just a reference in 'man 2 ioctl_list'
(which says it describes lk 1.3.27 !). Prefixing
struct hd_driveid in include/linux/hdreg.h is the comment:
/* structure returned by HDIO_GET_IDENTITY, as per ANSI ATA2 rev.2f spec */

This seems like scsi's inquiry command and some of
the disk specific mode sense pages wrapped up in one
container.

I'm trying to make the scsi inquiry command information
available via proc_fs (e.g. cat /proc/scsi/sg/device_strs).
More device type specific information can be obtained
from programs like scsiinfo (from Eric Youngdale at
www.andante.org) or my equivalent sginfo (at
www.torque.net/sg). These programs display scsi mode sense
pages. [BTW the "grown table" defect list is an interesting
one to monitor for scsi disks.] Robin Miller
(Robin.Miller@compaq.com) has some very interesting programs
in this area that can monitor the health of scsi
peripherals.

> Also, there are a couple of scsi-related ioctl() calls
> (most notably the calls that enable and disable tagged
> command queneing), but none of the good stuff, like a
> HDIO_GET_IDENTITY equivalent. Why are such calls not
> implemented in ioctl() for non-IDE devices? It seems
> to me that perhaps implementing a SCSI_GET_IDENTITY
> command in ioctl() would make things easier. But then
> again, I don't do kernel development. =)

Doug Gilbert

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/