termux/termux-root-packages

[Package request] Inclusion of libfuse3

FreddieOliveira opened this issue · 1 comments

Package description

Filesystem in Userspace (FUSE) is a software interface for Unix and Unix-like computer operating systems that lets non-privileged users create their own file systems without editing kernel code, or it was supposed to be.

Actually this is not so true in Android, since only root user are allowed to use it. Nor relaxing permissions of /dev/fuse, nor setting the set ID bit of the libs and binaries makes any difference. Blame Google for this.

Here's the Ubuntu package page for reference:
https://packages.ubuntu.com/focal/libfuse3-3

Link to home page and sources

  1. Home page: https://github.com/libfuse/libfuse
  2. Source code: https://github.com/libfuse/libfuse

Additional information

As discussed here, some patches are necessary as a workaround to some pthread functions not available in the Android SDK. The strategy used was to use an atomic watch variable and check if it's set right before the so called cancellation points functions. This mimics as close as possible the pthread_cancel behavior.

These are the libs it depends upon:

libdl.so
libc.so

Release build

All the steps above were executed from within termux using the latest stable version of libfuse v3. First download the patches, then run:

$ wget https://github.com/libfuse/libfuse/releases/download/fuse-3.9.1/fuse-3.9.1.tar.xz
$ tar xf fuse-3.9.1.tar.xz && cd fuse-3.9.1
$ patch meson.build ../meson.build.patch
$ patch lib/fuse.c ../fuse.c.patch
$ patch lib/fuse_loop_mt.c ../fuse_loop_mt.c.patch
$ mkdir build && cd build
$ meson -D disable-mtab=true -D examples=false -D sbindir=bin -D mandir=man -D udevrulesdir=/etc/udev/rules.d -D useroot=false -D buildtype=release -D strip=true -D prefix=/ ..
$ DESTDIR=/data/data/com.termux/files/usr ninja install

This is the list of files added to the system when installed:

files
└── usr
    ├── bin
    │   ├── fusermount3
    │   └── mount.fuse3
    ├── etc
    │   ├── fuse.conf
    │   ├── init.d
    │   │   └── fuse3
    │   └── udev
    │       └── rules.d
    │           └── 99-fuse3.rules
    ├── include
    │   └── fuse3
    │       ├── cuse_lowlevel.h
    │       ├── fuse.h
    │       ├── fuse_common.h
    │       ├── fuse_log.h
    │       ├── fuse_lowlevel.h
    │       └── fuse_opt.h
    ├── lib
    │   ├── libfuse3.so -> libfuse3.so.3
    │   ├── libfuse3.so.3 -> libfuse3.so.3.9.1
    │   ├── libfuse3.so.3.9.1
    │   └── pkgconfig
    │       └── fuse3.pc
    └── man
        ├── man1
        │   └── fusermount3.1
        └── man8
            └── mount.fuse3.8

13 directories, 17 files

Debug build

Note that this build is not intended to be installed on the system, since the installation paths and other stuffs are not properly set. The purpose here is to built the tests and execute them at the end.

All the steps above were executed from within termux using the latest stable version of libfuse v3. First download the patches, then run:

$ wget https://github.com/libfuse/libfuse/releases/download/fuse-3.9.1/fuse-3.9.1.tar.xz
$ tar xf fuse-3.9.1.tar.xz && cd fuse-3.9.1
$ patch lib/fuse.c ../fuse.c.patch
$ patch lib/fuse_loop_mt.c ../fuse_loop_mt.c.patch
$ patch lib/fuse_i.h ../fuse_i.h.patch
$ patch example/poll.c ../poll.c.patch
$ patch example/printcap.c ../printcap.c.patch
$ patch test/test_setattr.c ../test_setattr.c.patch
$ mkdir build && cd build
$ meson -D disable-mtab=true -D udevrulesdir=/etc/udev/rules.d ..
$ ninja
$ sudo python3 -m pytest --maxfail=0 test/ > test.out

Most probably the test.out file will be very large. On my phone, from the 43 tests:

  • 24 passed
  • 15 failed, from which
    • 1 were due to the android kernel doesn't suppport CUSE
    • 10 due to the android doesn't support hard links
    • 4 I believe due to permission issues, even running the tests as root
  • 4 were skipped, I don't know why

In summary, I believe the core part of the lib is working properly. The errors got are because of lack of support from the kernel related to other non critical things, not because of build problems.

Attachments

fuse_i.h.patch.txt
fuse_loop_mt.c.patch.txt
fuse.c.patch.txt
poll.c.patch.txt
printcap.c.patch.txt
test_setattr.c.patch.txt
meson.build.patch.txt

Added in 6fb804c.