From: Douglas Gilbert <dougg@torque.net>
To: Lee Xing <lxing@Crossroads.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: SCSI passthrough ioctl calls vs. sd/sg devices
Date: Sat, 24 Apr 2004 14:06:10 +1000 [thread overview]
Message-ID: <4089E7B2.5060803@torque.net> (raw)
In-Reply-To: <519672568F040C41B6FAC21ADF51B18FEFBE@mailnode1.commstor.crossroads.com>
Lee Xing wrote:
> Hi,
>
> I would appreciate it if some one could clarify this. It's a bit confusing.
>
> <<The Linux SCSI Generic (sg) HOWTO>> page 2 says "The sg driver permits user applications to send SCSI commands to devices that understand them. SCSI commands are 6, 10, 12 or 16 bytes long. The SCSI disk driver (sd), once device initialization is complete, only sends SCSI READ and WRITE commands."
>
> <<The Linux 2.4 SCSI subsystem HOWTO>> page 3 says "Sg is a SCSI command pass through device that uses a char device interface. General purpose Linux commands should not be used on sg devices."
>
> My questions are:
>
> - looks like SCSI passthrough ioctl calls can only apply
> to sg devices. Is it right, and can we apply SCSI
> passthrough ioctl calls to sd devices as well?
True in the lk 2.4 series. When all else fails you can still
use the SCSI_IOCTL_SEND_COMMAND ioctl() [which is what is
used by smartmontools currently].
In the lk 2.6 series the SG_IO ioctl is available for block
devices which include SCSI disks and ATAPI dvd/cd drives.
The SG_IO ioctl is currently not available for SCSI char
device drivers (e.g. st and osst) other than sg itself.
BTW ATA disks don't understand SCSI commands so the SG_IO
ioctl is of little use with them.
It the next week or so I hope to propose a SG_IO ioctl
for the scsi mid level for consideration in lk 2.6.
That will make the SG_IO ioctl available to st and osst
as well.
> - what are the so-called "General purpose Linux commands"?
> Are they read()/write() or 'mount' / 'dd' or something else?
mount, dd, cp, mv, rm (etc).
The sg3_utils package has a dd variant called sg_dd which can use
sg devices (as well as those that the standard dd can handle).
> What should we do if we need to 'mount' a file system on a disk and
> also need to issue SCSI passthrough ioctl calls to the same disk?
> Maybe we should use both sd and sg (i.e. mount the file system to
> /dev/sda, and issue SCSI passthrough ioctl calls to /dev/sg0 that
> maps to the same physical disk)?
yes
> 'mount' doesn't work on sg devices as I was told earlier.
true.
Doug Gilbert
next prev parent reply other threads:[~2004-04-24 4:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-21 22:04 SCSI passthrough ioctl calls vs. sd/sg devices Lee Xing
2004-04-24 4:06 ` Douglas Gilbert [this message]
2004-04-24 6:58 ` Kai Makisara
2004-04-24 12:42 ` Willem Riede
2004-04-25 6:49 ` Douglas Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4089E7B2.5060803@torque.net \
--to=dougg@torque.net \
--cc=linux-scsi@vger.kernel.org \
--cc=lxing@Crossroads.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox