[WIP/MOD] Adding FUSE filesystems to P500

AxesofEvil

Member
May 28, 2011
28
17
0
Status: working!
The tar file has some binaries which work.

If you aren't a developer you probably don't care about this.

I'm working on getting FUSE working on my P500, and thought I'd share my experiences. FUSE is a mechanism to mount lots of filesystems (like fusecompress, sshfs, or unionfs) without needing to recompile the kernel or patch the kernel. My need is to have a writeable /system that can be 'cleaned' back to the original state with the push of a button.

The following details my initial attempt. I've had better success as detailed here:
http://forum.xda-developers.com/showpost.php?p=14619814&postcount=3

Steps:
1) get the kernel source and build it with the FUSE module enabled. this provides fuse.ko which should be usable on virtually all 2.6.32.xx kernels for the P500

2) get the fuse userspace libraries and compile. I had to use a very old version (2.4.2) because newer versions need support for statvfs which bionic doesn't have. I had to patch in apthread_rwlock which isn't in bionic for froyo, and a few other cleanups.

3) get a fuse filesystem to test. I'm using unionfs-fuse. I had to use a very old version (0.11) to go with my very old libfuse from (2)

4) Try it out:
* move the files from 1-fuse.ko, 2-fusercompress, and 3-unionfs to the p500
* become root
* make sure all files are executable and in the PATH
* load the kernel module: insmod fuse.ko
* try to use fuse: ./unionfs --roots=/sdcard /mnt/asec

The last step seems to work, but ps shows no unionfs process.
Next I try with debug enabled:
* ./unionfs --roots=/sdcard /mnt/asec -d
This gives a segfault

Lastly I try with strace to find the segfault:
* strace -ff -F ./unionfs --roots=/sdcard /mnt/asec -d

now the code no longer segfaults, and the mount works.

So my goal now is to figure out why it segfaults when not run via strace.

I found someone who got this working on the desire:
http://forum.xda-developers.com/showthread.php?t=763908
(I tried their binaries just for fun, but they're not compatible with the P500)

They did it by using scratchbox which imports glibc. I was trying to do a native bionic build, but it may be easier to try scratchbox, as it would let me have a modern libfuse. If I can't figure out this segfault, then I'll go there next. Has anyone tried building for the P500 using scratchbox?
 

Attachments

Last edited:
  • Like
Reactions: naturist

AxesofEvil

Member
May 28, 2011
28
17
0
Ok, I have fuse fully working using the latest fuse version 2.8.5

In order to build, I got a copy of statvfs.c and statvfs.h from the shieldroid project. I had to modify the definition of f_fsid to be 'unsigned long' and adjust statvfs.c appropriately I also ended up disabling multi-threaded support in fuse as it made it made it easier to compile.

With a bunch of monkeying around, I got libfuse compiled with the apropriate utils. I verified the example filesystems worked, then went ahead and built unionfs-fuse (latest version).

Using the tar file in the 1st post you can now:
* copy all files to /data and make executable
* add the relevant directory to your path
* insmod fuse.ko
* ./unionfs /sdcard:/system/bin /data/local/tmp
* ls /data/local/tmp (should contain the contents of /system/bin and /sdcard in one merged dir)

When I get a chance, I'll build an installable zip that puts the files in the right place for easy use.
 

AxesofEvil

Member
May 28, 2011
28
17
0
FYI, my goal is to create a utility that can temporarily enable root on a phone and then disable it when done. My idea is to move the 'su' command out of /system/bin onto /data, and then use unionfs to teporarily add it back onto /system/bin on command. When done, you'll be able to click to unmount it again, bringing the phone back to an unrooted state.

It'll work sort of like the 'temporary root' capability of z4root, but will be undoable without a reboot (it also won't inculde the code to actually break out of a stock ROM, the goal is to be able to toggle root on an already rooted phone).

I need this capability because I run some enterprise software that doesn't work on a rooted phone, and I don't want to be constantly booting to recovery for root tasks.
 
  • Like
Reactions: ccdreadcc