Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[usb-storage] Re: [PATCH] fix Sony USB mass storage - pass larger receive buffer

0 views
Skip to first unread message

Pat LaVarre

unread,
Nov 17, 2003, 4:38:24 PM11/17/03
to
> I don't have any sd removable read only media.

Eh? Does http://www.torque.net/sg/sdebug26.html
not give us all sd removable read only media?

> If you want to test with your read only media,
> just use the dev flags:
>
> echo "vendor:model:0x4000" > /proc/scsi/device_info
>
> Then add your device, see if it comes back as writable, and try to mount
> or write it, and compare without the above (you can't remove device_info
> entry without rebooting or rmmod-ing scsi).

Thanks for kindly finding the time to share these hints, I have now
begun the work of decrypting them.

1) `find /lib/modules -name '*.ko'` says I have no scsi.ko. If I kick
around in `make xconfig` long enough, I may find one.

2) By vendor:model I first guess we mean what bash would say as
"$vendor:$model", of 8 and x10 bytes respectively, same as in op x12
Inquiry.

> can we easily nutshell for me how well
> > write-protect works now in sd? ...
> ...
> removable ... once when found (sd_probe ... sd_revalidate_disk), and ...
> sd_open calls check_disk_change, calls sd_media_changed ...
> sd_revalidate_disk to figure out ... write_prot ...
> write_prot ... if ... set ... the open fails with EROFS.

Prompt & cogent thank you.

> AFAICT, the sd write_prot setting is never passed on up to the block layer.

Except, of course, by way of EROFS returned from sd_open.

Pat LaVarre


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Patrick Mansfield

unread,
Nov 17, 2003, 5:00:32 PM11/17/03
to
[Trimmed the cc line]

On Mon, Nov 17, 2003 at 02:38:24PM -0700, Pat LaVarre wrote:
> > I don't have any sd removable read only media.
>
> Eh? Does http://www.torque.net/sg/sdebug26.html
> not give us all sd removable read only media?

Yes, looks like I would have to modify scsi_debug.c DEV_READONLY to make
it behave as read only.

> > If you want to test with your read only media,
> > just use the dev flags:
> >
> > echo "vendor:model:0x4000" > /proc/scsi/device_info
> >
> > Then add your device, see if it comes back as writable, and try to mount
> > or write it, and compare without the above (you can't remove device_info
> > entry without rebooting or rmmod-ing scsi).
>
> Thanks for kindly finding the time to share these hints, I have now
> begun the work of decrypting them.
>
> 1) `find /lib/modules -name '*.ko'` says I have no scsi.ko. If I kick
> around in `make xconfig` long enough, I may find one.

It is named scsi_mod.ko if you built it as a module.

Once you have a base .config it is easier to modify the .config and then
run make oldconfig and answer y/n/m.

I usually just delete the line in question from .config, and run make
oldconfig. In this case delete the line with CONFIG_SCSI and run make
oldconfig.

> 2) By vendor:model I first guess we mean what bash would say as
> "$vendor:$model", of 8 and x10 bytes respectively, same as in op x12
> Inquiry.

Yes.

-- Patrick Mansfield

Pat LaVarre

unread,
Nov 17, 2003, 6:36:56 PM11/17/03
to
> If you want to test with your read only media, just use the dev flags:
>
> echo "vendor:model:0x4000" > /proc/scsi/device_info
>
> Then add your device, see if it comes back as writable, and try to mount
> or write it, and compare without the above (you can't remove device_info
> entry without rebooting or rmmod-ing scsi).

Success!

Yes I see, same for sd as for sr/ide-cd, we can defeat write-protect in
2.6.0-test9 by root privilege so that then we can fail to write thru dd
or thru mount without bothering to notify the user loudly.

To prepare I remember I tried:

1) Make device writable.
2) mkfs
3) sync
4) Unplug.
5) Make device read-only.
6) Plug back in.

Thereafter I saw such tty logs as:

$ sudo sg_scan -i
/dev/sg0: scsi0 channel=0 id=0 lun=0 [em] type=0
LEXAR DIGITAL FILM /W1. [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
$
$ v="LEXAR "; m="DIGITAL FILM "; echo "$v:$m:0x4000" | sudo dd of=/proc/scsi/device_info
0+1 records in
0+1 records out
$
$ sudo dd of=/dev/sda1 if=/dev/zero bs=512 count=1
dd: opening `/dev/sda1': Read-only file system
$
$ sudo modprobe -r usb-storage
$ sudo modprobe usb-storage
$
$ sudo dd of=/dev/sda1 if=/dev/zero bs=512 count=1
1+0 records in
1+0 records out
$
$ dmesg | tail
usb-storage: -y "00 00 00 00 00 00"
usb-storage: -i 0x1000 -y "28 00 00 00 00 20 00 00 08 00"
usb-storage: -o 0x1000 -y "2A 00 00 00 00 20 00 00 08 00"
SCSI error : <4 0 0 0> return code = 0x8000002
Info fld=0x0, Current sda: sense = f0 7
ASC=27 ASCQ= 0
Raw sense data:0xf0 0x00 0x07 0x00 0x00 0x00 0x00 0x0b 0x00 0x00 0x00 0x00 0x27 0x00 0x00 0x00 0x00 0x00 0x00
end_request: I/O error, dev sda, sector 32
Buffer I/O error on device sda1, logical block 0
lost page write due to I/O error on sda1
$
$ sudo mount /dev/sda1 /mnt/sda1
$ ls /mnt/sda1
lost+found
$ sudo umount /mnt/sda1
$ dmesg | tail
[<c010b509>] sysenter_past_esp+0x52/0x71

usb-storage: -o 0x400 -y "2A 00 00 00 00 22 00 00 02 00"
SCSI error : <4 0 0 0> return code = 0x8000002
Info fld=0x0, Current sda: sense = f0 7
ASC=27 ASCQ= 0
Raw sense data:0xf0 0x00 0x07 0x00 0x00 0x00 0x00 0x0b 0x00 0x00 0x00 0x00 0x27 0x00 0x00 0x00 0x00 0x00 0x00
end_request: I/O error, dev sda, sector 34
Buffer I/O error on device sda1, logical block 1
lost page write due to I/O error on sda1
$

> [Trimmed the cc line]

Ack.

I concluded by trying:

$ egrep 'CONFIG_SCSI.*m' .config
CONFIG_SCSI=m
CONFIG_SCSI_DEBUG=m
$

Also I was helped by the dmesg:

scsi_strcpy_devinfo: vendor string 'LEXAR ' is too long
scsi_strcpy_devinfo: model string 'DIGITAL FILM ' is too long

And I failed to immediately grok `logger`. Instead I correlated my
shell commands with my dmesg by patching usb-storage to trace cdb's.

Pat LaVarre

0 new messages