sg_scan -i /dev/sg[0123] /dev/hd[abcd] /dev/scd[0123]
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.
Quoted 15 lines · Pat LaVarre
Doug G:
In lk 2.6 I wish
sg_scanaccepted 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 $
Quoted 1 line
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).
Quoted 10 lines
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(quoted diff) +0
-2-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
Quoted 14 lines
Quoted 10 lines
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(quoted diff) +0
-2-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
sg_dd.c +1 -0
@@ -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 (" " ); }
sg_read.c +1 -0
@@ -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 ); }
Quoted 3 lines
Quoted 3 lines
In lk 2.6 I wish
sg_scanaccepted 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.
Quoted 1 line
Quoted 1 line
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.
Quoted 1 line
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!
Quoted 2 lines
Maybe
sg_scanshould renamedsam_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.
Quoted 1 line
the gcc ... warning:
Answered separately in this same thread. Now I see gcc also complains of sgm_dd.c.
Quoted 3 lines
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
Quoted 3 lines
Quoted 1 line
Quoted 1 line
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
sg_scan.c +19 -1
@@ -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 ) {
Quoted 6 lines
Quoted 2 lines
Maybe
sg_scanshould renamedsam_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
Quoted 4 lines · Douglas Gilbert
Have a look at the sg3_utils-1.06.tgz beta on www.torque.net/sg
Maybe
sg_scanshould renamedsam_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)
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
sg_scan.c +3 -2
@@ -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" );
Quoted 8 lines · Pat LaVarre
Doug G:
Thank you, I see
sg_scannow 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.
Quoted 4 lines · Willem Riede
Quoted 2 lines
Maybe
sg_scanshould renamedsam_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
Doug G:
Quoted 8 lines
Quoted 6 lines
...
sg_scannow 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