Difference between revisions of "Mounting Files and Devices as USB Mass Storage"
(initial page creation) |
m |
||
Line 4: | Line 4: | ||
linux-2.6.24/drivers/usb/gadget/f_mass_storage.c | linux-2.6.24/drivers/usb/gadget/f_mass_storage.c | ||
− | This driver calls '''DEVICE_ATTR''' to create a file named "file" in sysfs. When the sysfs entry is | + | This driver calls '''DEVICE_ATTR''' to create a file named "file" in sysfs. When the sysfs entry is written to, the function '''store_file()''' is called within the driver. This function will mount the file or device that is passed in. |
==Mounting Examples== | ==Mounting Examples== |
Revision as of 04:18, 5 March 2011
Mounting Files and Devices as USB Mass Storage
Background
Devices running WebOS use a usb mass storage driver written by Mike Lockwood in 2008. The driver source can be found in the following location in the source tree:
linux-2.6.24/drivers/usb/gadget/f_mass_storage.c
This driver calls DEVICE_ATTR to create a file named "file" in sysfs. When the sysfs entry is written to, the function store_file() is called within the driver. This function will mount the file or device that is passed in.
Mounting Examples
The following examples illustrate how to use this file, you must be root since the "file" entry has permissions 644.
Mount /media/internal
echo /dev/mapper/store-media > /sys/devices/platform/musb_hdrc.0/gadget/gadget-lun0/file
Create a 256 MB image and mount it
dd if=/dev/zero of=/media/internal/test.img bs=1M count=256
echo /media/internal/test.img > /sys/devices/platform/musb_hdrc.0/gadget/gadget-lun0/file
Applications
There are numerous applications that could benefit from using this feature. Many game consoles write to generic fat16/32 partitions, unfortunately they typically want to format the entire partition for their use. Using this method, a game console CAN format the entire partition (2nd example above) without wiping out the entire partition.