public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
@ 2003-12-06  0:27 Pat LaVarre
  2003-12-08  8:11 ` Douglas Gilbert
  0 siblings, 1 reply; 10+ messages in thread
From: Pat LaVarre @ 2003-12-06  0:27 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

Doug G:

In lk 2.6 I wish sg_scan accepted a list of args e.g.

$ lsmod | grep sg
$
$ sudo sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
/dev/hdd: scsi0 channel=0 id=0 lun=0 [em]  type=5
    Iomega    RRD               05.A [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
/dev/scd0: scsi0 channel=0 id=0 lun=0 [em]  type=5
    Iomega    RRD               05.U [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
$
$ lsmod | grep sg
$ 

Tell me you will accept such a patch, and I might not be too lazy to write it.

Pat LaVarre

P.S. I presume already you are aware of the gcc -Wall warning:

$ cd sg3_utils-1.06/
$ make
gcc -g -O2 -Wall -W -D_REENTRANT -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64
-c -o sg_dd.o sg_dd.c
sg_dd.c: In function `siginfo_handler':
sg_dd.c:138: warning: unused parameter `sig'
...

P.P.S. Thanks again for giving http://www.torque.net/sg/ us via google.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  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
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Douglas Gilbert @ 2003-12-08  8:11 UTC (permalink / raw)
  To: Pat LaVarre; +Cc: linux-scsi

Pat LaVarre wrote:
> Doug G:
> 
> In lk 2.6 I wish sg_scan accepted a list of args e.g.
> 
> $ lsmod | grep sg
> $
> $ sudo sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
> /dev/hdd: scsi0 channel=0 id=0 lun=0 [em]  type=5
>     Iomega    RRD               05.A [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
> /dev/scd0: scsi0 channel=0 id=0 lun=0 [em]  type=5
>     Iomega    RRD               05.U [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
> $
> $ lsmod | grep sg
> $ 
> 
> Tell me you will accept such a patch, and I might not be too lazy to write it.

Pat,
Have a look at the sg3_utils-1.06.tgz beta on www.torque.net/sg

Maybe sg_scan should renamed sam_scan (sadly apart from INQUIRYs
on st and osst devices).

> P.S. I presume already you are aware of the gcc -Wall warning:
> 
> $ cd sg3_utils-1.06/
> $ make
> gcc -g -O2 -Wall -W -D_REENTRANT -D_LARGEFILE64_SOURCE
> -D_FILE_OFFSET_BITS=64
> -c -o sg_dd.o sg_dd.c
> sg_dd.c: In function `siginfo_handler':
> sg_dd.c:138: warning: unused parameter `sig'
> ...

Yes, but adding the '-W' flagging has several beneficial
effects (to counterbalance this annoying warning which
C++ but not C addresses).


BTW The sginfo in that beta decodes mode pages for disks,
tapes, cd/dvds and enclosures (plus SPI-4, FCP and SAS on
the transport side).

Doug Gilbert



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-08  8:11 ` Douglas Gilbert
@ 2003-12-08 17:39   ` Pat LaVarre
  2003-12-08 17:58   ` Pat LaVarre
  2003-12-11  1:07   ` Willem Riede
  2 siblings, 0 replies; 10+ messages in thread
From: Pat LaVarre @ 2003-12-08 17:39 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

> > P.S. I presume already you are aware of the gcc -Wall warning:
> > 
> > $ cd sg3_utils-1.06/
> > $ make
> > gcc -g -O2 -Wall -W -D_REENTRANT -D_LARGEFILE64_SOURCE
> > -D_FILE_OFFSET_BITS=64
> > -c -o sg_dd.o sg_dd.c
> > sg_dd.c: In function `siginfo_handler':
> > sg_dd.c:138: warning: unused parameter `sig'
> > ...
> 
> Yes, but adding the '-W' flagging has several beneficial
> effects (to counterbalance this annoying warning which
> C++ but not C addresses).

Sorry I had forgotten that gcc -W warns of more than -Wall.

I have seen translations to C language express the idea of discarding a
result on purpose via such source code as { result = result; }
assign-no-change and { (void) result; } cast-to-void.

I vote assign-no-change, because ...

gcc -Wall -W here now seems happy with either.  Possibly I remember
msvc++ max warnings accepting assign-no-change and disliking
cast-to-void.  I see javac here accepts assign-to-self, rejects
cast-to-void as an error.  I see `man lint` here now chokes.  `man -k
lint` suggests `splint`.  `splint sg_dd.c` yields about 283 warnings,
but accepts assign-no-change quietly while complaining of cast-to-void
via "Statement has no ...  visible effect --- no values are modified
...".

Assign-no-change has not yet bitten me with gcc, your mileage may vary.

I see `make sg_dd.lst` here doesn't yet know gcc -a well enough to try
things like the linux-fsdevel suggestion `gcc -O -g -Wa=
,-ahls file.c` that you might see hinted by lk 2.6 `make
drivers/usb/core/usb.lst`.

Pat LaVarre

diff -Nurp sg3_utils-1.06/sg_dd.c sg3_utils/sg_dd.c
--- sg3_utils-1.06/sg_dd.c	2003-11-12 04:02:10.000000000 -0700
+++ sg3_utils/sg_dd.c	2003-12-08 10:14:15.315282120 -0700
@@ -137,6 +137,7 @@ static void interrupt_handler(int sig)
 
 static void siginfo_handler(int sig)
 {
+    sig = sig;
     fprintf(stderr, "Progress report, continuing ...\n");
     print_stats("  ");
 }
diff -Nurp sg3_utils-1.06/sg_read.c sg3_utils/sg_read.c
--- sg3_utils-1.06/sg_read.c	2003-11-11 21:32:01.000000000 -0700
+++ sg3_utils/sg_read.c	2003-12-08 10:14:35.178262488 -0700
@@ -123,6 +123,7 @@ static void interrupt_handler(int sig)
 
 static void siginfo_handler(int sig)
 {
+    sig = sig;
     fprintf(stderr, "Progress report, continuing ...\n");
     print_stats(0);
 }



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  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
  2003-12-10 18:14     ` Pat LaVarre
  2003-12-11  1:07   ` Willem Riede
  2 siblings, 2 replies; 10+ messages in thread
From: Pat LaVarre @ 2003-12-08 17:58 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

> > In lk 2.6 I wish sg_scan accepted a list of args e.g.
> > 
> > $ sudo sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]

Kindly offline I'm told `man sg_scan` may have changed lately.  I have
sg installed without root privilege, so I have no man, but my sg_scan.8
is readable.

> > From:sg_scan.8

There I see only the -anwix options defined, in particular the
predefined -a and -n device lists.  I see no support for accepting a
list of devices to try from the command line.  I will write a patch and
reply again.

> Have a look at the sg3_utils-1.06.tgz beta on www.torque.net/sg

1.06 of Mon differs from 1.06 of Fri, aye.  My diff -Nurp between those
yields 1432 lines.  I see CHANGELOG mentions: "accept /dev/hd? ATAPI
devices directly in lk 2.6", I thank you!

> Maybe sg_scan should renamed sam_scan (sadly apart from INQUIRYs
> on st and osst devices).

Lost me help?  I'm guessing this English means an "st device" is a PDT
x01 device aggressively supported by CONFIG_CHR_DEV_ST, and we (lk 2.6)
have history that precludes sg_scan from seeing st devices, and osst is
something like st but distinct.

> the gcc ... warning:

Answered separately in this same thread.  Now I see gcc also complains
of sgm_dd.c.

> BTW The sginfo in that beta decodes mode pages for disks,
> tapes, cd/dvds and enclosures (plus SPI-4, FCP and SAS on
> the transport side).

$ sudo ./sginfo -a /dev/hdc | wc -l
    223
$ sudo ./sginfo -a /dev/hdd | wc -l
    117
$

Fun thank you.

Pat LaVarre



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-08 17:58   ` Pat LaVarre
@ 2003-12-08 18:29     ` Pat LaVarre
  2003-12-11 20:02       ` Pat LaVarre
  2003-12-10 18:14     ` Pat LaVarre
  1 sibling, 1 reply; 10+ messages in thread
From: Pat LaVarre @ 2003-12-08 18:29 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

> > > 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) {



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-08 17:58   ` Pat LaVarre
  2003-12-08 18:29     ` Pat LaVarre
@ 2003-12-10 18:14     ` Pat LaVarre
  1 sibling, 0 replies; 10+ messages in thread
From: Pat LaVarre @ 2003-12-10 18:14 UTC (permalink / raw)
  To: linux-scsi

> > Maybe sg_scan should renamed sam_scan (sadly apart from INQUIRYs
> > on st and osst devices).
> 
> ... guessing ...
> an "st device" is a PDT x01 device ... CONFIG_CHR_DEV_ST, ...
> osst is something like st but distinct.

Via `grep _ST .config` I now recall that here in linux-scsi once I
guessed st is part/all of what CONFIG_CHR_DEV_ST builds.

Following that pattern by trying `grep _OSST .config`, I now guess
"osst" is part/all of what CONFIG_CHR_DEV_OSST builds.

Pat LaVarre



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-08  8:11 ` Douglas Gilbert
  2003-12-08 17:39   ` Pat LaVarre
  2003-12-08 17:58   ` Pat LaVarre
@ 2003-12-11  1:07   ` Willem Riede
  2 siblings, 0 replies; 10+ messages in thread
From: Willem Riede @ 2003-12-11  1:07 UTC (permalink / raw)
  To: linux-scsi

On 2003.12.08 03:11, Douglas Gilbert wrote:
> Have a look at the sg3_utils-1.06.tgz beta on www.torque.net/sg
> 
> Maybe sg_scan should renamed sam_scan (sadly apart from INQUIRYs
> on st and osst devices).
            ^^^^
Is there something I can/should do to enable that?

Regards, Willem Riede.
(osst maintainer)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-08 18:29     ` Pat LaVarre
@ 2003-12-11 20:02       ` Pat LaVarre
  2003-12-12 13:00         ` Douglas Gilbert
  0 siblings, 1 reply; 10+ messages in thread
From: Pat LaVarre @ 2003-12-11 20:02 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

Doug G:

Thank you, I see sg_scan now lets me name the devices to scan, including
lk 2.6 block devices:

The inline patch of this e-mail then also omits and scans past the
"Stopping because there are too many error" message in configurations
with few devices present, for example:

$ cd sg3_utils-1.06
$
$ grep Ch CHANGELOG | head -1
Changelog for sg3_utils-1.06 [20031210]
$
$ sudo ./sg_scan -i /dev/hd[abcd] /dev/scd[0123]
sg_scan: device /dev/hda failed on scsi ioctl, skip: Invalid argument
/dev/hdc: scsi0 channel=0 id=0 lun=0 [em]
    LITE-ON   COMBO LTC-48161H  KH0K [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
/dev/hdd: scsi0 channel=0 id=0 lun=0 [em]
    Iomega    RRD               11.A [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
/dev/scd0: scsi0 channel=0 id=0 lun=0 [em]
    Iomega    RRD               11.U [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
/dev/scd1: scsi1 channel=0 id=0 lun=0 [em]
    Iomega    RRD               11.U [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
Stopping because there are too many error
$

Pat LaVarre

diff -Nurp sg3_utils-1.06/sg_scan.c sg3_utils/sg_scan.c
--- sg3_utils-1.06/sg_scan.c	2003-12-09 20:24:21.000000000 -0700
+++ sg3_utils/sg_scan.c	2003-12-11 12:56:09.956934904 -0700
@@ -187,7 +187,7 @@ int main(int argc, char * argv[])
     flags = writeable ? O_RDWR : O_RDONLY;
 
     for (k = 0, res = 0, j = 0; 
-	 (k < max_file_args)  && (num_errors < MAX_ERRORS);
+	 (k < max_file_args)  && (has_file_args || (num_errors < MAX_ERRORS));
          ++k, res = (sg_fd >= 0) ? close(sg_fd) : 0) {
         if (res < 0) {
             snprintf(ebuff, EBUFF_SZ, ME "Error closing %s ", fname);
@@ -283,7 +283,8 @@ int main(int argc, char * argv[])
                 res = sg3_inq(sg_fd, inqBuff, do_extra);
         }
     }
-    if ((num_errors >= MAX_ERRORS) && (num_silent < num_errors)) {
+    if ((num_errors >= MAX_ERRORS) && (num_silent < num_errors) &&
+            !has_file_args) {
         printf("Stopping because there are too many error\n");
         if (eacces_err)
             printf("    root access may be required\n");



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-11 20:02       ` Pat LaVarre
@ 2003-12-12 13:00         ` Douglas Gilbert
  2003-12-14 22:30           ` Pat LaVarre
  0 siblings, 1 reply; 10+ messages in thread
From: Douglas Gilbert @ 2003-12-12 13:00 UTC (permalink / raw)
  To: Pat LaVarre; +Cc: linux-scsi

Pat LaVarre wrote:
> Doug G:
> 
> Thank you, I see sg_scan now lets me name the devices to scan, including
> lk 2.6 block devices:
> 
> The inline patch of this e-mail then also omits and scans past the
> "Stopping because there are too many error" message in configurations
> with few devices present, ....

Pat,
Patch applied, uploaded to the sg webpage.

Willem Riede wrote:
 > > Maybe sg_scan should renamed sam_scan (sadly apart from INQUIRYs
 > > on st and osst devices).
 >             ^^^^
 > Is there something I can/should do to enable that?

No, the problem is in sg_scan. The version I just uploaded
falls back to the SCSI_IOCTL_SEND_COMMAND if the SG_IO
ioctl fails. This should make INQUIRYs work on st and osst
devices.

Doug Gilbert



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
  2003-12-12 13:00         ` Douglas Gilbert
@ 2003-12-14 22:30           ` Pat LaVarre
  0 siblings, 0 replies; 10+ messages in thread
From: Pat LaVarre @ 2003-12-14 22:30 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

Doug G:

> > ... sg_scan now lets me name the devices to scan, including
> > lk 2.6 block devices:
> > 
> > ... then also omits and scans past the
> > "Stopping because there are too many error" message in configurations
> > with few devices present, ....
> ...
> Patch applied, uploaded to the sg webpage.

Beautiful, thank you, our command line grows more incisive:

$ time sg_scan -i /dev/hd* /dev/scd*
sg_scan: device /dev/hda failed on scsi ioctl, skip: Invalid argument
sg_scan: device /dev/hda1 failed on scsi ioctl, skip: Invalid argument
sg_scan: device /dev/hda2 failed on scsi ioctl, skip: Invalid argument
sg_scan: device /dev/hda3 failed on scsi ioctl, skip: Invalid argument
/dev/hdc: scsi0 channel=0 id=0 lun=0 [em]
    LITE-ON   COMBO LTC-48161H  KH0K [rmb=1 cmdq=0 pqual=0 pdev=0x5]
/dev/hdd: scsi0 channel=0 id=0 lun=0 [em]
    Iomega    RRD               14.A [rmb=1 cmdq=0 pqual=0 pdev=0x5]
/dev/scd0: scsi0 channel=0 id=0 lun=0 [em]
    Iomega    RRD               14.U [rmb=1 cmdq=0 pqual=0 pdev=0x5]
/dev/scd1: scsi1 channel=0 id=0 lun=0 [em]
    Iomega    RRD               14.U [rmb=1 cmdq=0 pqual=0 pdev=0x5]
 
real    0m1.213s
user    0m0.097s
sys     0m0.021s
$
$ uname -msr
Linux 2.6.0-test11 i686
$
$ grep Change sg3_utils-1.06/CHANGELOG | head -1
Changelog for sg3_utils-1.06 [20031212]
$

Pat LaVarre



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-12-14 22:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox