new package: libfuse2

This commit is contained in:
Leonid Pliushch 2020-08-11 21:00:03 +03:00 committed by Yaksh Bariya
parent 2cdcb3983c
commit f057cfa9aa
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
3 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,25 @@
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=2.9.9
TERMUX_PKG_SRCURL=https://github.com/libfuse/libfuse/archive/fuse-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=e57a24721177c3b3dd71cb9239ca46b4dee283db9388d48f7ccd256184982194
TERMUX_PKG_DEPENDS="libiconv"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-example
--disable-mtab
"
TERMUX_PKG_RM_AFTER_INSTALL="
etc/init.d
etc/udev
"
termux_step_pre_configure() {
export MOUNT_FUSE_PATH=$TERMUX_PREFIX/bin
export UDEV_RULES_PATH=$TERMUX_PREFIX/etc/udev/rules.d
export INIT_D_PATH=$TERMUX_PREFIX/etc/init.d
./makeconf.sh
}

View File

@ -0,0 +1,42 @@
diff --git a/lib/fuse.c b/../fuse.c
index d1d873a..c3ddf68 100644
--- a/lib/fuse.c
+++ b/../fuse.c
@@ -38,6 +38,7 @@
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/file.h>
+#include <stdatomic.h>
#define FUSE_NODE_SLAB 1
@@ -153,6 +154,7 @@ struct fuse {
struct list_head partial_slabs;
struct list_head full_slabs;
pthread_t prune_thread;
+ atomic_flag cancel;
};
struct lock {
@@ -4637,9 +4639,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;
@@ -4657,7 +4662,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);
}

View File

@ -0,0 +1,49 @@
diff --git a/lib/fuse_loop_mt.c b/../fuse_loop_mt.c
index 82e3001..005639a 100644
--- a/lib/fuse_loop_mt.c
+++ b/../fuse_loop_mt.c
@@ -19,6 +19,7 @@
#include <semaphore.h>
#include <errno.h>
#include <sys/time.h>
+#include <stdatomic.h>
/* Environment var controlling the thread stack size */
#define ENVNAME_THREAD_STACK "FUSE_THREAD_STACK"
@@ -30,6 +31,7 @@ struct fuse_worker {
size_t bufsize;
char *buf;
struct fuse_mt *mt;
+ atomic_flag cancel;
};
struct fuse_mt {
@@ -67,6 +69,7 @@ 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;
@@ -77,9 +80,9 @@ static void *fuse_do_work(void *data)
};
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(mt->se, &fbuf, &ch);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if (res == -EINTR)
continue;
if (res <= 0) {
@@ -243,7 +246,7 @@ int fuse_session_loop_mt(struct fuse_session *se)
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);