Re: [PATCH] Forcing SCSI capacity for broken SD Card readers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 14, 2009 at 2:13 PM, Clemens Fruhwirth
<clemens@xxxxxxxxxxxxx> wrote:
> Hi everyone,
>
> Short: Attached is an incomplete patch that allows user space to force
> the capacity of an scsi device to a specific value. Any not over
> my-dead-body objections with that?

No major objection - just the usual nits:
Why not make /sys/block/sdX/size writeable?
    (instead of adding an ioctl())

grundler@parisc:~$ cat /sys/block/sda/size
976773168
grundler@parisc:~$ ls -l /sys/block/sda/size
-r--r--r-- 1 root root 4096 Oct 14 16:14 /sys/block/sda/size


After reading the wiki page[1], my impression is that the block size
gets reported wrong and thus the total capacity is miscalculated for
1GB-4GB SD cards with 1024 or 2048 byte blocks. Two questions around this:
a) Does the host need to know the correct block size for correct operation?
b) Do the devices report which SD Card Association spec they are compliant
   with in the USB headers?

I'm asking (b) to start the conversation about if it's feasible to
auto-detect this in the kernel and spare all the distro's from having
to frob the device size.

If we can autodetect this case, *and* the device has a valid FAT
partition, it should be trivial
to use the FAT partition info instead of what the USB card reader is
reporting. Partitioning
a new card will probably still need "size" to be writable.

hth,
grant

> Long: I was unfortunate and grabbed one of the cheaper USB SD card
> readers that do not correctly detect >1GB capacity sd cards. This is a
> known and common bug. See [1] or [2]. What's interesting is that this
> card reader was sold to work with these cards explicitly, and I
> figured it must have been tested only under Windows, which we all know
> believes in the partition table more strongly than in what the device
> reports. And indeed, my 2GB sd cards start to work if I simply ignore
> the capacity reported by the device. I have been using this
> successfully in the last half year with all my sd cards and now I'm
> tired of patching the kernel for just that thing. Could you imagine to
> merge that upstream? I doubt that any device will kill itself if this
> interface is used incorrectly.
>
> A simple user space program using the new interface is available at [3].
>
> Please CC, me not on list.
> [1] http://en.wikipedia.org/wiki/Secure_Digital#Standard-SD_cards_.28non-SDHC.29_with_greater_than_1_GB_capacity
> [2] http://www.hjreggel.net/cardspeed/special-sd.html
> [3] http://blog.clemens.endorphin.org/2009/03/patching-for-broken-sd-card-readers.html

thanks,
grant

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux