On Thu, Oct 15, 2009 at 1:29 AM, Grant Grundler <grundler@xxxxxxxxxx> wrote: > On Wed, Oct 14, 2009 at 2:13 PM, Clemens Fruhwirth > <clemens@xxxxxxxxxxxxx> wrote: >> 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()) Oh, I like that. Sorry it took me so long to reply. It turned out that this is a much better idea. The value that is printed when reading the size attribute is to the value that I set in my patch indirectly through set_capacity. So, making size writable replaces that totally. Patch attached. > 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? >From experiments it does not look like that's the case. This is surprising though, as one would suspect the card not to function properly otherwise. Frankly speaking, I have not looked down the calling chain, especially how usb-storage treats these blocks, but I'd say not at all. Seems like the USB reader, I have, just doesn't get the capacity right, by not considering BLOCK_LEN > 512. > 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. I'm sorry, I can't really answer (b). Autofixing this doesn't seem possible to me (except for the partition trick) as the capacity = BLOCK_LEN * BLOCKS. If BLOCK_LEN isn't detected correctly, we can't distinguish a 1GB from 2GB card. Best Regards, -- Fruhwirth Clemens http://clemens.endorphin.org
Attachment:
size-setter.patch
Description: Binary data