Difference between revisions of "Mounting Files and Devices as USB Mass Storage"

From WebOS Internals
Jump to navigation Jump to search
m
m (Fixed section header and grammar)
Line 1: Line 1:
= Mounting Files and Devices as USB Mass Storage =
 
 
==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 function will mount the file or device that is passed in.
+
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 entire partition.
+
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.

Revision as of 06:13, 6 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.