aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Android.mk51
-rw-r--r--lib/buffer.c2
-rw-r--r--lib/fuse.c33
-rw-r--r--lib/fuse_loop_mt.c31
-rw-r--r--lib/fuse_mt.c2
-rw-r--r--lib/fuse_session.c9
-rw-r--r--lib/fuse_versionscript3
-rw-r--r--lib/helper.c6
-rw-r--r--lib/mount.c4
-rw-r--r--lib/mount_util.c5
10 files changed, 133 insertions, 13 deletions
diff --git a/lib/Android.mk b/lib/Android.mk
new file mode 100644
index 0000000..a2b1231
--- /dev/null
+++ b/lib/Android.mk
@@ -0,0 +1,51 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ ../android/statvfs.c \
+ buffer.c \
+ cuse_lowlevel.c \
+ fuse.c \
+ fuse_kern_chan.c \
+ fuse_loop.c \
+ fuse_loop_mt.c \
+ fuse_lowlevel.c \
+ fuse_mt.c fuse_opt.c \
+ fuse_session.c \
+ fuse_signals.c \
+ helper.c \
+ mount.c \
+ mount_util.c \
+ ulockmgr.c
+
+LOCAL_C_INCLUDES := \
+ external/fuse/android \
+ external/fuse/include
+
+LOCAL_SHARED_LIBRARIES := \
+ libutils libdl
+
+LOCAL_CFLAGS := \
+ -D_FILE_OFFSET_BITS=64 \
+ -DFUSE_USE_VERSION=26
+
+LOCAL_MODULE := libfuse
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
diff --git a/lib/buffer.c b/lib/buffer.c
index 17a595c..0078e11 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -45,7 +45,7 @@ static ssize_t fuse_buf_write(const struct fuse_buf *dst, size_t dst_off,
while (len) {
if (dst->flags & FUSE_BUF_FD_SEEK) {
- res = pwrite(dst->fd, src->mem + src_off, len,
+ res = pwrite64(dst->fd, src->mem + src_off, len,
dst->pos + dst_off);
} else {
res = write(dst->fd, src->mem + src_off, len);
diff --git a/lib/fuse.c b/lib/fuse.c
index 067d0dc..e456515 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -4558,11 +4558,30 @@ static int node_table_init(struct node_table *t)
return 0;
}
+static void thread_exit_handler(int sig)
+{
+ pthread_exit(0);
+}
+
static void *fuse_prune_nodes(void *fuse)
{
struct fuse *f = fuse;
int sleep_time;
+#if defined(__ANDROID__)
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_exit_handler;
+ sigaction(SIGUSR1, &actions, NULL);
+
+ sigset_t setusr1;
+ sigemptyset(&setusr1);
+ sigaddset(&setusr1, SIGUSR1);
+ pthread_sigmask(SIG_BLOCK, &setusr1, NULL);
+#endif
+
while(1) {
sleep_time = fuse_clean_cache(f);
sleep(sleep_time);
@@ -4582,7 +4601,11 @@ void fuse_stop_cleanup_thread(struct fuse *f)
{
if (lru_enabled(f)) {
pthread_mutex_lock(&f->lock);
+#if defined(__ANDROID__)
+ pthread_kill(f->prune_thread, SIGUSR1);
+#else
pthread_cancel(f->prune_thread);
+#endif
pthread_mutex_unlock(&f->lock);
pthread_join(f->prune_thread, NULL);
}
@@ -4873,11 +4896,11 @@ struct fuse *fuse_new_compat1(int fd, int flags,
11);
}
-FUSE_SYMVER(".symver fuse_exited,__fuse_exited@");
-FUSE_SYMVER(".symver fuse_process_cmd,__fuse_process_cmd@");
-FUSE_SYMVER(".symver fuse_read_cmd,__fuse_read_cmd@");
-FUSE_SYMVER(".symver fuse_set_getcontext_func,__fuse_set_getcontext_func@");
-FUSE_SYMVER(".symver fuse_new_compat2,fuse_new@");
+FUSE_SYMVER(".symver fuse_exited,__fuse_exited@FUSE_UNVERSIONED");
+FUSE_SYMVER(".symver fuse_process_cmd,__fuse_process_cmd@FUSE_UNVERSIONED");
+FUSE_SYMVER(".symver fuse_read_cmd,__fuse_read_cmd@FUSE_UNVERSIONED");
+FUSE_SYMVER(".symver fuse_set_getcontext_func,__fuse_set_getcontext_func@FUSE_UNVERSIONED");
+FUSE_SYMVER(".symver fuse_new_compat2,fuse_new@FUSE_UNVERSIONED");
FUSE_SYMVER(".symver fuse_new_compat22,fuse_new@FUSE_2.2");
#endif /* __FreeBSD__ || __NetBSD__ */
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c
index 82e3001..90fc1e6 100644
--- a/lib/fuse_loop_mt.c
+++ b/lib/fuse_loop_mt.c
@@ -63,11 +63,30 @@ static void list_del_worker(struct fuse_worker *w)
static int fuse_loop_start_thread(struct fuse_mt *mt);
+static void thread_exit_handler(int sig)
+{
+ pthread_exit(0);
+}
+
static void *fuse_do_work(void *data)
{
struct fuse_worker *w = (struct fuse_worker *) data;
struct fuse_mt *mt = w->mt;
+#if defined(__ANDROID__)
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_exit_handler;
+ sigaction(SIGUSR1, &actions, NULL);
+
+ sigset_t setusr1;
+ sigemptyset(&setusr1);
+ sigaddset(&setusr1, SIGUSR1);
+ pthread_sigmask(SIG_BLOCK, &setusr1, NULL);
+#endif
+
while (!fuse_session_exited(mt->se)) {
int isforget = 0;
struct fuse_chan *ch = mt->prevch;
@@ -77,9 +96,17 @@ static void *fuse_do_work(void *data)
};
int res;
+#if defined(__ANDROID__)
+ pthread_sigmask(SIG_UNBLOCK, &setusr1, NULL);
+#else
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+#endif
res = fuse_session_receive_buf(mt->se, &fbuf, &ch);
+#if defined(__ANDROID__)
+ pthread_sigmask(SIG_BLOCK, &setusr1, NULL);
+#else
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+#endif
if (res == -EINTR)
continue;
if (res <= 0) {
@@ -243,7 +270,11 @@ 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)
+#if defined(__ANDROID__)
+ pthread_kill(w->thread_id, SIGUSR1);
+#else
pthread_cancel(w->thread_id);
+#endif
mt.exit = 1;
pthread_mutex_unlock(&mt.lock);
diff --git a/lib/fuse_mt.c b/lib/fuse_mt.c
index f6dbe71..fd5ac23 100644
--- a/lib/fuse_mt.c
+++ b/lib/fuse_mt.c
@@ -119,4 +119,4 @@ int fuse_loop_mt(struct fuse *f)
return res;
}
-FUSE_SYMVER(".symver fuse_loop_mt_proc,__fuse_loop_mt@");
+FUSE_SYMVER(".symver fuse_loop_mt_proc,__fuse_loop_mt@FUSE_UNVERSIONED");
diff --git a/lib/fuse_session.c b/lib/fuse_session.c
index 6e11068..18c8c42 100644
--- a/lib/fuse_session.c
+++ b/lib/fuse_session.c
@@ -184,9 +184,12 @@ int fuse_chan_fd(struct fuse_chan *ch)
int fuse_chan_clearfd(struct fuse_chan *ch)
{
- int fd = ch->fd;
- ch->fd = -1;
- return fd;
+ if (ch == NULL)
+ return -1;
+
+ int fd = ch->fd;
+ ch->fd = -1;
+ return fd;
}
size_t fuse_chan_bufsize(struct fuse_chan *ch)
diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
index 8d91887..de16ab2 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -1,3 +1,6 @@
+FUSE_UNVERSIONED {
+};
+
FUSE_2.2 {
global:
fuse_destroy;
diff --git a/lib/helper.c b/lib/helper.c
index b644012..c5349bf 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -436,10 +436,10 @@ int fuse_mount_compat1(const char *mountpoint, const char *args[])
return fuse_mount_compat22(mountpoint, NULL);
}
-FUSE_SYMVER(".symver fuse_setup_compat2,__fuse_setup@");
+FUSE_SYMVER(".symver fuse_setup_compat2,__fuse_setup@FUSE_UNVERSIONED");
FUSE_SYMVER(".symver fuse_setup_compat22,fuse_setup@FUSE_2.2");
-FUSE_SYMVER(".symver fuse_teardown,__fuse_teardown@");
-FUSE_SYMVER(".symver fuse_main_compat2,fuse_main@");
+FUSE_SYMVER(".symver fuse_teardown,__fuse_teardown@FUSE_UNVERSIONED");
+FUSE_SYMVER(".symver fuse_main_compat2,fuse_main@FUSE_UNVERSIONED");
FUSE_SYMVER(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");
#endif /* __FreeBSD__ || __NetBSD__ */
diff --git a/lib/mount.c b/lib/mount.c
index 0f767c8..2a557c6 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -42,6 +42,10 @@
#define FUSERMOUNT_PROG "fusermount"
#define FUSE_COMMFD_ENV "_FUSE_COMMFD"
+#if defined(__ANDROID__) && !defined(FUSERMOUNT_DIR)
+# define FUSERMOUNT_DIR "/system/xbin"
+#endif
+
#ifndef HAVE_FORK
#define fork() vfork()
#endif
diff --git a/lib/mount_util.c b/lib/mount_util.c
index 3d2f4cd..e8bd538 100644
--- a/lib/mount_util.c
+++ b/lib/mount_util.c
@@ -23,10 +23,15 @@
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/param.h>
+#if defined(__ANDROID__)
+#include <paths.h>
+#endif
#ifdef __NetBSD__
#define umount2(mnt, flags) unmount(mnt, (flags == 2) ? MNT_FORCE : 0)
#define mtab_needs_update(mnt) 0
+#elif defined(__ANDROID__)
+#define mtab_needs_update(mnt) 0
#else
static int mtab_needs_update(const char *mnt)
{