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: Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
Date: 08 Dec 2003 11:29:06 -0700	[thread overview]
Message-ID: <1070908146.2263.121.camel@patibmrh9> (raw)
In-Reply-To: <1070906283.2263.101.camel@patibmrh9>

> > > From:sg_scan.8
> 
> ... only the ... predefined -a and -n device lists

The trivial inline patch here does let us choose as we please out of
/dev/sg* , for example:

$ sudo sg_scan /dev/sg*
/dev/sg0: scsi0 channel=0 id=0 lun=0 [em]  type=5
$ sudo sg_scan /dev/sg2 /dev/sg1
$ sudo sg_scan /dev/sg0
/dev/sg0: scsi0 channel=0 id=0 lun=0 [em]  type=5
$

But 2.6.0-test11 drivers/block/scsi_ioctl.c doesn't much like sg utils
sg_scan.c:

$
$ sudo sg_scan /dev/hd[acd]
sg_scan: device /dev/hda failed on scsi ioctl, skip: Invalid argument
sg_scan: device /dev/hdc ioctls(4), skip: Invalid argument
sg_scan: device /dev/hdd ioctls(4), skip: Invalid argument
/dev/hdc: scsi0 channel=0 id=0 lun=0 [em]/dev/hdd: scsi0 channel=0 id=0 lun=0 [em]$
$

Pat LaVarre

diff -Nurp sg3_utils-1.06/sg_scan.c sg3_utils/sg_scan.c
--- sg3_utils-1.06/sg_scan.c	2003-11-11 21:30:59.000000000 -0700
+++ sg3_utils/sg_scan.c	2003-12-08 11:19:51.156943240 -0700
@@ -145,6 +145,7 @@ int main(int argc, char * argv[])
     int host_no;
     int flags;
     int emul;
+    int name0 = -1;
 
     for (k = 1; k < argc; ++k) {
         if (0 == strcmp("-n", argv[k]))
@@ -168,6 +169,10 @@ int main(int argc, char * argv[])
             usage();
             return 1;
         }
+        else if (*argv[k] == '/') {
+            name0 = k;
+            break;
+        }
         else if (*argv[k] != '-') {
             printf("Unknown argument\n");
             usage();
@@ -184,7 +189,20 @@ int main(int argc, char * argv[])
             perror(ME "close error");
             return 1;
         }
-        make_dev_name(fname, k, do_numeric);
+
+        if (name0 < 0) {
+            make_dev_name(fname, k, do_numeric);
+        }
+        else if (k < name0) {
+            sg_fd = -1;
+            continue;
+        }
+        else if (k < argc) {
+            strncpy(&fname[0], argv[k], sizeof fname);
+        }
+        else {
+            break;
+        }
 
         sg_fd = open(fname, flags | O_NONBLOCK);
         if (sg_fd < 0) {



  reply	other threads:[~2003-12-08 18:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-06  0:27 sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123] Pat LaVarre
2003-12-08  8:11 ` Douglas Gilbert
2003-12-08 17:39   ` Pat LaVarre
2003-12-08 17:58   ` Pat LaVarre
2003-12-08 18:29     ` Pat LaVarre [this message]
2003-12-11 20:02       ` Pat LaVarre
2003-12-12 13:00         ` Douglas Gilbert
2003-12-14 22:30           ` Pat LaVarre
2003-12-10 18:14     ` Pat LaVarre
2003-12-11  1:07   ` Willem Riede

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=1070908146.2263.121.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