- Notifications
You must be signed in to change notification settings - Fork4
libfuse (for android mainly)
License
GPL-2.0, LGPL-2.1 licenses found
Licenses found
agnostic-apollo/fuse
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is an old version of libfuse initially releasedhere, which was patched with android support. It has been further patched for NDK cross compilation and Termux native compilation. The device kernel must support the fuse filesystem. Check "/proc/filesystems" for "fuse" entry. Linux kernels 2.6.14 or latershould contain FUSE support.
Be aware that FUSE has an unresolved security bug(bug #15): thepermission check for accessing a cached directory is only done oncewhen the directory entry is first loaded into the cache. Subsequentaccesses will re-use the results of the first check, even if thedirectory permissions have since changed, and even if the subsequentaccess is made by a different user.
This bug needs to be fixed in the Linux kernel and has been knownsince 2006 but unfortunately no fix has been applied yet. If youdepend on correct permission handling for FUSE file systems, the onlyworkaround is to completely disable caching of directoryentries. Alternatively, the severity of the bug can be somewhatreduced by not using theallow_other
mount option.
FUSE (Filesystem in Userspace) is an interface for userspace programsto export a filesystem to the Linux kernel. The FUSE project consistsof two components: thefuse kernel module (maintained in the regularkernel repositories) and thelibfuse userspace library (maintainedin this repository). libfuse provides the reference implementationfor communicating with the FUSE kernel module.
A FUSE file system is typically implemented as a standaloneapplication that links with libfuse. libfuse provides functions tomount the file system, unmount it, read requests from the kernel, andsend responses back. libfuse offers two APIs: a "high-level",synchronous API, and a "low-level" asynchronous API. In both cases,incoming requests from the kernel are passed to the main program usingcallbacks. When using the high-level API, the callbacks may work withfile names and paths instead of inodes, and processing of a requestfinishes when the callback function returns. When using the low-levelAPI, the callbacks must work with inodes and responses must be sentexplicitly using a separate set of API functions.
It is best to gohere for latest libfuse versions for pc distros and use those.
#install dependenciessudo apt install autoconf automake libtoolcd fuse#only if building from git repository to generate configure script./makeconf.sh#build./configuremake -j8#install if neededmake install
You may also need to add/usr/local/lib
to/etc/ld.so.conf
and/orrunldconfig. If you're building from the git repository (instead ofusing a release tarball), you also need to run./makeconf.sh
tocreate theconfigure
script.
For more details see the fileINSTALL
Downloadandroid_ndk_cross_compile_build_automator and read/follow its usage guide.
Copy
fuse
directory toandroid_ndk_cross_compile_build_automator/packages
directory.Copy
fuse/post_build_scripts/fusermount_extractor.sh
file toandroid_ndk_cross_compile_build_automator/$POST_BUILD_SCRIPTS_DIR/
directory.Add/Set
fuse
to$PROJECTS_TO_BUILD
inandroid_ndk_cross_compile_build_automator.sh
.Add/Set
fusermount_extractor.sh
to$POST_BUILD_SCRIPTS_TO_RUN
inandroid_ndk_cross_compile_build_automator.sh
. You can skip this optionally if you do not want to create a zip of the fusermount binaries of all the archs that are built.Add/Set
armeabi armeabi-v7a arm64-v8a x86 x86-64
to$ARCHS_SRC_TO_BUILD
inandroid_ndk_cross_compile_build_automator.sh
or whatever ARCHS_SRC you want to build for. API_LEVEL in ARCH_SRC files must be 21 or higher otherwise compilation will fail. NDK must also be higher than r15. Checkfuse/android_ndk_cross_compile_build.sh
for more details.
#install dependenciessudo apt install autoconf automake libtoolcd android_ndk_cross_compile_build_automator#buildbash ./android_ndk_cross_compile_build_automator.sh
android_ndk_cross_compile_build_automator
will callfuse/android_ndk_cross_compile_build.sh script
to build and install each ARCHS_SRC. fuse for each ARCHS_SRC will be installed atandroid_ndk_cross_compile_build_automator/$INSTALL_DIR/fuse/$ARCHS_SRC
.android_ndk_cross_compile_build_automator/$POST_BUILD_SCRIPTS_DIR/fusermount_extractor.sh
will extractfusermount
binaries fromandroid_ndk_cross_compile_build_automator/$INSTALL_DIR/fuse/$ARCHS_SRC
and zip them atandroid_ndk_cross_compile_build_automator/$OUT_DIR/fuse/fusermount<build-info>.zip
.
Fully static compile is not possible currently for fusermount binary using NDK since bionic libc does not support static linking (fully or at all), since binaries built for android are supposed to dynamically link with android system libraries of each phone and android version at runtime. Fusermount compiled with NDK will dynamically link with android system libc.so and/or libdl.so.However the fusermount compiled with above flags is not linked with any termux libraries and should not need the export of termux lib path with LD_LIBRARY_PATH for execution. Fully static compile will probably be possible with mucl since its libc implementation has static support. A focus on only the fusermount binary is because it is required byrclonemount for mounting cloud drives like google drive in android with root of course. That was the motivation behind this all.
Download release zip or copy the zip built from source to your device.
Extract the binary of your device arch or abi from the zip.
#command to find device archuname -m#command to find device abigetprop ro.product.cpu.abi
- Copy the binary to
/data/data/com.termux/files/usr/bin
and then set correct ownership and permissions by running the following commands in a non-root shell. If you run them in a root shell, then binary will only be runnable in a root shell.
export scripts_path="/data/data/com.termux/files/usr/bin"; export termux_uid="$(id -u)"; export termux_gid="$(id -g)"; su -c chown $termux_uid:$termux_gid "$scripts_path/fusermount" && chmod 700 "$scripts_path/fusermount";
#run following commands in a non-root shell#install dependenciespkg install build-essential git silversearcher-ag wget gettextcd fuse#must be run to generate configure script and fulfill dependencies in termux./makeconf_termux.sh#build./configure CC=clang CXX=clang++ --enable-example=no --disable-mtab --enable-android=yes --enable-static=yes LDFLAGS="-static-libgcc"make#install fusermount by copying it to termux bin path and set correct ownership and permissionscp ./util/fusermount /data/data/com.termux/files/usr/binexport scripts_path="/data/data/com.termux/files/usr/bin"; export termux_uid="$(id -u)"; export termux_gid="$(id -g)"; su -c chown $termux_uid:$termux_gid "$scripts_path/fusermount" && chmod 700 "$scripts_path/fusermount";
Fully static compile is not possible currently for fusermount binary using termux since termux clang does not support static compilations and even if that were possible, fusermount would most likely still link dynamically with android system libc.so and/or libdl.so.However the fusermount compiled with above flags is not linked with any termux libraries and should not need the export of termux lib path with LD_LIBRARY_PATH for execution.
You can check outTermux Build Packages Wiki for more helpful info.
If you runmake install
, thefusermount program is installedset-user-id to root. This is done to allow normal users to mounttheir own filesystem implementations.
There must however be some limitations, in order to prevent Bad User fromdoing nasty things. Currently those limitations are:
The user can only mount on a mountpoint, for which it has writepermission
The mountpoint is not a sticky directory which isn't owned by theuser (like /tmp usually is)
No other user (including root) can access the contents of themounted filesystem (though this can be relaxed by allowing the useof the
allow_other
andallow_root
mount options infuse.conf
)
FUSE comes with several example file systems in theexamples
directory. For example, thefusexmp example mirrors the contents ofthe root directory under the mountpoint. Start from there and adaptthe code!
The documentation of the API functions and necessary callbacks ismostly contained in the filesinclude/fuse.h
(for the high-levelAPI) andinclude/fuse_lowlevel.h
(for the low-level API). Anautogenerated html version of the API is available in thedoc/html
directory and athttp://libfuse.github.io/doxygen.
If you need help, please ask on thefuse-devel@lists.sourceforge.netmailing list (subscribe athttps://lists.sourceforge.net/lists/listinfo/fuse-devel).
Please report any bugs on the GitHub issue tracker athttps://github.com/libfuse/main/issues.
About
libfuse (for android mainly)