public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Pat LaVarre <p.lavarre@ieee.org>
To: dougg@torque.net
Cc: linux-scsi@vger.kernel.org
Subject: SG_IO open flags are which
Date: 15 Dec 2003 09:39:42 -0700	[thread overview]
Message-ID: <1071506381.3389.22.camel@patibmrh9> (raw)

Doug G:

What open flags should apps use to talk SG_IO?

O_RDWR?  O_RDONLY?  O_NONBLOCK?  Other?  Combination?

Wrong info in Google includes:

> List: linux-scsi
> Date: 2003-12-03 0:17:56
> Re: sg utils sg_io -i 0x24 -y "12 00:00:00 24 00"
> ...
> > > - O_RDWR
> > > + O_RDONLY|O_NONBLOCK
> > ... not from reading a document anywhere ...
> ...
> Possibly we recommend open O_NONBLOCK for SG_IO ...
> Evidence in favour ... includes ...
> From: linux-2.6.0-test11/Documentation/cdrom/cdrom-standard.tex
> ...
> 1997/12/28 ... propose ... $O_NONBLOCK$ to indicate
> that the device is opened just for issuing $ioctl$
> commands.

Wrong guess, if we try 2.6.0-test11 with the three commands:

-i x24 -y "12 00:00:00 24 00" // standard Inquiry
-y "1B 00:00:00 00 00" // Stop Unit
-y "1B 00:00:00 01 00" // Start Unit

Either open O_NONBLOCK or open O_RDWR allows pass thru of standard
Inquiry.  And open O_RDWR allows pass thru of Stop Unit.  But open
O_NONBLOCK rejects pass thru of Stop Unit:

$ sudo plscsi /dev/sg0 -x "1B 00:00:00 00 00"
...
$ grep -i 'Operation not permitted' /usr/include/asm/errno.h
#define EPERM            1      /* Operation not permitted */
$

Perhaps lk has no open that allows all of SG_IO without closing trays,
spinning up discs, etc.?  If we do face that limit, then often we can
settle for O_NONBLOCK to list device names (e.g. sg_scan) and O_RDWR
otherwise (e.g. sg_dd).

Wish I knew where in the lk source we're choosing to have the privilege
of the open vary the transparency of the pass thru.

Pat LaVarre



             reply	other threads:[~2003-12-15 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-15 16:39 Pat LaVarre [this message]
2003-12-18  3:41 ` SG_IO open flags are which Douglas Gilbert
2003-12-18  9:47   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2004-04-06  0:49 Pat LaVarre
2004-05-20 15:16 Pat LaVarre

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=1071506381.3389.22.camel@patibmrh9 \
    --to=p.lavarre@ieee.org \
    --cc=dougg@torque.net \
    --cc=linux-scsi@vger.kernel.org \
    /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