mirror of
https://github.com/feather-wallet/feather.git
synced 2024-10-31 17:37:43 +00:00
641 lines
19 KiB
Diff
641 lines
19 KiB
Diff
|
--- a/Makefile.am
|
||
|
+++ b/Makefile.am
|
||
|
@@ -1,6 +1,7 @@
|
||
|
COMPRESSION_LIBS = $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(LZ4_LIBS)
|
||
|
|
||
|
ACLOCAL_AMFLAGS = -I m4 --install
|
||
|
+AM_CFLAGS = -fno-strict-aliasing -DENABLE_DLOPEN
|
||
|
|
||
|
# Suppress AppleDouble
|
||
|
if MAKE_EXPORT
|
||
|
@@ -19,13 +20,13 @@
|
||
|
# Main library: libsquashfuse
|
||
|
libsquashfuse_la_SOURCES = swap.c cache.c table.c dir.c file.c fs.c \
|
||
|
decompress.c xattr.c hash.c stack.c traverse.c util.c \
|
||
|
- nonstd-pread.c nonstd-stat.c \
|
||
|
+ nonstd-pread.c nonstd-stat.c squashfuse_dlopen.c \
|
||
|
squashfs_fs.h common.h nonstd-internal.h nonstd.h swap.h cache.h table.h \
|
||
|
dir.h file.h decompress.h xattr.h squashfuse.h hash.h stack.h traverse.h \
|
||
|
- util.h fs.h
|
||
|
+ util.h fs.h squashfuse_dlopen.h
|
||
|
libsquashfuse_la_CPPFLAGS = $(ZLIB_CPPFLAGS) $(XZ_CPPFLAGS) $(LZO_CPPFLAGS) \
|
||
|
$(LZ4_CPPFLAGS)
|
||
|
-libsquashfuse_la_LIBADD =
|
||
|
+libsquashfuse_la_LIBADD = -ldl
|
||
|
|
||
|
# Helper for FUSE clients: libfuseprivate
|
||
|
libfuseprivate_la_SOURCES = fuseprivate.c nonstd-makedev.c nonstd-enoattr.c \
|
||
|
--- a/fuseprivate.c
|
||
|
+++ b/fuseprivate.c
|
||
|
@@ -94,15 +94,17 @@
|
||
|
}
|
||
|
|
||
|
void sqfs_usage(char *progname, bool fuse_usage) {
|
||
|
+ LOAD_SYMBOL(int,fuse_opt_add_arg,(struct fuse_args *args, const char *arg));
|
||
|
+ LOAD_SYMBOL(int,fuse_parse_cmdline,(struct fuse_args *args, char **mountpoint, int *multithreaded, int *foreground));
|
||
|
fprintf(stderr, "%s (c) 2012 Dave Vasilevsky\n\n", PACKAGE_STRING);
|
||
|
fprintf(stderr, "Usage: %s [options] ARCHIVE MOUNTPOINT\n",
|
||
|
progname ? progname : PACKAGE_NAME);
|
||
|
if (fuse_usage) {
|
||
|
struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
|
||
|
- fuse_opt_add_arg(&args, ""); /* progname */
|
||
|
- fuse_opt_add_arg(&args, "-ho");
|
||
|
+ DL(fuse_opt_add_arg)(&args, ""); /* progname */
|
||
|
+ DL(fuse_opt_add_arg)(&args, "-ho");
|
||
|
fprintf(stderr, "\n");
|
||
|
- fuse_parse_cmdline(&args, NULL, NULL, NULL);
|
||
|
+ DL(fuse_parse_cmdline)(&args, NULL, NULL, NULL);
|
||
|
}
|
||
|
exit(-2);
|
||
|
}
|
||
|
--- a/fuseprivate.h
|
||
|
+++ b/fuseprivate.h
|
||
|
@@ -27,7 +27,10 @@
|
||
|
|
||
|
#include "squashfuse.h"
|
||
|
|
||
|
-#include <fuse.h>
|
||
|
+#include "squashfuse_dlopen.h"
|
||
|
+#ifndef ENABLE_DLOPEN
|
||
|
+# include <fuse.h>
|
||
|
+#endif
|
||
|
|
||
|
#include <sys/stat.h>
|
||
|
|
||
|
--- a/hl.c
|
||
|
+++ b/hl.c
|
||
|
@@ -33,6 +33,7 @@
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
+int have_libloaded = 0;
|
||
|
|
||
|
typedef struct sqfs_hl sqfs_hl;
|
||
|
struct sqfs_hl {
|
||
|
@@ -42,9 +43,10 @@
|
||
|
|
||
|
static sqfs_err sqfs_hl_lookup(sqfs **fs, sqfs_inode *inode,
|
||
|
const char *path) {
|
||
|
+ LOAD_SYMBOL(struct fuse_context *,fuse_get_context,(void));
|
||
|
bool found;
|
||
|
|
||
|
- sqfs_hl *hl = fuse_get_context()->private_data;
|
||
|
+ sqfs_hl *hl = DL(fuse_get_context)()->private_data;
|
||
|
*fs = &hl->fs;
|
||
|
if (inode)
|
||
|
*inode = hl->root; /* copy */
|
||
|
@@ -67,7 +69,8 @@
|
||
|
}
|
||
|
|
||
|
static void *sqfs_hl_op_init(struct fuse_conn_info *conn) {
|
||
|
- return fuse_get_context()->private_data;
|
||
|
+ LOAD_SYMBOL(struct fuse_context *,fuse_get_context,(void));
|
||
|
+ return DL(fuse_get_context)()->private_data;
|
||
|
}
|
||
|
|
||
|
static int sqfs_hl_op_getattr(const char *path, struct stat *st) {
|
||
|
@@ -264,7 +267,16 @@
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
+#ifdef ENABLE_DLOPEN
|
||
|
+#define fuse_main(argc, argv, op, user_data) \
|
||
|
+ DL(fuse_main_real)(argc, argv, op, sizeof(*(op)), user_data)
|
||
|
+#endif
|
||
|
+
|
||
|
int main(int argc, char *argv[]) {
|
||
|
+ LOAD_SYMBOL(int,fuse_opt_parse,(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc));
|
||
|
+ LOAD_SYMBOL(int,fuse_opt_add_arg,(struct fuse_args *args, const char *arg));
|
||
|
+ LOAD_SYMBOL(int,fuse_main_real,(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, void *user_data)); /* fuse_main */
|
||
|
+ LOAD_SYMBOL(void,fuse_opt_free_args,(struct fuse_args *args));
|
||
|
struct fuse_args args;
|
||
|
sqfs_opts opts;
|
||
|
sqfs_hl *hl;
|
||
|
@@ -299,7 +311,7 @@
|
||
|
opts.image = NULL;
|
||
|
opts.mountpoint = 0;
|
||
|
opts.offset = 0;
|
||
|
- if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
|
||
|
+ if (DL(fuse_opt_parse)(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
|
||
|
sqfs_usage(argv[0], true);
|
||
|
if (!opts.image)
|
||
|
sqfs_usage(argv[0], true);
|
||
|
@@ -308,8 +320,9 @@
|
||
|
if (!hl)
|
||
|
return -1;
|
||
|
|
||
|
- fuse_opt_add_arg(&args, "-s"); /* single threaded */
|
||
|
+ DL(fuse_opt_add_arg)(&args, "-s"); /* single threaded */
|
||
|
ret = fuse_main(args.argc, args.argv, &sqfs_hl_ops, hl);
|
||
|
- fuse_opt_free_args(&args);
|
||
|
+ DL(fuse_opt_free_args)(&args);
|
||
|
+ CLOSE_LIBRARY;
|
||
|
return ret;
|
||
|
}
|
||
|
--- a/ll.h
|
||
|
+++ b/ll.h
|
||
|
@@ -27,7 +27,10 @@
|
||
|
|
||
|
#include "squashfuse.h"
|
||
|
|
||
|
-#include <fuse_lowlevel.h>
|
||
|
+#include "squashfuse_dlopen.h"
|
||
|
+#ifndef ENABLE_DLOPEN
|
||
|
+# include <fuse_lowlevel.h>
|
||
|
+#endif
|
||
|
|
||
|
typedef struct sqfs_ll sqfs_ll;
|
||
|
struct sqfs_ll {
|
||
|
--- a/ll_inode.c
|
||
|
+++ b/ll_inode.c
|
||
|
@@ -348,12 +348,14 @@
|
||
|
|
||
|
|
||
|
sqfs_err sqfs_ll_iget(fuse_req_t req, sqfs_ll_i *lli, fuse_ino_t i) {
|
||
|
+ LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
sqfs_err err = SQFS_OK;
|
||
|
- lli->ll = fuse_req_userdata(req);
|
||
|
+ lli->ll = DL(fuse_req_userdata)(req);
|
||
|
if (i != SQFS_FUSE_INODE_NONE) {
|
||
|
err = sqfs_ll_inode(lli->ll, &lli->inode, i);
|
||
|
if (err)
|
||
|
- fuse_reply_err(req, ENOENT);
|
||
|
+ DL(fuse_reply_err)(req, ENOENT);
|
||
|
}
|
||
|
return err;
|
||
|
}
|
||
|
--- a/nonstd-daemon.c
|
||
|
+++ b/nonstd-daemon.c
|
||
|
@@ -28,11 +28,16 @@
|
||
|
#include "nonstd-internal.h"
|
||
|
|
||
|
#include <unistd.h>
|
||
|
-#include <fuse_lowlevel.h>
|
||
|
+
|
||
|
+#include "squashfuse_dlopen.h"
|
||
|
+#ifndef ENABLE_DLOPEN
|
||
|
+# include <fuse_lowlevel.h>
|
||
|
+#endif
|
||
|
|
||
|
int sqfs_ll_daemonize(int fg) {
|
||
|
#if HAVE_DECL_FUSE_DAEMONIZE
|
||
|
- return fuse_daemonize(fg);
|
||
|
+ LOAD_SYMBOL(int,fuse_daemonize,(int foreground));
|
||
|
+ return DL(fuse_daemonize)(fg);
|
||
|
#else
|
||
|
return daemon(0,0);
|
||
|
#endif
|
||
|
--- a/ll.c
|
||
|
+++ b/ll.c
|
||
|
@@ -38,37 +38,41 @@
|
||
|
|
||
|
static void sqfs_ll_op_getattr(fuse_req_t req, fuse_ino_t ino,
|
||
|
struct fuse_file_info *fi) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_attr,(fuse_req_t req, const struct stat *attr, double attr_timeout));
|
||
|
sqfs_ll_i lli;
|
||
|
struct stat st;
|
||
|
if (sqfs_ll_iget(req, &lli, ino))
|
||
|
return;
|
||
|
|
||
|
if (sqfs_stat(&lli.ll->fs, &lli.inode, &st)) {
|
||
|
- fuse_reply_err(req, ENOENT);
|
||
|
+ DL(fuse_reply_err)(req, ENOENT);
|
||
|
} else {
|
||
|
st.st_ino = ino;
|
||
|
- fuse_reply_attr(req, &st, SQFS_TIMEOUT);
|
||
|
+ DL(fuse_reply_attr)(req, &st, SQFS_TIMEOUT);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_opendir(fuse_req_t req, fuse_ino_t ino,
|
||
|
struct fuse_file_info *fi) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_open,(fuse_req_t req, const struct fuse_file_info *fi));
|
||
|
sqfs_ll_i *lli;
|
||
|
|
||
|
fi->fh = (intptr_t)NULL;
|
||
|
|
||
|
lli = malloc(sizeof(*lli));
|
||
|
if (!lli) {
|
||
|
- fuse_reply_err(req, ENOMEM);
|
||
|
+ DL(fuse_reply_err)(req, ENOMEM);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (sqfs_ll_iget(req, lli, ino) == SQFS_OK) {
|
||
|
if (!S_ISDIR(lli->inode.base.mode)) {
|
||
|
- fuse_reply_err(req, ENOTDIR);
|
||
|
+ DL(fuse_reply_err)(req, ENOTDIR);
|
||
|
} else {
|
||
|
fi->fh = (intptr_t)lli;
|
||
|
- fuse_reply_open(req, fi);
|
||
|
+ DL(fuse_reply_open)(req, fi);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
@@ -77,28 +81,35 @@
|
||
|
|
||
|
static void sqfs_ll_op_create(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||
|
mode_t mode, struct fuse_file_info *fi) {
|
||
|
- fuse_reply_err(req, EROFS);
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ DL(fuse_reply_err)(req, EROFS);
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_releasedir(fuse_req_t req, fuse_ino_t ino,
|
||
|
struct fuse_file_info *fi) {
|
||
|
free((sqfs_ll_i*)(intptr_t)fi->fh);
|
||
|
- fuse_reply_err(req, 0); /* yes, this is necessary */
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ DL(fuse_reply_err)(req, 0); /* yes, this is necessary */
|
||
|
}
|
||
|
|
||
|
static size_t sqfs_ll_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
|
||
|
const char *name, const struct stat *st, off_t off) {
|
||
|
#if HAVE_DECL_FUSE_ADD_DIRENTRY
|
||
|
- return fuse_add_direntry(req, buf, bufsize, name, st, off);
|
||
|
+ LOAD_SYMBOL(size_t,fuse_add_direntry,(fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct stat *stbuf, off_t off));
|
||
|
+ return DL(fuse_add_direntry)(req, buf, bufsize, name, st, off);
|
||
|
#else
|
||
|
- size_t esize = fuse_dirent_size(strlen(name));
|
||
|
+ LOAD_SYMBOL(size_t,fuse_dirent_size(size_t namelen));
|
||
|
+ LOAD_SYMBOL(char *,fuse_add_dirent,(char *buf, const char *name, const struct stat *stbuf, off_t off));
|
||
|
+ size_t esize = DL(fuse_dirent_size)(strlen(name));
|
||
|
if (bufsize >= esize)
|
||
|
- fuse_add_dirent(buf, name, st, off);
|
||
|
+ DL(fuse_add_dirent)(buf, name, st, off);
|
||
|
return esize;
|
||
|
#endif
|
||
|
}
|
||
|
static void sqfs_ll_op_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
|
||
|
off_t off, struct fuse_file_info *fi) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
|
||
|
sqfs_err sqerr;
|
||
|
sqfs_dir dir;
|
||
|
sqfs_name namebuf;
|
||
|
@@ -135,14 +146,16 @@
|
||
|
}
|
||
|
|
||
|
if (err)
|
||
|
- fuse_reply_err(req, err);
|
||
|
+ DL(fuse_reply_err)(req, err);
|
||
|
else
|
||
|
- fuse_reply_buf(req, buf, bufpos - buf);
|
||
|
+ DL(fuse_reply_buf)(req, buf, bufpos - buf);
|
||
|
free(buf);
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_lookup(fuse_req_t req, fuse_ino_t parent,
|
||
|
const char *name) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_entry,(fuse_req_t req, const struct fuse_entry_param *e));
|
||
|
sqfs_ll_i lli;
|
||
|
sqfs_err sqerr;
|
||
|
sqfs_name namebuf;
|
||
|
@@ -154,7 +167,7 @@
|
||
|
return;
|
||
|
|
||
|
if (!S_ISDIR(lli.inode.base.mode)) {
|
||
|
- fuse_reply_err(req, ENOTDIR);
|
||
|
+ DL(fuse_reply_err)(req, ENOTDIR);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
@@ -162,55 +175,58 @@
|
||
|
sqerr = sqfs_dir_lookup(&lli.ll->fs, &lli.inode, name, strlen(name), &entry,
|
||
|
&found);
|
||
|
if (sqerr) {
|
||
|
- fuse_reply_err(req, EIO);
|
||
|
+ DL(fuse_reply_err)(req, EIO);
|
||
|
return;
|
||
|
}
|
||
|
if (!found) {
|
||
|
- fuse_reply_err(req, ENOENT);
|
||
|
+ DL(fuse_reply_err)(req, ENOENT);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (sqfs_inode_get(&lli.ll->fs, &inode, sqfs_dentry_inode(&entry))) {
|
||
|
- fuse_reply_err(req, ENOENT);
|
||
|
+ DL(fuse_reply_err)(req, ENOENT);
|
||
|
} else {
|
||
|
struct fuse_entry_param fentry;
|
||
|
memset(&fentry, 0, sizeof(fentry));
|
||
|
if (sqfs_stat(&lli.ll->fs, &inode, &fentry.attr)) {
|
||
|
- fuse_reply_err(req, EIO);
|
||
|
+ DL(fuse_reply_err)(req, EIO);
|
||
|
} else {
|
||
|
fentry.attr_timeout = fentry.entry_timeout = SQFS_TIMEOUT;
|
||
|
fentry.ino = lli.ll->ino_register(lli.ll, &entry);
|
||
|
fentry.attr.st_ino = fentry.ino;
|
||
|
- fuse_reply_entry(req, &fentry);
|
||
|
+ DL(fuse_reply_entry)(req, &fentry);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_open(fuse_req_t req, fuse_ino_t ino,
|
||
|
struct fuse_file_info *fi) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_open,(fuse_req_t req, const struct fuse_file_info *fi));
|
||
|
+ LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req));
|
||
|
sqfs_inode *inode;
|
||
|
sqfs_ll *ll;
|
||
|
|
||
|
if (fi->flags & (O_WRONLY | O_RDWR)) {
|
||
|
- fuse_reply_err(req, EROFS);
|
||
|
+ DL(fuse_reply_err)(req, EROFS);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
inode = malloc(sizeof(sqfs_inode));
|
||
|
if (!inode) {
|
||
|
- fuse_reply_err(req, ENOMEM);
|
||
|
+ DL(fuse_reply_err)(req, ENOMEM);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
- ll = fuse_req_userdata(req);
|
||
|
+ ll = DL(fuse_req_userdata)(req);
|
||
|
if (sqfs_ll_inode(ll, inode, ino)) {
|
||
|
- fuse_reply_err(req, ENOENT);
|
||
|
+ DL(fuse_reply_err)(req, ENOENT);
|
||
|
} else if (!S_ISREG(inode->base.mode)) {
|
||
|
- fuse_reply_err(req, EISDIR);
|
||
|
+ DL(fuse_reply_err)(req, EISDIR);
|
||
|
} else {
|
||
|
fi->fh = (intptr_t)inode;
|
||
|
fi->keep_cache = 1;
|
||
|
- fuse_reply_open(req, fi);
|
||
|
+ DL(fuse_reply_open)(req, fi);
|
||
|
return;
|
||
|
}
|
||
|
free(inode);
|
||
|
@@ -218,37 +234,43 @@
|
||
|
|
||
|
static void sqfs_ll_op_release(fuse_req_t req, fuse_ino_t ino,
|
||
|
struct fuse_file_info *fi) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
free((sqfs_inode*)(intptr_t)fi->fh);
|
||
|
fi->fh = 0;
|
||
|
- fuse_reply_err(req, 0);
|
||
|
+ DL(fuse_reply_err)(req, 0);
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_read(fuse_req_t req, fuse_ino_t ino,
|
||
|
size_t size, off_t off, struct fuse_file_info *fi) {
|
||
|
- sqfs_ll *ll = fuse_req_userdata(req);
|
||
|
+ LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
|
||
|
+ sqfs_ll *ll = DL(fuse_req_userdata)(req);
|
||
|
sqfs_inode *inode = (sqfs_inode*)(intptr_t)fi->fh;
|
||
|
sqfs_err err = SQFS_OK;
|
||
|
|
||
|
off_t osize;
|
||
|
char *buf = malloc(size);
|
||
|
if (!buf) {
|
||
|
- fuse_reply_err(req, ENOMEM);
|
||
|
+ DL(fuse_reply_err)(req, ENOMEM);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
osize = size;
|
||
|
err = sqfs_read_range(&ll->fs, inode, off, &osize, buf);
|
||
|
if (err) {
|
||
|
- fuse_reply_err(req, EIO);
|
||
|
+ DL(fuse_reply_err)(req, EIO);
|
||
|
} else if (osize == 0) { /* EOF */
|
||
|
- fuse_reply_buf(req, NULL, 0);
|
||
|
+ DL(fuse_reply_buf)(req, NULL, 0);
|
||
|
} else {
|
||
|
- fuse_reply_buf(req, buf, osize);
|
||
|
+ DL(fuse_reply_buf)(req, buf, osize);
|
||
|
}
|
||
|
free(buf);
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_readlink(fuse_req_t req, fuse_ino_t ino) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_readlink,(fuse_req_t req, const char *link));
|
||
|
char *dst;
|
||
|
size_t size;
|
||
|
sqfs_ll_i lli;
|
||
|
@@ -256,21 +278,24 @@
|
||
|
return;
|
||
|
|
||
|
if (!S_ISLNK(lli.inode.base.mode)) {
|
||
|
- fuse_reply_err(req, EINVAL);
|
||
|
+ DL(fuse_reply_err)(req, EINVAL);
|
||
|
} else if (sqfs_readlink(&lli.ll->fs, &lli.inode, NULL, &size)) {
|
||
|
- fuse_reply_err(req, EIO);
|
||
|
+ DL(fuse_reply_err)(req, EIO);
|
||
|
} else if (!(dst = malloc(size + 1))) {
|
||
|
- fuse_reply_err(req, ENOMEM);
|
||
|
+ DL(fuse_reply_err)(req, ENOMEM);
|
||
|
} else if (sqfs_readlink(&lli.ll->fs, &lli.inode, dst, &size)) {
|
||
|
- fuse_reply_err(req, EIO);
|
||
|
+ DL(fuse_reply_err)(req, EIO);
|
||
|
free(dst);
|
||
|
} else {
|
||
|
- fuse_reply_readlink(req, dst);
|
||
|
+ DL(fuse_reply_readlink)(req, dst);
|
||
|
free(dst);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_xattr,(fuse_req_t req, size_t count));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
|
||
|
sqfs_ll_i lli;
|
||
|
char *buf;
|
||
|
int ferr;
|
||
|
@@ -280,17 +305,17 @@
|
||
|
|
||
|
buf = NULL;
|
||
|
if (size && !(buf = malloc(size))) {
|
||
|
- fuse_reply_err(req, ENOMEM);
|
||
|
+ DL(fuse_reply_err)(req, ENOMEM);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ferr = sqfs_listxattr(&lli.ll->fs, &lli.inode, buf, &size);
|
||
|
if (ferr) {
|
||
|
- fuse_reply_err(req, ferr);
|
||
|
+ DL(fuse_reply_err)(req, ferr);
|
||
|
} else if (buf) {
|
||
|
- fuse_reply_buf(req, buf, size);
|
||
|
+ DL(fuse_reply_buf)(req, buf, size);
|
||
|
} else {
|
||
|
- fuse_reply_xattr(req, size);
|
||
|
+ DL(fuse_reply_xattr)(req, size);
|
||
|
}
|
||
|
free(buf);
|
||
|
}
|
||
|
@@ -301,13 +326,16 @@
|
||
|
, uint32_t position
|
||
|
#endif
|
||
|
) {
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_xattr,(fuse_req_t req, size_t count));
|
||
|
+ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
|
||
|
sqfs_ll_i lli;
|
||
|
char *buf = NULL;
|
||
|
size_t real = size;
|
||
|
|
||
|
#ifdef FUSE_XATTR_POSITION
|
||
|
if (position != 0) { /* We don't support resource forks */
|
||
|
- fuse_reply_err(req, EINVAL);
|
||
|
+ DL(fuse_reply_err)(req, EINVAL);
|
||
|
return;
|
||
|
}
|
||
|
#endif
|
||
|
@@ -316,26 +344,27 @@
|
||
|
return;
|
||
|
|
||
|
if (!(buf = malloc(size)))
|
||
|
- fuse_reply_err(req, ENOMEM);
|
||
|
+ DL(fuse_reply_err)(req, ENOMEM);
|
||
|
else if (sqfs_xattr_lookup(&lli.ll->fs, &lli.inode, name, buf, &real))
|
||
|
- fuse_reply_err(req, EIO);
|
||
|
+ DL(fuse_reply_err)(req, EIO);
|
||
|
else if (real == 0)
|
||
|
- fuse_reply_err(req, sqfs_enoattr());
|
||
|
+ DL(fuse_reply_err)(req, sqfs_enoattr());
|
||
|
else if (size == 0)
|
||
|
- fuse_reply_xattr(req, real);
|
||
|
+ DL(fuse_reply_xattr)(req, real);
|
||
|
else if (size < real)
|
||
|
- fuse_reply_err(req, ERANGE);
|
||
|
+ DL(fuse_reply_err)(req, ERANGE);
|
||
|
else
|
||
|
- fuse_reply_buf(req, buf, real);
|
||
|
+ DL(fuse_reply_buf)(req, buf, real);
|
||
|
free(buf);
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_op_forget(fuse_req_t req, fuse_ino_t ino,
|
||
|
unsigned long nlookup) {
|
||
|
+ LOAD_SYMBOL(void,fuse_reply_none,(fuse_req_t req));
|
||
|
sqfs_ll_i lli;
|
||
|
sqfs_ll_iget(req, &lli, SQFS_FUSE_INODE_NONE);
|
||
|
lli.ll->ino_forget(lli.ll, ino, nlookup);
|
||
|
- fuse_reply_none(req);
|
||
|
+ DL(fuse_reply_none)(req);
|
||
|
}
|
||
|
|
||
|
|
||
|
@@ -348,23 +377,27 @@
|
||
|
|
||
|
static sqfs_err sqfs_ll_mount(sqfs_ll_chan *ch, const char *mountpoint,
|
||
|
struct fuse_args *args) {
|
||
|
+ LOAD_SYMBOL(struct fuse_chan *,fuse_mount,(const char *mountpoint, struct fuse_args *args));
|
||
|
#ifdef HAVE_NEW_FUSE_UNMOUNT
|
||
|
- ch->ch = fuse_mount(mountpoint, args);
|
||
|
+ ch->ch = DL(fuse_mount)(mountpoint, args);
|
||
|
#else
|
||
|
- ch->fd = fuse_mount(mountpoint, args);
|
||
|
+ LOAD_SYMBOL(struct fuse_chan *,fuse_kern_chan_new,(int fd));
|
||
|
+ ch->fd = DL(fuse_mount)(mountpoint, args);
|
||
|
if (ch->fd == -1)
|
||
|
return SQFS_ERR;
|
||
|
- ch->ch = fuse_kern_chan_new(ch->fd);
|
||
|
+ ch->ch = DL(fuse_kern_chan_new)(ch->fd);
|
||
|
#endif
|
||
|
return ch->ch ? SQFS_OK : SQFS_ERR;
|
||
|
}
|
||
|
|
||
|
static void sqfs_ll_unmount(sqfs_ll_chan *ch, const char *mountpoint) {
|
||
|
#ifdef HAVE_NEW_FUSE_UNMOUNT
|
||
|
- fuse_unmount(mountpoint, ch->ch);
|
||
|
+ LOAD_SYMBOL(void,fuse_unmount,(const char *mountpoint, struct fuse_chan *ch));
|
||
|
+ DL(fuse_unmount)(mountpoint, ch->ch);
|
||
|
#else
|
||
|
+ LOAD_SYMBOL(void,fuse_unmount,(const char *mountpoint));
|
||
|
close(ch->fd);
|
||
|
- fuse_unmount(mountpoint);
|
||
|
+ DL(fuse_unmount)(mountpoint);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
@@ -391,6 +424,19 @@
|
||
|
}
|
||
|
|
||
|
int fusefs_main(int argc, char *argv[], void (*mounted) (void)) {
|
||
|
+ LOAD_SYMBOL(int,fuse_opt_parse,(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc));
|
||
|
+ LOAD_SYMBOL(int,fuse_parse_cmdline,(struct fuse_args *args, char **mountpoint, int *multithreaded, int *foreground));
|
||
|
+ LOAD_SYMBOL(struct fuse_session *,fuse_lowlevel_new,(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata));
|
||
|
+ LOAD_SYMBOL(int,fuse_set_signal_handlers,(struct fuse_session *se));
|
||
|
+ LOAD_SYMBOL(void,fuse_session_add_chan,(struct fuse_session *se, struct fuse_chan *ch));
|
||
|
+ LOAD_SYMBOL(int,fuse_session_loop,(struct fuse_session *se));
|
||
|
+ LOAD_SYMBOL(void,fuse_remove_signal_handlers,(struct fuse_session *se));
|
||
|
+#if HAVE_DECL_FUSE_SESSION_REMOVE_CHAN
|
||
|
+ LOAD_SYMBOL(void,fuse_session_remove_chan,(struct fuse_chan *ch));
|
||
|
+#endif
|
||
|
+ LOAD_SYMBOL(void,fuse_session_destroy,(struct fuse_session *se));
|
||
|
+ LOAD_SYMBOL(void,fuse_opt_free_args,(struct fuse_args *args));
|
||
|
+
|
||
|
struct fuse_args args;
|
||
|
sqfs_opts opts;
|
||
|
|
||
|
@@ -429,10 +475,10 @@
|
||
|
opts.image = NULL;
|
||
|
opts.mountpoint = 0;
|
||
|
opts.offset = 0;
|
||
|
- if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
|
||
|
+ if (DL(fuse_opt_parse)(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
|
||
|
sqfs_usage(argv[0], true);
|
||
|
|
||
|
- if (fuse_parse_cmdline(&args, &mountpoint, &mt, &fg) == -1)
|
||
|
+ if (DL(fuse_parse_cmdline)(&args, &mountpoint, &mt, &fg) == -1)
|
||
|
sqfs_usage(argv[0], true);
|
||
|
if (mountpoint == NULL)
|
||
|
sqfs_usage(argv[0], true);
|
||
|
@@ -445,33 +491,34 @@
|
||
|
sqfs_ll_chan ch;
|
||
|
err = -1;
|
||
|
if (sqfs_ll_mount(&ch, mountpoint, &args) == SQFS_OK) {
|
||
|
- struct fuse_session *se = fuse_lowlevel_new(&args,
|
||
|
+ struct fuse_session *se = DL(fuse_lowlevel_new)(&args,
|
||
|
&sqfs_ll_ops, sizeof(sqfs_ll_ops), ll);
|
||
|
if (se != NULL) {
|
||
|
if (sqfs_ll_daemonize(fg) != -1) {
|
||
|
- if (fuse_set_signal_handlers(se) != -1) {
|
||
|
- fuse_session_add_chan(se, ch.ch);
|
||
|
+ if (DL(fuse_set_signal_handlers)(se) != -1) {
|
||
|
+ DL(fuse_session_add_chan)(se, ch.ch);
|
||
|
if (mounted)
|
||
|
mounted ();
|
||
|
/* FIXME: multithreading */
|
||
|
- err = fuse_session_loop(se);
|
||
|
- fuse_remove_signal_handlers(se);
|
||
|
+ err = DL(fuse_session_loop)(se);
|
||
|
+ DL(fuse_remove_signal_handlers)(se);
|
||
|
#if HAVE_DECL_FUSE_SESSION_REMOVE_CHAN
|
||
|
- fuse_session_remove_chan(ch.ch);
|
||
|
+ DL(fuse_session_remove_chan)(ch.ch);
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
- fuse_session_destroy(se);
|
||
|
+ DL(fuse_session_destroy)(se);
|
||
|
}
|
||
|
sqfs_ll_destroy(ll);
|
||
|
sqfs_ll_unmount(&ch, mountpoint);
|
||
|
}
|
||
|
}
|
||
|
- fuse_opt_free_args(&args);
|
||
|
+ DL(fuse_opt_free_args)(&args);
|
||
|
if (mounted)
|
||
|
rmdir (mountpoint);
|
||
|
free(ll);
|
||
|
free(mountpoint);
|
||
|
+ CLOSE_LIBRARY;
|
||
|
|
||
|
return -err;
|
||
|
}
|