Difference between revisions of "Mounting Files and Devices as USB Mass Storage"
m |
(Added link to an open source node.js project that uses these details.) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
==Background== | ==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:<br> | 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:<br> | ||
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 written to, the function '''store_file()''' is called within the driver. | + | This driver calls '''DEVICE_ATTR''' to create a file named "file" in sysfs. When the sysfs file entry is written to, the function '''store_file()''' is called within the driver. '''store_file()''' will mount the file or device that is passed in as an argument. |
==Mounting Examples== | ==Mounting Examples== | ||
− | The following examples illustrate how to use this file, you must be root since the "file" entry has permissions 644. | + | The following examples illustrate how to use this special file, you must be root since the "file" entry has permissions 644. |
'''Mount /media/internal'''<br> | '''Mount /media/internal'''<br> | ||
Line 17: | Line 16: | ||
==Applications== | ==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 | + | 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 precious user data. |
+ | |||
+ | ==Sample Service== | ||
+ | A node.js service for WebOS 2.x that implements the base functionality to mount user-specified files can be found [http://gitorious.org/usb-mass-storage-tools-service here] |
Latest revision as of 00:36, 16 March 2011
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 file entry is written to, the function store_file() is called within the driver. store_file() will mount the file or device that is passed in as an argument.
Mounting Examples
The following examples illustrate how to use this special 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 precious user data.
Sample Service
A node.js service for WebOS 2.x that implements the base functionality to mount user-specified files can be found here