aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Android.mk20
-rw-r--r--android/config.h87
-rw-r--r--android/statvfs.c48
-rw-r--r--android/sys/statvfs.h39
-rw-r--r--include/cuse_lowlevel.h4
-rw-r--r--include/fuse.h37
-rw-r--r--include/fuse_common.h2
-rw-r--r--include/fuse_compat.h32
-rw-r--r--include/fuse_lowlevel.h20
-rw-r--r--include/fuse_lowlevel_compat.h16
-rw-r--r--include/ulockmgr.h2
-rwxr-xr-xlib/Android.mk67
-rw-r--r--lib/buffer.c27
-rw-r--r--lib/cuse_lowlevel.c4
-rw-r--r--lib/fuse.c92
-rw-r--r--lib/fuse_loop_mt.c31
-rw-r--r--lib/fuse_lowlevel.c20
-rw-r--r--lib/fuse_mt.c4
-rw-r--r--lib/fuse_opt.c2
-rw-r--r--lib/fuse_session.c9
-rw-r--r--lib/fuse_versionscript6
-rw-r--r--lib/helper.c6
-rw-r--r--lib/modules/iconv.c12
-rw-r--r--lib/modules/subdir.c10
-rw-r--r--lib/mount.c4
-rw-r--r--lib/mount_util.c7
-rw-r--r--lib/mount_util.h2
-rw-r--r--lib/ulockmgr.c4
-rw-r--r--test/test.c8
-rw-r--r--util/fusermount.c2
31 files changed, 491 insertions, 134 deletions
diff --git a/.gitignore b/.gitignore
index 65a37c7..d04bdcd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,6 @@ Makefile.in
Makefile
*.m4
stamp-h*
-config.*
/ltmain.sh
/configure
/install-sh
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..a75a53c
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2008 The Android Open Source Project
+# Copyright (C) 2015 The CyanogenMod 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 $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/android/config.h b/android/config.h
new file mode 100644
index 0000000..dac8c16
--- /dev/null
+++ b/android/config.h
@@ -0,0 +1,87 @@
+/* include/config.h. Generated from config.h.in by configure. */
+/* include/config.h.in. Generated from configure.in by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `fdatasync' function. */
+#define HAVE_FDATASYNC 1
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define if you have the iconv() function and it works. */
+#define HAVE_ICONV 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `setxattr' function. */
+#define HAVE_SETXATTR 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if `st_atim' is member of `struct stat'. */
+//#define HAVE_STRUCT_STAT_ST_ATIM 0
+
+/* Define to 1 if `st_atimespec' is member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_ATIMESPEC */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define as const if the declaration of iconv() needs const. */
+#define ICONV_CONST
+
+/* Don't update /etc/mtab */
+/* #undef IGNORE_MTAB */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+#define PACKAGE "fuse"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "fuse"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "fuse 2.9.3"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "fuse"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "2.9.3"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "2.9.3"
diff --git a/android/statvfs.c b/android/statvfs.c
new file mode 100644
index 0000000..7cec574
--- /dev/null
+++ b/android/statvfs.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "sys/statvfs.h"
+#include <sys/statfs.h>
+
+#define MAP(to,from) vfs->to = sfs.from
+
+int statvfs(const char *path, struct statvfs *vfs) {
+ struct statfs sfs;
+ int ret;
+ int *fsid;
+ if ((ret = statfs(path, &sfs)) != 0)
+ return ret;
+
+ MAP(f_bsize, f_bsize);
+ MAP(f_frsize, f_frsize);
+ MAP(f_blocks, f_blocks);
+ MAP(f_bfree, f_bfree);
+ MAP(f_bavail, f_bavail);
+ MAP(f_files, f_files);
+ MAP(f_ffree, f_ffree);
+ MAP(f_namemax, f_namelen);
+
+ vfs->f_favail = 0;
+ vfs->f_flag = 0;
+
+ fsid = (int *)&sfs.f_fsid;
+ vfs->f_fsid = (fsid[0] << sizeof(fsid[0])) | fsid[1];
+
+ return ret;
+}
diff --git a/android/sys/statvfs.h b/android/sys/statvfs.h
new file mode 100644
index 0000000..0d770dd
--- /dev/null
+++ b/android/sys/statvfs.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _SYS_STATVFS_H_
+#define _SYS_STATVFS_H_
+#include <sys/types.h>
+
+struct statvfs {
+ unsigned long f_bsize; /* file system block size */
+ unsigned long f_frsize; /* fragment size */
+ fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
+ fsblkcnt_t f_bfree; /* # free blocks */
+ fsblkcnt_t f_bavail; /* # free blocks for non-root */
+ fsfilcnt_t f_files; /* # inodes */
+ fsfilcnt_t f_ffree; /* # free inodes */
+ fsfilcnt_t f_favail; /* # free inodes for non-root */
+ unsigned long f_fsid; /* file system ID */
+ unsigned long f_flag; /* mount flags */
+ unsigned long f_namemax; /* maximum filename length */
+};
+
+int statvfs(const char *, struct statvfs *);
+#endif
diff --git a/include/cuse_lowlevel.h b/include/cuse_lowlevel.h
index e147fa2..fb445a7 100644
--- a/include/cuse_lowlevel.h
+++ b/include/cuse_lowlevel.h
@@ -51,9 +51,9 @@ struct cuse_lowlevel_ops {
void (*init_done) (void *userdata);
void (*destroy) (void *userdata);
void (*open) (fuse_req_t req, struct fuse_file_info *fi);
- void (*read) (fuse_req_t req, size_t size, off_t off,
+ void (*read) (fuse_req_t req, size_t size, loff_t off,
struct fuse_file_info *fi);
- void (*write) (fuse_req_t req, const char *buf, size_t size, off_t off,
+ void (*write) (fuse_req_t req, const char *buf, size_t size, loff_t off,
struct fuse_file_info *fi);
void (*flush) (fuse_req_t req, struct fuse_file_info *fi);
void (*release) (fuse_req_t req, struct fuse_file_info *fi);
diff --git a/include/fuse.h b/include/fuse.h
index 911a676..b82325e 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -30,6 +30,9 @@
#include <utime.h>
#include <sys/types.h>
#include <sys/stat.h>
+#if defined(__ANDROID__)
+#include <pthread.h>
+#endif
#include <sys/statvfs.h>
#include <sys/uio.h>
@@ -56,7 +59,7 @@ struct fuse_cmd;
* @return 1 if buffer is full, zero otherwise
*/
typedef int (*fuse_fill_dir_t) (void *buf, const char *name,
- const struct stat *stbuf, off_t off);
+ const struct stat *stbuf, loff_t off);
/* Used by deprecated getdir() method */
typedef struct fuse_dirhandle *fuse_dirh_t;
@@ -145,7 +148,7 @@ struct fuse_operations {
int (*chown) (const char *, uid_t, gid_t);
/** Change the size of a file */
- int (*truncate) (const char *, off_t);
+ int (*truncate) (const char *, loff_t);
/** Change the access and/or modification times of a file
*
@@ -183,7 +186,7 @@ struct fuse_operations {
*
* Changed in version 2.2
*/
- int (*read) (const char *, char *, size_t, off_t,
+ int (*read) (const char *, char *, size_t, loff_t,
struct fuse_file_info *);
/** Write data to an open file
@@ -194,7 +197,7 @@ struct fuse_operations {
*
* Changed in version 2.2
*/
- int (*write) (const char *, const char *, size_t, off_t,
+ int (*write) (const char *, const char *, size_t, loff_t,
struct fuse_file_info *);
/** Get file system statistics
@@ -301,7 +304,7 @@ struct fuse_operations {
*
* Introduced in version 2.3
*/
- int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
+ int (*readdir) (const char *, void *, fuse_fill_dir_t, loff_t,
struct fuse_file_info *);
/** Release directory
@@ -379,7 +382,7 @@ struct fuse_operations {
*
* Introduced in version 2.5
*/
- int (*ftruncate) (const char *, off_t, struct fuse_file_info *);
+ int (*ftruncate) (const char *, loff_t, struct fuse_file_info *);
/**
* Get attributes from an open file
@@ -536,7 +539,7 @@ struct fuse_operations {
*
* Introduced in version 2.9
*/
- int (*write_buf) (const char *, struct fuse_bufvec *buf, off_t off,
+ int (*write_buf) (const char *, struct fuse_bufvec *buf, loff_t off,
struct fuse_file_info *);
/** Store data from an open file in a buffer
@@ -556,7 +559,7 @@ struct fuse_operations {
* Introduced in version 2.9
*/
int (*read_buf) (const char *, struct fuse_bufvec **bufp,
- size_t size, off_t off, struct fuse_file_info *);
+ size_t size, loff_t off, struct fuse_file_info *);
/**
* Perform BSD file locking operation
*
@@ -589,7 +592,7 @@ struct fuse_operations {
*
* Introduced in version 2.9.1
*/
- int (*fallocate) (const char *, int, off_t, off_t,
+ int (*fallocate) (const char *, int, loff_t, loff_t,
struct fuse_file_info *);
};
@@ -829,14 +832,14 @@ int fuse_fs_release(struct fuse_fs *fs, const char *path,
int fuse_fs_open(struct fuse_fs *fs, const char *path,
struct fuse_file_info *fi);
int fuse_fs_read(struct fuse_fs *fs, const char *path, char *buf, size_t size,
- off_t off, struct fuse_file_info *fi);
+ loff_t off, struct fuse_file_info *fi);
int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
- struct fuse_bufvec **bufp, size_t size, off_t off,
+ struct fuse_bufvec **bufp, size_t size, loff_t off,
struct fuse_file_info *fi);
int fuse_fs_write(struct fuse_fs *fs, const char *path, const char *buf,
- size_t size, off_t off, struct fuse_file_info *fi);
+ size_t size, loff_t off, struct fuse_file_info *fi);
int fuse_fs_write_buf(struct fuse_fs *fs, const char *path,
- struct fuse_bufvec *buf, off_t off,
+ struct fuse_bufvec *buf, loff_t off,
struct fuse_file_info *fi);
int fuse_fs_fsync(struct fuse_fs *fs, const char *path, int datasync,
struct fuse_file_info *fi);
@@ -846,7 +849,7 @@ int fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf);
int fuse_fs_opendir(struct fuse_fs *fs, const char *path,
struct fuse_file_info *fi);
int fuse_fs_readdir(struct fuse_fs *fs, const char *path, void *buf,
- fuse_fill_dir_t filler, off_t off,
+ fuse_fill_dir_t filler, loff_t off,
struct fuse_file_info *fi);
int fuse_fs_fsyncdir(struct fuse_fs *fs, const char *path, int datasync,
struct fuse_file_info *fi);
@@ -860,8 +863,8 @@ int fuse_fs_flock(struct fuse_fs *fs, const char *path,
struct fuse_file_info *fi, int op);
int fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode);
int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid);
-int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size);
-int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, off_t size,
+int fuse_fs_truncate(struct fuse_fs *fs, const char *path, loff_t size);
+int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, loff_t size,
struct fuse_file_info *fi);
int fuse_fs_utimens(struct fuse_fs *fs, const char *path,
const struct timespec tv[2]);
@@ -887,7 +890,7 @@ int fuse_fs_poll(struct fuse_fs *fs, const char *path,
struct fuse_file_info *fi, struct fuse_pollhandle *ph,
unsigned *reventsp);
int fuse_fs_fallocate(struct fuse_fs *fs, const char *path, int mode,
- off_t offset, off_t length, struct fuse_file_info *fi);
+ loff_t offset, loff_t length, struct fuse_file_info *fi);
void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn);
void fuse_fs_destroy(struct fuse_fs *fs);
diff --git a/include/fuse_common.h b/include/fuse_common.h
index a4d980d..f08778b 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -372,7 +372,7 @@ struct fuse_buf {
*
* Used if FUSE_BUF_FD_SEEK flag is set.
*/
- off_t pos;
+ loff_t pos;
};
/**
diff --git a/include/fuse_compat.h b/include/fuse_compat.h
index e7497a9..b825dee 100644
--- a/include/fuse_compat.h
+++ b/include/fuse_compat.h
@@ -9,6 +9,8 @@
/* these definitions provide source compatibility to prior versions.
Do not include this file directly! */
+#include "fuse_lowlevel.h"
+
struct fuse_operations_compat25 {
int (*getattr) (const char *, struct stat *);
int (*readlink) (const char *, char *, size_t);
@@ -22,12 +24,12 @@ struct fuse_operations_compat25 {
int (*link) (const char *, const char *);
int (*chmod) (const char *, mode_t);
int (*chown) (const char *, uid_t, gid_t);
- int (*truncate) (const char *, off_t);
+ int (*truncate) (const char *, loff_t);
int (*utime) (const char *, struct utimbuf *);
int (*open) (const char *, struct fuse_file_info *);
- int (*read) (const char *, char *, size_t, off_t,
+ int (*read) (const char *, char *, size_t, loff_t,
struct fuse_file_info *);
- int (*write) (const char *, const char *, size_t, off_t,
+ int (*write) (const char *, const char *, size_t, loff_t,
struct fuse_file_info *);
int (*statfs) (const char *, struct statvfs *);
int (*flush) (const char *, struct fuse_file_info *);
@@ -38,7 +40,7 @@ struct fuse_operations_compat25 {
int (*listxattr) (const char *, char *, size_t);
int (*removexattr) (const char *, const char *);
int (*opendir) (const char *, struct fuse_file_info *);
- int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
+ int (*readdir) (const char *, void *, fuse_fill_dir_t, loff_t,
struct fuse_file_info *);
int (*releasedir) (const char *, struct fuse_file_info *);
int (*fsyncdir) (const char *, int, struct fuse_file_info *);
@@ -46,7 +48,7 @@ struct fuse_operations_compat25 {
void (*destroy) (void *);
int (*access) (const char *, int);
int (*create) (const char *, mode_t, struct fuse_file_info *);
- int (*ftruncate) (const char *, off_t, struct fuse_file_info *);
+ int (*ftruncate) (const char *, loff_t, struct fuse_file_info *);
int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *);
};
@@ -81,12 +83,12 @@ struct fuse_operations_compat22 {
int (*link) (const char *, const char *);
int (*chmod) (const char *, mode_t);
int (*chown) (const char *, uid_t, gid_t);
- int (*truncate) (const char *, off_t);
+ int (*truncate) (const char *, loff_t);
int (*utime) (const char *, struct utimbuf *);
int (*open) (const char *, struct fuse_file_info_compat *);
- int (*read) (const char *, char *, size_t, off_t,
+ int (*read) (const char *, char *, size_t, loff_t,
struct fuse_file_info_compat *);
- int (*write) (const char *, const char *, size_t, off_t,
+ int (*write) (const char *, const char *, size_t, loff_t,
struct fuse_file_info_compat *);
int (*statfs) (const char *, struct statfs *);
int (*flush) (const char *, struct fuse_file_info_compat *);
@@ -97,7 +99,7 @@ struct fuse_operations_compat22 {
int (*listxattr) (const char *, char *, size_t);
int (*removexattr) (const char *, const char *);
int (*opendir) (const char *, struct fuse_file_info_compat *);
- int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
+ int (*readdir) (const char *, void *, fuse_fill_dir_t, loff_t,
struct fuse_file_info_compat *);
int (*releasedir) (const char *, struct fuse_file_info_compat *);
int (*fsyncdir) (const char *, int, struct fuse_file_info_compat *);
@@ -132,11 +134,11 @@ struct fuse_operations_compat2 {
int (*link) (const char *, const char *);
int (*chmod) (const char *, mode_t);
int (*chown) (const char *, uid_t, gid_t);
- int (*truncate) (const char *, off_t);
+ int (*truncate) (const char *, loff_t);
int (*utime) (const char *, struct utimbuf *);
int (*open) (const char *, int);
- int (*read) (const char *, char *, size_t, off_t);
- int (*write) (const char *, const char *, size_t, off_t);
+ int (*read) (const char *, char *, size_t, loff_t);
+ int (*write) (const char *, const char *, size_t, loff_t);
int (*statfs) (const char *, struct statfs *);
int (*flush) (const char *);
int (*release) (const char *, int);
@@ -180,11 +182,11 @@ struct fuse_operations_compat1 {
int (*link) (const char *, const char *);
int (*chmod) (const char *, mode_t);
int (*chown) (const char *, uid_t, gid_t);
- int (*truncate) (const char *, off_t);
+ int (*truncate) (const char *, loff_t);
int (*utime) (const char *, struct utimbuf *);
int (*open) (const char *, int);
- int (*read) (const char *, char *, size_t, off_t);
- int (*write) (const char *, const char *, size_t, off_t);
+ int (*read) (const char *, char *, size_t, loff_t);
+ int (*write) (const char *, const char *, size_t, loff_t);
int (*statfs) (struct fuse_statfs_compat1 *);
int (*release) (const char *, int);
int (*fsync) (const char *, int);
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index 8262d38..26dc429 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -462,7 +462,7 @@ struct fuse_lowlevel_ops {
* @param off offset to read from
* @param fi file information
*/
- void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, loff_t off,
struct fuse_file_info *fi);
/**
@@ -489,7 +489,7 @@ struct fuse_lowlevel_ops {
* @param fi file information
*/
void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf,
- size_t size, off_t off, struct fuse_file_info *fi);
+ size_t size, loff_t off, struct fuse_file_info *fi);
/**
* Flush method
@@ -612,7 +612,7 @@ struct fuse_lowlevel_ops {
* @param off offset to continue reading the directory stream
* @param fi file information
*/
- void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, loff_t off,
struct fuse_file_info *fi);
/**
@@ -946,7 +946,7 @@ struct fuse_lowlevel_ops {
* @param fi file information
*/
void (*write_buf) (fuse_req_t req, fuse_ino_t ino,
- struct fuse_bufvec *bufv, off_t off,
+ struct fuse_bufvec *bufv, loff_t off,
struct fuse_file_info *fi);
/**
@@ -964,7 +964,7 @@ struct fuse_lowlevel_ops {
* @param bufv the buffer containing the returned data
*/
void (*retrieve_reply) (fuse_req_t req, void *cookie, fuse_ino_t ino,
- off_t offset, struct fuse_bufvec *bufv);
+ loff_t offset, struct fuse_bufvec *bufv);
/**
* Forget about multiple inodes
@@ -1020,7 +1020,7 @@ struct fuse_lowlevel_ops {
* see fallocate(2)
*/
void (*fallocate) (fuse_req_t req, fuse_ino_t ino, int mode,
- off_t offset, off_t length, struct fuse_file_info *fi);
+ loff_t offset, loff_t length, struct fuse_file_info *fi);
};
/**
@@ -1254,7 +1254,7 @@ int fuse_reply_bmap(fuse_req_t req, uint64_t idx);
*/
size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
const char *name, const struct stat *stbuf,
- off_t off);
+ loff_t off);
/**
* Reply to ask for data fetch and output buffer preparation. ioctl
@@ -1334,7 +1334,7 @@ int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph);
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, fuse_ino_t ino,
- off_t off, off_t len);
+ loff_t off, loff_t len);
/**
* Notify to invalidate parent attributes and the dentry matching
@@ -1395,7 +1395,7 @@ int fuse_lowlevel_notify_delete(struct fuse_chan *ch,
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_store(struct fuse_chan *ch, fuse_ino_t ino,
- off_t offset, struct fuse_bufvec *bufv,
+ loff_t offset, struct fuse_bufvec *bufv,
enum fuse_buf_copy_flags flags);
/**
* Retrieve data from the kernel buffers
@@ -1423,7 +1423,7 @@ int fuse_lowlevel_notify_store(struct fuse_chan *ch, fuse_ino_t ino,
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_retrieve(struct fuse_chan *ch, fuse_ino_t ino,
- size_t size, off_t offset, void *cookie);
+ size_t size, loff_t offset, void *cookie);
/* ----------------------------------------------------------- *
diff --git a/include/fuse_lowlevel_compat.h b/include/fuse_lowlevel_compat.h
index 8de220b..f13adbd 100644
--- a/include/fuse_lowlevel_compat.h
+++ b/include/fuse_lowlevel_compat.h
@@ -9,6 +9,8 @@
/* these definitions provide source compatibility to prior versions.
Do not include this file directly! */
+#include "fuse_common.h"
+
struct fuse_lowlevel_ops_compat25 {
void (*init) (void *userdata);
void (*destroy) (void *userdata);
@@ -33,10 +35,10 @@ struct fuse_lowlevel_ops_compat25 {
const char *newname);
void (*open) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi);
- void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, loff_t off,
struct fuse_file_info *fi);
void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf,
- size_t size, off_t off, struct fuse_file_info *fi);
+ size_t size, loff_t off, struct fuse_file_info *fi);
void (*flush) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi);
void (*release) (fuse_req_t req, fuse_ino_t ino,
@@ -45,7 +47,7 @@ struct fuse_lowlevel_ops_compat25 {
struct fuse_file_info *fi);
void (*opendir) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi);
- void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, loff_t off,
struct fuse_file_info *fi);
void (*releasedir) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi);
@@ -70,7 +72,7 @@ struct fuse_session *fuse_lowlevel_new_compat25(struct fuse_args *args,
size_t fuse_dirent_size(size_t namelen);
char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
- off_t off);
+ loff_t off);
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
@@ -100,10 +102,10 @@ struct fuse_lowlevel_ops_compat {
const char *newname);
void (*open) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info_compat *fi);
- void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, loff_t off,
struct fuse_file_info_compat *fi);
void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf,
- size_t size, off_t off, struct fuse_file_info_compat *fi);
+ size_t size, loff_t off, struct fuse_file_info_compat *fi);
void (*flush) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info_compat *fi);
void (*release) (fuse_req_t req, fuse_ino_t ino,
@@ -112,7 +114,7 @@ struct fuse_lowlevel_ops_compat {
struct fuse_file_info_compat *fi);
void (*opendir) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info_compat *fi);
- void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, loff_t off,
struct fuse_file_info_compat *fi);
void (*releasedir) (fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info_compat *fi);
diff --git a/include/ulockmgr.h b/include/ulockmgr.h
index ad55579..c3ceef5 100644
--- a/include/ulockmgr.h
+++ b/include/ulockmgr.h
@@ -6,6 +6,8 @@
See the file COPYING.LIB.
*/
+#include "fuse_lowlevel.h"
+
#include <stdint.h>
#include <fcntl.h>
#include <sys/types.h>
diff --git a/lib/Android.mk b/lib/Android.mk
new file mode 100755
index 0000000..fd191ec
--- /dev/null
+++ b/lib/Android.mk
@@ -0,0 +1,67 @@
+# 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)
+
+common_src_files := \
+ 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
+
+common_c_includes := \
+ external/fuse/android \
+ external/fuse/include
+
+common_shared_libraries := \
+ libutils
+
+common_cflags := \
+ -D_FILE_OFFSET_BITS=64 \
+ -DFUSE_USE_VERSION=26 \
+ -fno-strict-aliasing
+
+common_ldflags := \
+ -Wl,--version-script,$(LOCAL_PATH)/fuse_versionscript
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libfuse
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(common_src_files)
+LOCAL_C_INCLUDES := $(common_c_includes)
+LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
+LOCAL_CFLAGS := $(common_cflags) -fPIC
+LOCAL_LDFLAGS := $(common_ldflags)
+LOCAL_CLANG := true
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libfuse_static
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(common_src_files)
+LOCAL_C_INCLUDES := $(common_c_includes)
+LOCAL_STATIC_LIBRARIES := $(common_shared_libraries)
+LOCAL_CFLAGS := $(common_cflags)
+LOCAL_CLANG := true
+include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/buffer.c b/lib/buffer.c
index 17a595c..b2dd47c 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -45,10 +45,10 @@ 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, (const intptr_t *)src->mem + src_off, len,
dst->pos + dst_off);
} else {
- res = write(dst->fd, src->mem + src_off, len);
+ res = write(dst->fd, (const intptr_t *)src->mem + src_off, len);
}
if (res == -1) {
if (!copied)
@@ -79,10 +79,10 @@ static ssize_t fuse_buf_read(const struct fuse_buf *dst, size_t dst_off,
while (len) {
if (src->flags & FUSE_BUF_FD_SEEK) {
- res = pread(src->fd, dst->mem + dst_off, len,
+ res = pread(src->fd, (intptr_t *)dst->mem + dst_off, len,
src->pos + src_off);
} else {
- res = read(src->fd, dst->mem + dst_off, len);
+ res = read(src->fd, (intptr_t *)dst->mem + dst_off, len);
}
if (res == -1) {
if (!copied)
@@ -119,7 +119,7 @@ static ssize_t fuse_buf_fd_to_fd(const struct fuse_buf *dst, size_t dst_off,
tmp.mem = buf;
while (len) {
- size_t this_len = min_size(tmp.size, len);
+ ssize_t this_len = min_size(tmp.size, len);
size_t read_len;
res = fuse_buf_read(&tmp, 0, src, src_off, this_len);
@@ -160,10 +160,10 @@ static ssize_t fuse_buf_splice(const struct fuse_buf *dst, size_t dst_off,
size_t len, enum fuse_buf_copy_flags flags)
{
int splice_flags = 0;
- off_t *srcpos = NULL;
- off_t *dstpos = NULL;
- off_t srcpos_val;
- off_t dstpos_val;
+ loff_t *srcpos = NULL;
+ loff_t *dstpos = NULL;
+ loff_t srcpos_val;
+ loff_t dstpos_val;
ssize_t res;
size_t copied = 0;
@@ -229,11 +229,12 @@ static ssize_t fuse_buf_copy_one(const struct fuse_buf *dst, size_t dst_off,
int dst_is_fd = dst->flags & FUSE_BUF_IS_FD;
if (!src_is_fd && !dst_is_fd) {
- void *dstmem = dst->mem + dst_off;
- void *srcmem = src->mem + src_off;
+ void *dstmem = (intptr_t *)dst->mem + dst_off;
+ void *srcmem = (intptr_t *)src->mem + src_off;
if (dstmem != srcmem) {
- if (dstmem + len <= srcmem || srcmem + len <= dstmem)
+ if ((intptr_t *)dstmem + len <= (intptr_t *)srcmem
+ || (intptr_t *)srcmem + len <= (intptr_t *)dstmem)
memcpy(dstmem, srcmem, len);
else
memmove(dstmem, srcmem, len);
@@ -288,7 +289,7 @@ ssize_t fuse_buf_copy(struct fuse_bufvec *dstv, struct fuse_bufvec *srcv,
const struct fuse_buf *dst = fuse_bufvec_current(dstv);
size_t src_len;
size_t dst_len;
- size_t len;
+ ssize_t len;
ssize_t res;
if (src == NULL || dst == NULL)
diff --git a/lib/cuse_lowlevel.c b/lib/cuse_lowlevel.c
index 402cf4b..ae08ed4 100644
--- a/lib/cuse_lowlevel.c
+++ b/lib/cuse_lowlevel.c
@@ -43,14 +43,14 @@ static void cuse_fll_open(fuse_req_t req, fuse_ino_t ino,
}
static void cuse_fll_read(fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t off, struct fuse_file_info *fi)
+ loff_t off, struct fuse_file_info *fi)
{
(void)ino;
req_clop(req)->read(req, size, off, fi);
}
static void cuse_fll_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
- size_t size, off_t off, struct fuse_file_info *fi)
+ size_t size, loff_t off, struct fuse_file_info *fi)
{
(void)ino;
req_clop(req)->write(req, buf, size, off, fi);
diff --git a/lib/fuse.c b/lib/fuse.c
index fa0a814..834dd92 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -30,7 +30,6 @@
#include <limits.h>
#include <errno.h>
#include <signal.h>
-#include <dlfcn.h>
#include <assert.h>
#include <poll.h>
#include <sys/param.h>
@@ -39,6 +38,10 @@
#include <sys/mman.h>
#include <sys/file.h>
+#ifdef USE_MODULES
+#include <dlfcn.h>
+#endif
+
#define FUSE_NODE_SLAB 1
#ifndef MAP_ANONYMOUS
@@ -157,8 +160,8 @@ struct fuse {
struct lock {
int type;
- off_t start;
- off_t end;
+ loff_t start;
+ loff_t end;
pid_t pid;
uint64_t owner;
struct lock *next;
@@ -176,7 +179,7 @@ struct node {
int open_count;
struct timespec stat_updated;
struct timespec mtime;
- off_t size;
+ loff_t size;
struct lock *locks;
unsigned int is_hidden : 1;
unsigned int cache_valid : 1;
@@ -222,6 +225,8 @@ struct fuse_context_i {
static pthread_key_t fuse_context_key;
static pthread_mutex_t fuse_context_lock = PTHREAD_MUTEX_INITIALIZER;
static int fuse_context_ref;
+
+#ifdef USE_MODULES
static struct fusemod_so *fuse_current_so;
static struct fuse_module *fuse_modules;
@@ -320,6 +325,7 @@ static void fuse_put_module(struct fuse_module *m)
}
pthread_mutex_unlock(&fuse_context_lock);
}
+#endif
static void init_list_head(struct list_head *list)
{
@@ -1760,12 +1766,12 @@ static void fuse_free_buf(struct fuse_bufvec *buf)
}
int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
- struct fuse_bufvec **bufp, size_t size, off_t off,
+ struct fuse_bufvec **bufp, size_t size, loff_t off,
struct fuse_file_info *fi)
{
fuse_get_context()->private_data = fs->user_data;
if (fs->op.read || fs->op.read_buf) {
- int res;
+ ssize_t res;
if (fs->debug)
fprintf(stderr,
@@ -1802,7 +1808,7 @@ int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
(unsigned long long) fi->fh,
fuse_buf_size(*bufp),
(unsigned long long) off);
- if (res >= 0 && fuse_buf_size(*bufp) > (int) size)
+ if (res >= 0 && fuse_buf_size(*bufp) > size)
fprintf(stderr, "fuse: read too many bytes\n");
if (res < 0)
@@ -1815,7 +1821,7 @@ int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
}
int fuse_fs_read(struct fuse_fs *fs, const char *path, char *mem, size_t size,
- off_t off, struct fuse_file_info *fi)
+ loff_t off, struct fuse_file_info *fi)
{
int res;
struct fuse_bufvec *buf = NULL;
@@ -1833,7 +1839,7 @@ int fuse_fs_read(struct fuse_fs *fs, const char *path, char *mem, size_t size,
}
int fuse_fs_write_buf(struct fuse_fs *fs, const char *path,
- struct fuse_bufvec *buf, off_t off,
+ struct fuse_bufvec *buf, loff_t off,
struct fuse_file_info *fi)
{
fuse_get_context()->private_data = fs->user_data;
@@ -1897,7 +1903,7 @@ out:
}
int fuse_fs_write(struct fuse_fs *fs, const char *path, const char *mem,
- size_t size, off_t off, struct fuse_file_info *fi)
+ size_t size, loff_t off, struct fuse_file_info *fi)
{
struct fuse_bufvec bufv = FUSE_BUFVEC_INIT(size);
@@ -1996,7 +2002,7 @@ static int fill_dir_old(struct fuse_dirhandle *dh, const char *name, int type,
}
int fuse_fs_readdir(struct fuse_fs *fs, const char *path, void *buf,
- fuse_fill_dir_t filler, off_t off,
+ fuse_fill_dir_t filler, loff_t off,
struct fuse_file_info *fi)
{
fuse_get_context()->private_data = fs->user_data;
@@ -2107,7 +2113,7 @@ int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid)
}
}
-int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size)
+int fuse_fs_truncate(struct fuse_fs *fs, const char *path, loff_t size)
{
fuse_get_context()->private_data = fs->user_data;
if (fs->op.truncate) {
@@ -2121,7 +2127,7 @@ int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size)
}
}
-int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, off_t size,
+int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, loff_t size,
struct fuse_file_info *fi)
{
fuse_get_context()->private_data = fs->user_data;
@@ -2339,7 +2345,7 @@ int fuse_fs_poll(struct fuse_fs *fs, const char *path,
}
int fuse_fs_fallocate(struct fuse_fs *fs, const char *path, int mode,
- off_t offset, off_t length, struct fuse_file_info *fi)
+ loff_t offset, loff_t length, struct fuse_file_info *fi)
{
fuse_get_context()->private_data = fs->user_data;
if (fs->op.fallocate) {
@@ -2612,8 +2618,10 @@ void fuse_fs_destroy(struct fuse_fs *fs)
fuse_get_context()->private_data = fs->user_data;
if (fs->op.destroy)
fs->op.destroy(fs->user_data);
+#ifdef USE_MODULES
if (fs->m)
fuse_put_module(fs->m);
+#endif
free(fs);
}
@@ -3240,7 +3248,7 @@ static void fuse_lib_open(fuse_req_t req, fuse_ino_t ino,
}
static void fuse_lib_read(fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t off, struct fuse_file_info *fi)
+ loff_t off, struct fuse_file_info *fi)
{
struct fuse *f = req_fuse_prepare(req);
struct fuse_bufvec *buf = NULL;
@@ -3266,7 +3274,7 @@ static void fuse_lib_read(fuse_req_t req, fuse_ino_t ino, size_t size,
}
static void fuse_lib_write_buf(fuse_req_t req, fuse_ino_t ino,
- struct fuse_bufvec *buf, off_t off,
+ struct fuse_bufvec *buf, loff_t off,
struct fuse_file_info *fi)
{
struct fuse *f = req_fuse_prepare(req);
@@ -3395,7 +3403,7 @@ static int extend_contents(struct fuse_dh *dh, unsigned minsize)
}
static int fill_dir(void *dh_, const char *name, const struct stat *statp,
- off_t off)
+ loff_t off)
{
struct fuse_dh *dh = (struct fuse_dh *) dh_;
struct stat stbuf;
@@ -3445,7 +3453,7 @@ static int fill_dir(void *dh_, const char *name, const struct stat *statp,
}
static int readdir_fill(struct fuse *f, fuse_req_t req, fuse_ino_t ino,
- size_t size, off_t off, struct fuse_dh *dh,
+ size_t size, loff_t off, struct fuse_dh *dh,
struct fuse_file_info *fi)
{
char *path;
@@ -3477,7 +3485,7 @@ static int readdir_fill(struct fuse *f, fuse_req_t req, fuse_ino_t ino,
}
static void fuse_lib_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t off, struct fuse_file_info *llfi)
+ loff_t off, struct fuse_file_info *llfi)
{
struct fuse *f = req_fuse_prepare(req);
struct fuse_file_info fi;
@@ -4073,7 +4081,7 @@ static void fuse_lib_poll(fuse_req_t req, fuse_ino_t ino,
}
static void fuse_lib_fallocate(fuse_req_t req, fuse_ino_t ino, int mode,
- off_t offset, off_t length, struct fuse_file_info *fi)
+ loff_t offset, loff_t length, struct fuse_file_info *fi)
{
struct fuse *f = req_fuse_prepare(req);
struct fuse_intr_data d;
@@ -4433,6 +4441,7 @@ static void fuse_lib_help(void)
"\n", FUSE_DEFAULT_INTR_SIGNAL);
}
+#ifdef USE_MODULES
static void fuse_lib_help_modules(void)
{
struct fuse_module *m;
@@ -4452,6 +4461,7 @@ static void fuse_lib_help_modules(void)
}
pthread_mutex_unlock(&fuse_context_lock);
}
+#endif
static int fuse_lib_opt_proc(void *data, const char *arg, int key,
struct fuse_args *outargs)
@@ -4507,7 +4517,7 @@ static void fuse_restore_intr_signal(int signum)
sigaction(signum, &sa, NULL);
}
-
+#ifdef USE_MODULES
static int fuse_push_module(struct fuse *f, const char *module,
struct fuse_args *args)
{
@@ -4530,6 +4540,7 @@ static int fuse_push_module(struct fuse *f, const char *module,
f->utime_omit_ok = newfs->op.flag_utime_omit_ok && f->utime_omit_ok;
return 0;
}
+#endif
struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size,
void *user_data)
@@ -4567,11 +4578,30 @@ static int node_table_init(struct node_table *t)
return 0;
}
+static void thread_exit_handler(int sig __unused)
+{
+ 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);
@@ -4591,7 +4621,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);
}
@@ -4645,6 +4679,7 @@ struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
fuse_lib_opt_proc) == -1)
goto out_free_fs;
+#ifdef USE_MODULES
if (f->conf.modules) {
char *module;
char *next;
@@ -4659,6 +4694,7 @@ struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
goto out_free_fs;
}
}
+#endif
if (!f->conf.ac_attr_timeout_set)
f->conf.ac_attr_timeout = f->conf.attr_timeout;
@@ -4678,8 +4714,10 @@ struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
f->se = fuse_lowlevel_new_common(args, &llop, sizeof(llop), f);
if (f->se == NULL) {
+#ifdef USE_MODULES
if (f->conf.help)
fuse_lib_help_modules();
+#endif
goto out_free_fs;
}
@@ -4820,6 +4858,7 @@ static struct fuse *fuse_new_common_compat25(int fd, struct fuse_args *args,
return f;
}
+#ifdef USE_MODULES
/* called with fuse_context_lock held or during initialization (before
main() has been called) */
void fuse_register_module(struct fuse_module *mod)
@@ -4831,6 +4870,7 @@ void fuse_register_module(struct fuse_module *mod)
mod->next = fuse_modules;
fuse_modules = mod;
}
+#endif
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
@@ -4882,11 +4922,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..09d8681 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 __unused)
+{
+ 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_lowlevel.c b/lib/fuse_lowlevel.c
index ff03c63..232956c 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -248,7 +248,7 @@ size_t fuse_dirent_size(size_t namelen)
}
char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
- off_t off)
+ loff_t off)
{
unsigned namelen = strlen(name);
unsigned entlen = FUSE_NAME_OFFSET + namelen;
@@ -268,7 +268,7 @@ char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
}
size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
- const char *name, const struct stat *stbuf, off_t off)
+ const char *name, const struct stat *stbuf, loff_t off)
{
size_t entsize;
@@ -1980,7 +1980,7 @@ int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph)
}
int fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, fuse_ino_t ino,
- off_t off, off_t len)
+ loff_t off, loff_t len)
{
struct fuse_notify_inval_inode_out outarg;
struct fuse_ll *f;
@@ -2061,7 +2061,7 @@ int fuse_lowlevel_notify_delete(struct fuse_chan *ch,
}
int fuse_lowlevel_notify_store(struct fuse_chan *ch, fuse_ino_t ino,
- off_t offset, struct fuse_bufvec *bufv,
+ loff_t offset, struct fuse_bufvec *bufv,
enum fuse_buf_copy_flags flags)
{
struct fuse_out_header out;
@@ -2146,7 +2146,7 @@ out:
}
int fuse_lowlevel_notify_retrieve(struct fuse_chan *ch, fuse_ino_t ino,
- size_t size, off_t offset, void *cookie)
+ size_t size, loff_t offset, void *cookie)
{
struct fuse_notify_retrieve_out outarg;
struct fuse_ll *f;
@@ -2304,12 +2304,12 @@ static const char *opname(enum fuse_opcode opcode)
static int fuse_ll_copy_from_pipe(struct fuse_bufvec *dst,
struct fuse_bufvec *src)
{
- int res = fuse_buf_copy(dst, src, 0);
+ ssize_t res = fuse_buf_copy(dst, src, 0);
if (res < 0) {
fprintf(stderr, "fuse: copy from pipe: %s\n", strerror(-res));
return res;
}
- if (res < fuse_buf_size(dst)) {
+ if (res < (ssize_t)fuse_buf_size(dst)) {
fprintf(stderr, "fuse: copy from pipe: short read\n");
return -1;
}
@@ -2424,7 +2424,7 @@ static void fuse_ll_process_buf(void *data, const struct fuse_buf *buf,
mbuf = newmbuf;
tmpbuf = FUSE_BUFVEC_INIT(buf->size - write_header_size);
- tmpbuf.buf[0].mem = mbuf + write_header_size;
+ tmpbuf.buf[0].mem = (intptr_t *)mbuf + write_header_size;
res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
err = -res;
@@ -2779,7 +2779,7 @@ int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
char *buf;
size_t bufsize = 1024;
char path[128];
- int ret;
+ ssize_t ret;
int fd;
unsigned long pid = req->ctx.pid;
char *s;
@@ -2803,7 +2803,7 @@ retry:
goto out_free;
}
- if (ret == bufsize) {
+ if (ret == (ssize_t)bufsize) {
free(buf);
bufsize *= 4;
goto retry;
diff --git a/lib/fuse_mt.c b/lib/fuse_mt.c
index f6dbe71..4db7e78 100644
--- a/lib/fuse_mt.c
+++ b/lib/fuse_mt.c
@@ -50,7 +50,7 @@ static int mt_session_exited(void *data)
return fuse_session_exited(pd->prevse);
}
-static int mt_chan_receive(struct fuse_chan **chp, char *buf, size_t size)
+static int mt_chan_receive(struct fuse_chan **chp, char *buf, size_t size __unused)
{
struct fuse_cmd *cmd;
struct procdata *pd = (struct procdata *) fuse_chan_data(*chp);
@@ -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_opt.c b/lib/fuse_opt.c
index a2118ce..78d3b32 100644
--- a/lib/fuse_opt.c
+++ b/lib/fuse_opt.c
@@ -233,7 +233,7 @@ static int process_opt(struct fuse_opt_context *ctx,
if (call_proc(ctx, arg, opt->value, iso) == -1)
return -1;
} else {
- void *var = ctx->data + opt->offset;
+ void *var = (char *)ctx->data + opt->offset;
if (sep && opt->templ[sep + 1]) {
const char *param = arg + sep;
if (opt->templ[sep] == '=')
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..28711ed 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -1,3 +1,6 @@
+FUSE_UNVERSIONED {
+};
+
FUSE_2.2 {
global:
fuse_destroy;
@@ -145,9 +148,10 @@ FUSE_2.7 {
fuse_fs_unlink;
fuse_fs_utimens;
fuse_fs_write;
- fuse_register_module;
fuse_reply_iov;
fuse_version;
+ local:
+ fuse_register_module;
} FUSE_2.6;
FUSE_2.7.5 {
diff --git a/lib/helper.c b/lib/helper.c
index 49d30f9..1f13c87 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -450,10 +450,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/modules/iconv.c b/lib/modules/iconv.c
index 89b22e4..9b78cfd 100644
--- a/lib/modules/iconv.c
+++ b/lib/modules/iconv.c
@@ -170,7 +170,7 @@ static int iconv_opendir(const char *path, struct fuse_file_info *fi)
}
static int iconv_dir_fill(void *buf, const char *name,
- const struct stat *stbuf, off_t off)
+ const struct stat *stbuf, loff_t off)
{
struct iconv_dh *dh = buf;
char *newname;
@@ -183,7 +183,7 @@ static int iconv_dir_fill(void *buf, const char *name,
}
static int iconv_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
- off_t offset, struct fuse_file_info *fi)
+ loff_t offset, struct fuse_file_info *fi)
{
struct iconv *ic = iconv_get();
char *newpath;
@@ -335,7 +335,7 @@ static int iconv_chown(const char *path, uid_t uid, gid_t gid)
return err;
}
-static int iconv_truncate(const char *path, off_t size)
+static int iconv_truncate(const char *path, loff_t size)
{
struct iconv *ic = iconv_get();
char *newpath;
@@ -347,7 +347,7 @@ static int iconv_truncate(const char *path, off_t size)
return err;
}
-static int iconv_ftruncate(const char *path, off_t size,
+static int iconv_ftruncate(const char *path, loff_t size,
struct fuse_file_info *fi)
{
struct iconv *ic = iconv_get();
@@ -398,7 +398,7 @@ static int iconv_open_file(const char *path, struct fuse_file_info *fi)
}
static int iconv_read_buf(const char *path, struct fuse_bufvec **bufp,
- size_t size, off_t offset, struct fuse_file_info *fi)
+ size_t size, loff_t offset, struct fuse_file_info *fi)
{
struct iconv *ic = iconv_get();
char *newpath;
@@ -411,7 +411,7 @@ static int iconv_read_buf(const char *path, struct fuse_bufvec **bufp,
}
static int iconv_write_buf(const char *path, struct fuse_bufvec *buf,
- off_t offset, struct fuse_file_info *fi)
+ loff_t offset, struct fuse_file_info *fi)
{
struct iconv *ic = iconv_get();
char *newpath;
diff --git a/lib/modules/subdir.c b/lib/modules/subdir.c
index 76a53fa..05b3379 100644
--- a/lib/modules/subdir.c
+++ b/lib/modules/subdir.c
@@ -178,7 +178,7 @@ static int subdir_opendir(const char *path, struct fuse_file_info *fi)
}
static int subdir_readdir(const char *path, void *buf,
- fuse_fill_dir_t filler, off_t offset,
+ fuse_fill_dir_t filler, loff_t offset,
struct fuse_file_info *fi)
{
struct subdir *d = subdir_get();
@@ -322,7 +322,7 @@ static int subdir_chown(const char *path, uid_t uid, gid_t gid)
return err;
}
-static int subdir_truncate(const char *path, off_t size)
+static int subdir_truncate(const char *path, loff_t size)
{
struct subdir *d = subdir_get();
char *newpath;
@@ -334,7 +334,7 @@ static int subdir_truncate(const char *path, off_t size)
return err;
}
-static int subdir_ftruncate(const char *path, off_t size,
+static int subdir_ftruncate(const char *path, loff_t size,
struct fuse_file_info *fi)
{
struct subdir *d = subdir_get();
@@ -385,7 +385,7 @@ static int subdir_open(const char *path, struct fuse_file_info *fi)
}
static int subdir_read_buf(const char *path, struct fuse_bufvec **bufp,
- size_t size, off_t offset, struct fuse_file_info *fi)
+ size_t size, loff_t offset, struct fuse_file_info *fi)
{
struct subdir *d = subdir_get();
char *newpath;
@@ -398,7 +398,7 @@ static int subdir_read_buf(const char *path, struct fuse_bufvec **bufp,
}
static int subdir_write_buf(const char *path, struct fuse_bufvec *buf,
- off_t offset, struct fuse_file_info *fi)
+ loff_t offset, struct fuse_file_info *fi)
{
struct subdir *d = subdir_get();
char *newpath;
diff --git a/lib/mount.c b/lib/mount.c
index 227a408..7a629f1 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 defb92f..020b223 100644
--- a/lib/mount_util.c
+++ b/lib/mount_util.c
@@ -24,10 +24,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)
{
@@ -313,7 +318,7 @@ char *fuse_mnt_resolve_path(const char *progname, const char *orig)
}
int fuse_mnt_check_empty(const char *progname, const char *mnt,
- mode_t rootmode, off_t rootsize)
+ mode_t rootmode, loff_t rootsize)
{
int isempty = 1;
diff --git a/lib/mount_util.h b/lib/mount_util.h
index dc5c916..0e0f564 100644
--- a/lib/mount_util.h
+++ b/lib/mount_util.h
@@ -15,5 +15,5 @@ int fuse_mnt_umount(const char *progname, const char *abs_mnt,
const char *rel_mnt, int lazy);
char *fuse_mnt_resolve_path(const char *progname, const char *orig);
int fuse_mnt_check_empty(const char *progname, const char *mnt,
- mode_t rootmode, off_t rootsize);
+ mode_t rootmode, loff_t rootsize);
int fuse_mnt_check_fuseblk(void);
diff --git a/lib/ulockmgr.c b/lib/ulockmgr.c
index b875c50..ebd68c6 100644
--- a/lib/ulockmgr.c
+++ b/lib/ulockmgr.c
@@ -356,10 +356,10 @@ static uint32_t owner_hash(const unsigned char *id, size_t id_len)
static int ulockmgr_canonicalize(int fd, struct flock *lock)
{
- off_t offset;
+ loff_t offset;
if (lock->l_whence == SEEK_CUR) {
offset = lseek(fd, 0, SEEK_CUR);
- if (offset == (off_t) -1)
+ if (offset == (loff_t) -1)
return -errno;
} else if (lock->l_whence == SEEK_END) {
struct stat stbuf;
diff --git a/test/test.c b/test/test.c
index c421cda..10ed45a 100644
--- a/test/test.c
+++ b/test/test.c
@@ -286,7 +286,7 @@ static int check_data(const char *path, const char *data, int offset,
PERROR("open");
return -1;
}
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
+ if (lseek(fd, offset, SEEK_SET) == (loff_t) -1) {
PERROR("lseek");
close(fd);
return -1;
@@ -324,7 +324,7 @@ static int fcheck_data(int fd, const char *data, int offset,
{
char buf[4096];
int res;
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
+ if (lseek(fd, offset, SEEK_SET) == (loff_t) -1) {
PERROR("lseek");
return -1;
}
@@ -829,7 +829,7 @@ static int do_test_open(int exist, int flags, const char *flags_str, int mode)
int err = 0;
int res;
int fd;
- off_t off;
+ loff_t off;
start_test("open(%s, %s, 0%03o)", exist ? "+" : "-", flags_str, mode);
unlink(testfile);
@@ -910,7 +910,7 @@ static int do_test_open(int exist, int flags, const char *flags_str, int mode)
}
}
off = lseek(fd, SEEK_SET, 0);
- if (off == (off_t) -1) {
+ if (off == (loff_t) -1) {
PERROR("lseek");
err--;
} else if (off != 0) {
diff --git a/util/fusermount.c b/util/fusermount.c
index 26a0b75..f2daeac 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -714,7 +714,7 @@ static int get_string_opt(const char *s, unsigned len, const char *opt,
static int do_mount(const char *mnt, char **typep, mode_t rootmode,
int fd, const char *opts, const char *dev, char **sourcep,
- char **mnt_optsp, off_t rootsize)
+ char **mnt_optsp, loff_t rootsize)
{
int res;
int flags = MS_NOSUID | MS_NODEV;