usb-mass-storage, data corruption, QtMoko v26

Alfa21-mobile freerunner at my.is.it
Wed Sep 29 15:42:30 CEST 2010


> btw I'm not sure if this is acceptable by OSes others than linux, because in this way we expose a storage without a partition table.
> (I'll check this on a windows computer asap)

ok, sorry... I was away from any kind of windows pc :P
now I can confirm this fix is ok and my phone is viewed as a regular
single partition usb mass storage (atleast in win XP and Linux)

so the fix is:

!!!-> I assume /dev/mmcblk0p1 being the fat32 partition used as storage

/opt/qtmoko/bin/usb-mass-storage-on.sh
[begin]

#!/bin/sh
DEV_NAME=/dev/mmcblk0p1
ifdown usb0
# sync all buffers
sync ; echo 3 > /proc/sys/vm/drop_caches
umount ${DEV_NAME}
rmmod g_ether
modprobe g_file_storage file=${DEV_NAME} stall=0 removable=y

[End.Of.File]

in my /etc/fstab I've this line:
/dev/mmcblk0p1 /media/card auto  defaults                           0 0

and
/dev/mmcblk0p2  /         auto    defaults,errors=remount-ro,noatime 0 1
instead of the "rootfs" one. (yes, my qtmoko is on the second
partition of uSD and I've qi bootloader)
[I've also a swap on /dev/mmcblk0p3 but it's another topic]


and in my /home/root/Documents/ I have a symlink like:
card -> /media/card/
so I can see its contents in qtmoko documents (remember the "Rescan
System" option in menu!!)


- with this modification you can start the mass storage (USB mass
storage on) an your /media/card data will be visible as an usb stick.
- it will be unmounted in qtmoko untill you select "USB mass storage
off" in qtmoko.
- your qtmoko will not corrupt the uSD.
- you'll be able to use your phone as always and you can also forget
to switch the storage off (but meanwhile you cannot do ssh or ip
connection via usb cable or read your /media/card inside qtmoko)



I suggest to Radek (and all the community in general) to review this
fix and possibly include it in the next release of qtmoko or asap.
(data corruption is not a nice thing)
if something is unclear, here I am! ;)


kind regards, a.




On Sat, Sep 11, 2010 at 3:31 AM, Alfa21 wrote:
> 2010-09-10 at 18:13 Alfa21-mobile
>> and now a question from me:
>> when the usb mass storage mode is enabled, all the used partitions is
>> in read only mode..
>> I see qtmoko exports also the rootfs and imho it's not good because if
>> I forget to switch off the usb storage ... it's bad for the whole
>> system.
>>
>> the question is: how I can configure qtmoko to use only a specific
>> partition? eg the one mounted on /media/card only?
>
>
>
> about g_file_storage...
> we have this DOGMA: an usb host will not expect to see any changes in the storage other than the ones it makes.
>
> I found a critical (if the rootfs is on uSD) bug concerning the use of g_file_storage with the scripts in qtmokoV26!!
>
> - the "# mount checking" if, in /opt/qtmoko/bin/usb-mass-storage-on.sh is too weak because:
> 1) by default /etc/fstab in qtmoko contains "rootfs" for / and any root partition on the uSD is not found by that grep
> 2) any swap partition is not found by that grep
>
> so we could corrupt our storage if it remains mounted inside the freerunner and both exported with usb!
>
>
> a fix could be:
> - in storage-on script
> 1) modify the DEV_NAME with the name of the specific partition we want to export
> 2) umount it and really verify it's not mounted
> 3) modprobe g_file_storage (and we should add "removable=y" to the modprobe line)
>
>
> btw I'm not sure if this is acceptable by OSes others than linux, because in this way we expose a storage without a partition table.
> (I'll check this on a windows computer asap)
> ...else we could make a partition table inside the exported partition and use kpartx in the freerunner to read the storage (yes, it's like a matryoshka of partitions)
>
> bye, a.
>



More information about the community mailing list