I am building a track record of choosing projects that somehow flex the limits of what is easily doable on the Palm Pre.
First I wanted to use the Palm Pre as a mass storage device on my Xbox 360. The unraveling of that rabbit-hole took a full month. Now I want to be able to create and mount regular files as USB devices on the Palm Pre (an app I’m calling USB Mass Storage Tool). This time I am hitting a technical limitation imposed by Palm.
The current limitation is that sysfs is not available for applications to read/write from within the jailed environment in which apps run.
Q. Why would anyone need USB Mass Storage Tool? I mean, the Pre now works with the Xbox 360, isn’t that enough?
A. It is not enough. When you plug the Pre (or any storage device) into the Xbox 360 and attempt to use the device for data storage (storing saved games/profile information), the Xbox 360 will format the entire device. For the Palm Pre owner this means you lose /media/internal.
If you want to cry, try this. Hook your Pre into the Xbox, format it to be used as Xbox storage and then unplug your device. You will notice that all of your apps, photos, videos, etc are forever gone.
My dream is to be able to store a USB image for my Wii, Xbox 360 and PS3 as an actual file on the Pre (I don’t own a PS3, but PS3 owners should be interested in this). So when you browse the files on my device you will see:
When I want to save games on my Xbox, I choose xbox.img and present this file as my USB storage device. The Xbox formats the entire device (which is just a file sitting safely on /media/internal) and everyone walks away with no data loss.
Realizing the Dream
Not only is this possible, it is incredibly easy to do. You can mount any file or device by echoing said file/device into an entry in the sysfs filesystem:
echo /media/internal/xbox.img /sys/devices/platform/musb_hdrc.0/gadget/gadget-lun0/file
This sysfs entry was created by f_mass_storage.c for this very purpose. However, since Palm does not allow apps to access sysfs, what would have been a simple app has once again turned into usb module hacking. The sysfs filesystem contains non-process related information about drivers and hardware. Preventing user-level access to sysfs while allowing access to procfs doesn’t make a lot of sense from a security perspective. I have asked Palm for details on whether they plan on changing this policy.
In the meantime, because Palm allows access to /proc, I am going to modify the USB Mass storage driver so that it creates a procfs entry on module startup. This procfs entry will mimic the behavior of the sysfs entry.
Be the first to comment