diff --git a/root-packages/libfuse3/build.sh b/root-packages/libfuse3/build.sh new file mode 100644 index 000000000..859c4a72f --- /dev/null +++ b/root-packages/libfuse3/build.sh @@ -0,0 +1,16 @@ +TERMUX_PKG_HOMEPAGE=https://github.com/libfuse/libfuse +TERMUX_PKG_DESCRIPTION="FUSE (Filesystem in Userspace) is an interface for userspace programs to export a filesystem to the Linux kernel" +TERMUX_PKG_LICENSE="LGPL-2.1, GPL-2.0" +TERMUX_PKG_MAINTAINER="Henrik Grimler @Grimler91" +TERMUX_PKG_VERSION=3.9.1 +TERMUX_PKG_SRCURL=https://github.com/libfuse/libfuse/archive/fuse-${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_SHA256=4f3dea4979c30fbd85f46b8812bee5945bd6bb4487165eb01ecde57bbfbb332f + +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +-Ddisable-mtab=true +-Dexamples=false +-Dsbindir=bin +-Dmandir=share/man +-Dudevrulesdir=$TERMUX_PREFIX/etc/udev/rules.d +-Duseroot=false +" diff --git a/root-packages/libfuse3/fuse.c.patch b/root-packages/libfuse3/fuse.c.patch new file mode 100644 index 000000000..af8bc8fc5 --- /dev/null +++ b/root-packages/libfuse3/fuse.c.patch @@ -0,0 +1,40 @@ +--- a/lib/fuse.c ++++ b/lib/fuse.c +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include + + #define FUSE_NODE_SLAB 1 + +@@ -128,6 +129,7 @@ struct fuse { + struct list_head partial_slabs; + struct list_head full_slabs; + pthread_t prune_thread; ++ atomic_flag cancel; + }; + + struct lock { +@@ -4843,9 +4845,12 @@ static void *fuse_prune_nodes(void *fuse) + { + struct fuse *f = fuse; + int sleep_time; ++ atomic_flag_clear(&f->cancel); + + while(1) { + sleep_time = fuse_clean_cache(f); ++ if (atomic_flag_test_and_set(&f->cancel)) pthread_exit(NULL); ++ atomic_flag_clear(&f->cancel); + sleep(sleep_time); + } + return NULL; +@@ -4863,7 +4868,7 @@ void fuse_stop_cleanup_thread(struct fuse *f) + { + if (lru_enabled(f)) { + pthread_mutex_lock(&f->lock); +- pthread_cancel(f->prune_thread); ++ atomic_flag_test_and_set(&f->cancel); + pthread_mutex_unlock(&f->lock); + pthread_join(f->prune_thread, NULL); + } diff --git a/root-packages/libfuse3/fuse_i.h.patch b/root-packages/libfuse3/fuse_i.h.patch new file mode 100644 index 000000000..70112bdbe --- /dev/null +++ b/root-packages/libfuse3/fuse_i.h.patch @@ -0,0 +1,19 @@ +--- a/lib/fuse_i.h ++++ b/lib/fuse_i.h +@@ -8,6 +8,7 @@ + + #include "fuse.h" + #include "fuse_lowlevel.h" ++#include + + struct mount_opts; + +@@ -64,6 +65,8 @@ struct fuse_session { + struct fuse_notify_req notify_list; + size_t bufsize; + int error; ++ atomic_flag cancel; ++ int *retval; + }; + + struct fuse_chan { diff --git a/root-packages/libfuse3/fuse_loop_mt.c.patch b/root-packages/libfuse3/fuse_loop_mt.c.patch new file mode 100644 index 000000000..408022c4c --- /dev/null +++ b/root-packages/libfuse3/fuse_loop_mt.c.patch @@ -0,0 +1,45 @@ +--- a/lib/fuse_loop_mt.c ++++ b/lib/fuse_loop_mt.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + /* Environment var controlling the thread stack size */ + #define ENVNAME_THREAD_STACK "FUSE_THREAD_STACK" +@@ -39,6 +40,7 @@ struct fuse_worker { + struct fuse_buf fbuf; + struct fuse_chan *ch; + struct fuse_mt *mt; ++ atomic_flag cancel; + }; + + struct fuse_mt { +@@ -118,14 +120,15 @@ static void *fuse_do_work(void *data) + { + struct fuse_worker *w = (struct fuse_worker *) data; + struct fuse_mt *mt = w->mt; ++ atomic_flag_clear(&w->cancel); + + while (!fuse_session_exited(mt->se)) { + int isforget = 0; + int res; + +- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); ++ if (atomic_flag_test_and_set(&w->cancel)) pthread_exit(NULL); ++ atomic_flag_clear(&w->cancel); + res = fuse_session_receive_buf_int(mt->se, &w->fbuf, w->ch); +- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); + if (res == -EINTR) + continue; + if (res <= 0) { +@@ -333,7 +336,7 @@ int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *co + + pthread_mutex_lock(&mt.lock); + for (w = mt.main.next; w != &mt.main; w = w->next) +- pthread_cancel(w->thread_id); ++ atomic_flag_test_and_set(&w->cancel); + mt.exit = 1; + pthread_mutex_unlock(&mt.lock); + diff --git a/root-packages/libfuse3/install_helper.sh.patch b/root-packages/libfuse3/install_helper.sh.patch new file mode 100644 index 000000000..939dccebd --- /dev/null +++ b/root-packages/libfuse3/install_helper.sh.patch @@ -0,0 +1,12 @@ +diff -uNr libfuse-fuse-3.9.1/util/install_helper.sh libfuse-fuse-3.9.1.mod/util/install_helper.sh +--- libfuse-fuse-3.9.1/util/install_helper.sh 2020-03-19 22:00:41.000000000 +0200 ++++ libfuse-fuse-3.9.1.mod/util/install_helper.sh 2020-08-11 20:45:23.479917234 +0300 +@@ -26,6 +26,8 @@ + install -D -m 644 "${MESON_SOURCE_ROOT}/util/fuse.conf" \ + "${DESTDIR}${sysconfdir}/fuse.conf" + ++exit 0 ++ + if $useroot; then + chown root:root "${DESTDIR}${bindir}/fusermount3" + chmod u+s "${DESTDIR}${bindir}/fusermount3" diff --git a/root-packages/libfuse3/meson.build.patch b/root-packages/libfuse3/meson.build.patch new file mode 100644 index 000000000..0617b734c --- /dev/null +++ b/root-packages/libfuse3/meson.build.patch @@ -0,0 +1,47 @@ +diff -uNr libfuse-fuse-3.9.1/lib/meson.build libfuse-fuse-3.9.1.mod/lib/meson.build +--- libfuse-fuse-3.9.1/lib/meson.build 2020-03-19 22:00:41.000000000 +0200 ++++ libfuse-fuse-3.9.1.mod/lib/meson.build 2020-08-11 20:32:33.806112774 +0300 +@@ -4,11 +4,7 @@ + 'helper.c', 'modules/subdir.c', 'mount_util.c', + 'fuse_log.c' ] + +-if host_machine.system().startswith('linux') +- libfuse_sources += [ 'mount.c' ] +-else +- libfuse_sources += [ 'mount_bsd.c' ] +-endif ++libfuse_sources += [ 'mount.c' ] + + deps = [ thread_dep ] + if cfg.get('HAVE_ICONV') +@@ -27,9 +23,6 @@ + if host_machine.system().startswith('netbsd') + deps += [ cc.find_library('perfuse'), + cc.find_library('puffs') ] +-else +- # Required for clock_gettime before glibc 2.17 +- deps += cc.find_library('rt') + endif + + fusermount_path = join_paths(get_option('prefix'), get_option('bindir')) +@@ -43,7 +36,7 @@ + + '/fuse_versionscript' ]) + + pkg = import('pkgconfig') +-pkg.generate(libraries: [ libfuse, '-lpthread' ], ++pkg.generate(libraries: [ libfuse, '-lc' ], + libraries_private: '-ldl', + version: meson.project_version(), + name: 'fuse3', +diff -uNr libfuse-fuse-3.9.1/meson.build libfuse-fuse-3.9.1.mod/meson.build +--- libfuse-fuse-3.9.1/meson.build 2020-03-19 22:00:41.000000000 +0200 ++++ libfuse-fuse-3.9.1.mod/meson.build 2020-08-11 20:32:23.502040209 +0300 +@@ -96,7 +96,7 @@ + # + # Read build files from sub-directories + # +-subdirs = [ 'lib', 'include', 'test' ] ++subdirs = [ 'lib', 'include' ] + if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly' + subdirs += [ 'util', 'doc' ] + endif diff --git a/root-packages/libfuse3/poll.c.patch b/root-packages/libfuse3/poll.c.patch new file mode 100644 index 000000000..1403e7304 --- /dev/null +++ b/root-packages/libfuse3/poll.c.patch @@ -0,0 +1,55 @@ +--- a/example/poll.c ++++ b/example/poll.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + + /* + * fsel_open_mask is used to limit the number of opens to 1 per file. +@@ -220,7 +221,8 @@ static void *fsel_producer(void *data) + const struct timespec interval = { 0, 250000000 }; + unsigned idx = 0, nr = 1; + +- (void) data; ++ atomic_flag *cancel = (atomic_flag *) data; ++ atomic_flag_clear(cancel); + + while (1) { + int i, t; +@@ -257,6 +259,8 @@ static void *fsel_producer(void *data) + + pthread_mutex_unlock(&fsel_mutex); + ++ if (atomic_flag_test_and_set(cancel)) pthread_exit(NULL); ++ atomic_flag_clear(cancel); + nanosleep(&interval, NULL); + } + +@@ -268,6 +272,7 @@ int main(int argc, char *argv[]) + pthread_t producer; + pthread_attr_t attr; + int ret; ++ atomic_flag cancel; + + errno = pthread_mutex_init(&fsel_mutex, NULL); + if (errno) { +@@ -281,7 +286,7 @@ int main(int argc, char *argv[]) + return 1; + } + +- errno = pthread_create(&producer, &attr, fsel_producer, NULL); ++ errno = pthread_create(&producer, &attr, fsel_producer, (void *)&cancel); + if (errno) { + perror("pthread_create"); + return 1; +@@ -289,7 +294,7 @@ int main(int argc, char *argv[]) + + ret = fuse_main(argc, argv, &fsel_oper, NULL); + +- pthread_cancel(producer); ++ atomic_flag_test_and_set(&cancel); + pthread_join(producer, NULL); + + return ret; diff --git a/root-packages/libfuse3/printcap.c.patch b/root-packages/libfuse3/printcap.c.patch new file mode 100644 index 000000000..ad45c7c08 --- /dev/null +++ b/root-packages/libfuse3/printcap.c.patch @@ -0,0 +1,11 @@ +--- a/example/printcap.c ++++ b/example/printcap.c +@@ -95,7 +95,7 @@ int main(int argc, char **argv) + char *mountpoint; + int ret = -1; + +- mountpoint = strdup("/tmp/fuse_printcap_XXXXXX"); ++ mountpoint = strdup("/data/data/com.termux/files/usr/tmp/fuse_printcap_XXXXXX"); + if(mkdtemp(mountpoint) == NULL) { + perror("mkdtemp"); + return 1; diff --git a/root-packages/libfuse3/test_setattr.c.patch b/root-packages/libfuse3/test_setattr.c.patch new file mode 100644 index 000000000..5cebb99d8 --- /dev/null +++ b/root-packages/libfuse3/test_setattr.c.patch @@ -0,0 +1,44 @@ +--- a/test/test_setattr.c ++++ b/test/test_setattr.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + #ifndef __linux__ + #include +@@ -128,6 +129,15 @@ static struct fuse_lowlevel_ops tfs_oper = { + static void* run_fs(void *data) { + struct fuse_session *se = (struct fuse_session*) data; + assert(fuse_session_loop(se) == 0); ++ ++ if (atomic_flag_test_and_set(&se->cancel)) { ++ *se->retval = 1; ++ pthread_exit((void *)se->retval); ++ } ++ ++ atomic_flag_clear(&se->cancel); ++ *se->retval = 0; ++ + return NULL; + } + +@@ -164,13 +174,16 @@ int main(int argc, char *argv[]) { + assert(fuse_session_mount(se, fuse_opts.mountpoint) == 0); + + /* Start file-system thread */ ++ atomic_flag_test_and_set(&se->cancel); + assert(pthread_create(&fs_thread, NULL, run_fs, (void *)se) == 0); + + /* Do test */ + test_fs(fuse_opts.mountpoint); + + /* Stop file system */ +- assert(pthread_cancel(fs_thread) == 0); ++ assert(pthread_join(fs_thread, (void **)&se->retval) == 0); ++ assert(*se->retval == 1); ++ assert(atomic_flag_test_and_set(&se->cancel) == 1); + + fuse_session_unmount(se); + assert(got_fh == 1);