The question of the differences between /dev/sg write()/read() interface
and SCSI_IOCTL_SEND_COMMAND was raised in the amanda-users mailing-list.
I answered with the following. Any comments ? I will do a summary
to the amanda-users mailing-list.
From: Marc SCHAEFER <[EMAIL PROTECTED]>
Newsgroups: alphanet.ml.amanda.users
Subject: Re: Tape changer interface?
Date: 9 Apr 2000 12:10:56 +0200
Message-ID: <8cpkvg$7m8$[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]> <8c1e6l$lp5$[EMAIL PROTECTED]>
<8c70o3$m35$[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Sven Rudolph <[EMAIL PROTECTED]> wrote:
> > - scsi-generic interface (#define LINUX_CHG) for 2.0.x
> >
> > - ioctl() interface (#undef LINUX_CHG) for 2.2.x
> What's the difference between the last two interfaces, and what are
> the advantages/disadvantages of these interfaces?
The LINUX_CHG one uses the generic interface (/dev/sg), but it seems
it only works in 2.0.x (sg was changed, theoretically in a
backwards-compatible way in 2.2.x ...)
The other one, which seems to work nicely in 2.2.x uses
ioctl(DeviceFD, SCSI_IOCTL_SEND_COMMAND, Command);
which seems available only in Linux 2.2.x (drivers/scsi/scsi_ioctl.c),
although I also see it implemented in scsi_ioctl.c of 2.0.38 ...
/* The SCSI_IOCTL_SEND_COMMAND ioctl sends a command out to the SCSI host.
* The NORMAL_TIMEOUT and NORMAL_RETRIES variables are used.
*
* dev is the SCSI device struct ptr, *(int *) arg is the length of the
* input data, if any, not including the command string & counts,
* *((int *)arg + 1) is the output buffer size in bytes.
*
* *(char *) ((int *) arg)[2] the actual command byte.
*
* Note that if more than MAX_BUF bytes are requested to be transfered,
* the ioctl will fail with error EINVAL. MAX_BUF can be increased in
* the future by increasing the size that scsi_malloc will accept.
*
* This size *does not* include the initial lengths that were passed.
*
* The SCSI command is read from the memory location immediately after the
* length words, and the input data is right after the command. The SCSI
* routines know the command size based on the opcode decode.
*
* The output area is then filled in starting from the command byte.
*/
It seems to also use the generic device opening, at least, for
non already recognized devices (presumably you can use this ioctl()
either on /dev/sgX or /dev/sdaX if your target is a disk).
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]