xhost + # Workaround for: QXcbConnection: Could not connect to display :0
[appimagekit.git] / squashfuse_dlopen.patch
blob59e1e6e6882b403ca130aa419560c456b8e6def0
1 --- a/Makefile.am
2 +++ b/Makefile.am
3 @@ -1,6 +1,7 @@
4 COMPRESSION_LIBS = $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(LZ4_LIBS)
6 ACLOCAL_AMFLAGS = -I m4 --install
7 +AM_CFLAGS = -fno-strict-aliasing -DENABLE_DLOPEN
9 # Suppress AppleDouble
10 if MAKE_EXPORT
11 @@ -19,13 +20,13 @@
12 # Main library: libsquashfuse
13 libsquashfuse_la_SOURCES = swap.c cache.c table.c dir.c file.c fs.c \
14 decompress.c xattr.c hash.c stack.c traverse.c util.c \
15 - nonstd-pread.c nonstd-stat.c \
16 + nonstd-pread.c nonstd-stat.c squashfuse_dlopen.c \
17 squashfs_fs.h common.h nonstd-internal.h nonstd.h swap.h cache.h table.h \
18 dir.h file.h decompress.h xattr.h squashfuse.h hash.h stack.h traverse.h \
19 - util.h fs.h
20 + util.h fs.h squashfuse_dlopen.h
21 libsquashfuse_la_CPPFLAGS = $(ZLIB_CPPFLAGS) $(XZ_CPPFLAGS) $(LZO_CPPFLAGS) \
22 $(LZ4_CPPFLAGS)
23 -libsquashfuse_la_LIBADD =
24 +libsquashfuse_la_LIBADD = -ldl
26 # Helper for FUSE clients: libfuseprivate
27 libfuseprivate_la_SOURCES = fuseprivate.c nonstd-makedev.c nonstd-enoattr.c \
28 --- a/fuseprivate.c
29 +++ b/fuseprivate.c
30 @@ -94,15 +94,17 @@
33 void sqfs_usage(char *progname, bool fuse_usage) {
34 + LOAD_SYMBOL(int,fuse_opt_add_arg,(struct fuse_args *args, const char *arg));
35 + LOAD_SYMBOL(int,fuse_parse_cmdline,(struct fuse_args *args, char **mountpoint, int *multithreaded, int *foreground));
36 fprintf(stderr, "%s (c) 2012 Dave Vasilevsky\n\n", PACKAGE_STRING);
37 fprintf(stderr, "Usage: %s [options] ARCHIVE MOUNTPOINT\n",
38 progname ? progname : PACKAGE_NAME);
39 if (fuse_usage) {
40 struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
41 - fuse_opt_add_arg(&args, ""); /* progname */
42 - fuse_opt_add_arg(&args, "-ho");
43 + DL(fuse_opt_add_arg)(&args, ""); /* progname */
44 + DL(fuse_opt_add_arg)(&args, "-ho");
45 fprintf(stderr, "\n");
46 - fuse_parse_cmdline(&args, NULL, NULL, NULL);
47 + DL(fuse_parse_cmdline)(&args, NULL, NULL, NULL);
49 exit(-2);
51 --- a/fuseprivate.h
52 +++ b/fuseprivate.h
53 @@ -27,7 +27,10 @@
55 #include "squashfuse.h"
57 -#include <fuse.h>
58 +#include "squashfuse_dlopen.h"
59 +#ifndef ENABLE_DLOPEN
60 +# include <fuse.h>
61 +#endif
63 #include <sys/stat.h>
65 --- a/hl.c
66 +++ b/hl.c
67 @@ -33,6 +33,7 @@
68 #include <stdlib.h>
69 #include <string.h>
71 +int have_libloaded = 0;
73 typedef struct sqfs_hl sqfs_hl;
74 struct sqfs_hl {
75 @@ -42,9 +43,10 @@
77 static sqfs_err sqfs_hl_lookup(sqfs **fs, sqfs_inode *inode,
78 const char *path) {
79 + LOAD_SYMBOL(struct fuse_context *,fuse_get_context,(void));
80 bool found;
82 - sqfs_hl *hl = fuse_get_context()->private_data;
83 + sqfs_hl *hl = DL(fuse_get_context)()->private_data;
84 *fs = &hl->fs;
85 if (inode)
86 *inode = hl->root; /* copy */
87 @@ -67,7 +69,8 @@
90 static void *sqfs_hl_op_init(struct fuse_conn_info *conn) {
91 - return fuse_get_context()->private_data;
92 + LOAD_SYMBOL(struct fuse_context *,fuse_get_context,(void));
93 + return DL(fuse_get_context)()->private_data;
96 static int sqfs_hl_op_getattr(const char *path, struct stat *st) {
97 @@ -264,7 +267,16 @@
98 return NULL;
101 +#ifdef ENABLE_DLOPEN
102 +#define fuse_main(argc, argv, op, user_data) \
103 + DL(fuse_main_real)(argc, argv, op, sizeof(*(op)), user_data)
104 +#endif
106 int main(int argc, char *argv[]) {
107 + LOAD_SYMBOL(int,fuse_opt_parse,(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc));
108 + LOAD_SYMBOL(int,fuse_opt_add_arg,(struct fuse_args *args, const char *arg));
109 + LOAD_SYMBOL(int,fuse_main_real,(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, void *user_data)); /* fuse_main */
110 + LOAD_SYMBOL(void,fuse_opt_free_args,(struct fuse_args *args));
111 struct fuse_args args;
112 sqfs_opts opts;
113 sqfs_hl *hl;
114 @@ -299,7 +311,7 @@
115 opts.image = NULL;
116 opts.mountpoint = 0;
117 opts.offset = 0;
118 - if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
119 + if (DL(fuse_opt_parse)(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
120 sqfs_usage(argv[0], true);
121 if (!opts.image)
122 sqfs_usage(argv[0], true);
123 @@ -308,8 +320,9 @@
124 if (!hl)
125 return -1;
127 - fuse_opt_add_arg(&args, "-s"); /* single threaded */
128 + DL(fuse_opt_add_arg)(&args, "-s"); /* single threaded */
129 ret = fuse_main(args.argc, args.argv, &sqfs_hl_ops, hl);
130 - fuse_opt_free_args(&args);
131 + DL(fuse_opt_free_args)(&args);
132 + CLOSE_LIBRARY;
133 return ret;
135 --- a/ll.h
136 +++ b/ll.h
137 @@ -27,7 +27,10 @@
139 #include "squashfuse.h"
141 -#include <fuse_lowlevel.h>
142 +#include "squashfuse_dlopen.h"
143 +#ifndef ENABLE_DLOPEN
144 +# include <fuse_lowlevel.h>
145 +#endif
147 typedef struct sqfs_ll sqfs_ll;
148 struct sqfs_ll {
149 --- a/ll_inode.c
150 +++ b/ll_inode.c
151 @@ -348,12 +348,14 @@
154 sqfs_err sqfs_ll_iget(fuse_req_t req, sqfs_ll_i *lli, fuse_ino_t i) {
155 + LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req));
156 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
157 sqfs_err err = SQFS_OK;
158 - lli->ll = fuse_req_userdata(req);
159 + lli->ll = DL(fuse_req_userdata)(req);
160 if (i != SQFS_FUSE_INODE_NONE) {
161 err = sqfs_ll_inode(lli->ll, &lli->inode, i);
162 if (err)
163 - fuse_reply_err(req, ENOENT);
164 + DL(fuse_reply_err)(req, ENOENT);
166 return err;
168 --- a/nonstd-daemon.c
169 +++ b/nonstd-daemon.c
170 @@ -28,11 +28,16 @@
171 #include "nonstd-internal.h"
173 #include <unistd.h>
174 -#include <fuse_lowlevel.h>
176 +#include "squashfuse_dlopen.h"
177 +#ifndef ENABLE_DLOPEN
178 +# include <fuse_lowlevel.h>
179 +#endif
181 int sqfs_ll_daemonize(int fg) {
182 #if HAVE_DECL_FUSE_DAEMONIZE
183 - return fuse_daemonize(fg);
184 + LOAD_SYMBOL(int,fuse_daemonize,(int foreground));
185 + return DL(fuse_daemonize)(fg);
186 #else
187 return daemon(0,0);
188 #endif
189 --- a/ll.c
190 +++ b/ll.c
191 @@ -38,37 +38,41 @@
193 static void sqfs_ll_op_getattr(fuse_req_t req, fuse_ino_t ino,
194 struct fuse_file_info *fi) {
195 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
196 + LOAD_SYMBOL(int,fuse_reply_attr,(fuse_req_t req, const struct stat *attr, double attr_timeout));
197 sqfs_ll_i lli;
198 struct stat st;
199 if (sqfs_ll_iget(req, &lli, ino))
200 return;
202 if (sqfs_stat(&lli.ll->fs, &lli.inode, &st)) {
203 - fuse_reply_err(req, ENOENT);
204 + DL(fuse_reply_err)(req, ENOENT);
205 } else {
206 st.st_ino = ino;
207 - fuse_reply_attr(req, &st, SQFS_TIMEOUT);
208 + DL(fuse_reply_attr)(req, &st, SQFS_TIMEOUT);
212 static void sqfs_ll_op_opendir(fuse_req_t req, fuse_ino_t ino,
213 struct fuse_file_info *fi) {
214 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
215 + LOAD_SYMBOL(int,fuse_reply_open,(fuse_req_t req, const struct fuse_file_info *fi));
216 sqfs_ll_i *lli;
218 fi->fh = (intptr_t)NULL;
220 lli = malloc(sizeof(*lli));
221 if (!lli) {
222 - fuse_reply_err(req, ENOMEM);
223 + DL(fuse_reply_err)(req, ENOMEM);
224 return;
227 if (sqfs_ll_iget(req, lli, ino) == SQFS_OK) {
228 if (!S_ISDIR(lli->inode.base.mode)) {
229 - fuse_reply_err(req, ENOTDIR);
230 + DL(fuse_reply_err)(req, ENOTDIR);
231 } else {
232 fi->fh = (intptr_t)lli;
233 - fuse_reply_open(req, fi);
234 + DL(fuse_reply_open)(req, fi);
235 return;
238 @@ -77,28 +81,35 @@
240 static void sqfs_ll_op_create(fuse_req_t req, fuse_ino_t parent, const char *name,
241 mode_t mode, struct fuse_file_info *fi) {
242 - fuse_reply_err(req, EROFS);
243 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
244 + DL(fuse_reply_err)(req, EROFS);
247 static void sqfs_ll_op_releasedir(fuse_req_t req, fuse_ino_t ino,
248 struct fuse_file_info *fi) {
249 free((sqfs_ll_i*)(intptr_t)fi->fh);
250 - fuse_reply_err(req, 0); /* yes, this is necessary */
251 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
252 + DL(fuse_reply_err)(req, 0); /* yes, this is necessary */
255 static size_t sqfs_ll_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
256 const char *name, const struct stat *st, off_t off) {
257 #if HAVE_DECL_FUSE_ADD_DIRENTRY
258 - return fuse_add_direntry(req, buf, bufsize, name, st, off);
259 + 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));
260 + return DL(fuse_add_direntry)(req, buf, bufsize, name, st, off);
261 #else
262 - size_t esize = fuse_dirent_size(strlen(name));
263 + LOAD_SYMBOL(size_t,fuse_dirent_size(size_t namelen));
264 + LOAD_SYMBOL(char *,fuse_add_dirent,(char *buf, const char *name, const struct stat *stbuf, off_t off));
265 + size_t esize = DL(fuse_dirent_size)(strlen(name));
266 if (bufsize >= esize)
267 - fuse_add_dirent(buf, name, st, off);
268 + DL(fuse_add_dirent)(buf, name, st, off);
269 return esize;
270 #endif
272 static void sqfs_ll_op_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
273 off_t off, struct fuse_file_info *fi) {
274 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
275 + LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
276 sqfs_err sqerr;
277 sqfs_dir dir;
278 sqfs_name namebuf;
279 @@ -135,14 +146,16 @@
282 if (err)
283 - fuse_reply_err(req, err);
284 + DL(fuse_reply_err)(req, err);
285 else
286 - fuse_reply_buf(req, buf, bufpos - buf);
287 + DL(fuse_reply_buf)(req, buf, bufpos - buf);
288 free(buf);
291 static void sqfs_ll_op_lookup(fuse_req_t req, fuse_ino_t parent,
292 const char *name) {
293 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
294 + LOAD_SYMBOL(int,fuse_reply_entry,(fuse_req_t req, const struct fuse_entry_param *e));
295 sqfs_ll_i lli;
296 sqfs_err sqerr;
297 sqfs_name namebuf;
298 @@ -154,7 +167,7 @@
299 return;
301 if (!S_ISDIR(lli.inode.base.mode)) {
302 - fuse_reply_err(req, ENOTDIR);
303 + DL(fuse_reply_err)(req, ENOTDIR);
304 return;
307 @@ -162,55 +175,58 @@
308 sqerr = sqfs_dir_lookup(&lli.ll->fs, &lli.inode, name, strlen(name), &entry,
309 &found);
310 if (sqerr) {
311 - fuse_reply_err(req, EIO);
312 + DL(fuse_reply_err)(req, EIO);
313 return;
315 if (!found) {
316 - fuse_reply_err(req, ENOENT);
317 + DL(fuse_reply_err)(req, ENOENT);
318 return;
321 if (sqfs_inode_get(&lli.ll->fs, &inode, sqfs_dentry_inode(&entry))) {
322 - fuse_reply_err(req, ENOENT);
323 + DL(fuse_reply_err)(req, ENOENT);
324 } else {
325 struct fuse_entry_param fentry;
326 memset(&fentry, 0, sizeof(fentry));
327 if (sqfs_stat(&lli.ll->fs, &inode, &fentry.attr)) {
328 - fuse_reply_err(req, EIO);
329 + DL(fuse_reply_err)(req, EIO);
330 } else {
331 fentry.attr_timeout = fentry.entry_timeout = SQFS_TIMEOUT;
332 fentry.ino = lli.ll->ino_register(lli.ll, &entry);
333 fentry.attr.st_ino = fentry.ino;
334 - fuse_reply_entry(req, &fentry);
335 + DL(fuse_reply_entry)(req, &fentry);
340 static void sqfs_ll_op_open(fuse_req_t req, fuse_ino_t ino,
341 struct fuse_file_info *fi) {
342 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
343 + LOAD_SYMBOL(int,fuse_reply_open,(fuse_req_t req, const struct fuse_file_info *fi));
344 + LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req));
345 sqfs_inode *inode;
346 sqfs_ll *ll;
348 if (fi->flags & (O_WRONLY | O_RDWR)) {
349 - fuse_reply_err(req, EROFS);
350 + DL(fuse_reply_err)(req, EROFS);
351 return;
354 inode = malloc(sizeof(sqfs_inode));
355 if (!inode) {
356 - fuse_reply_err(req, ENOMEM);
357 + DL(fuse_reply_err)(req, ENOMEM);
358 return;
361 - ll = fuse_req_userdata(req);
362 + ll = DL(fuse_req_userdata)(req);
363 if (sqfs_ll_inode(ll, inode, ino)) {
364 - fuse_reply_err(req, ENOENT);
365 + DL(fuse_reply_err)(req, ENOENT);
366 } else if (!S_ISREG(inode->base.mode)) {
367 - fuse_reply_err(req, EISDIR);
368 + DL(fuse_reply_err)(req, EISDIR);
369 } else {
370 fi->fh = (intptr_t)inode;
371 fi->keep_cache = 1;
372 - fuse_reply_open(req, fi);
373 + DL(fuse_reply_open)(req, fi);
374 return;
376 free(inode);
377 @@ -218,37 +234,43 @@
379 static void sqfs_ll_op_release(fuse_req_t req, fuse_ino_t ino,
380 struct fuse_file_info *fi) {
381 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
382 free((sqfs_inode*)(intptr_t)fi->fh);
383 fi->fh = 0;
384 - fuse_reply_err(req, 0);
385 + DL(fuse_reply_err)(req, 0);
388 static void sqfs_ll_op_read(fuse_req_t req, fuse_ino_t ino,
389 size_t size, off_t off, struct fuse_file_info *fi) {
390 - sqfs_ll *ll = fuse_req_userdata(req);
391 + LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req));
392 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
393 + LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
394 + sqfs_ll *ll = DL(fuse_req_userdata)(req);
395 sqfs_inode *inode = (sqfs_inode*)(intptr_t)fi->fh;
396 sqfs_err err = SQFS_OK;
398 off_t osize;
399 char *buf = malloc(size);
400 if (!buf) {
401 - fuse_reply_err(req, ENOMEM);
402 + DL(fuse_reply_err)(req, ENOMEM);
403 return;
406 osize = size;
407 err = sqfs_read_range(&ll->fs, inode, off, &osize, buf);
408 if (err) {
409 - fuse_reply_err(req, EIO);
410 + DL(fuse_reply_err)(req, EIO);
411 } else if (osize == 0) { /* EOF */
412 - fuse_reply_buf(req, NULL, 0);
413 + DL(fuse_reply_buf)(req, NULL, 0);
414 } else {
415 - fuse_reply_buf(req, buf, osize);
416 + DL(fuse_reply_buf)(req, buf, osize);
418 free(buf);
421 static void sqfs_ll_op_readlink(fuse_req_t req, fuse_ino_t ino) {
422 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
423 + LOAD_SYMBOL(int,fuse_reply_readlink,(fuse_req_t req, const char *link));
424 char *dst;
425 size_t size;
426 sqfs_ll_i lli;
427 @@ -256,21 +278,24 @@
428 return;
430 if (!S_ISLNK(lli.inode.base.mode)) {
431 - fuse_reply_err(req, EINVAL);
432 + DL(fuse_reply_err)(req, EINVAL);
433 } else if (sqfs_readlink(&lli.ll->fs, &lli.inode, NULL, &size)) {
434 - fuse_reply_err(req, EIO);
435 + DL(fuse_reply_err)(req, EIO);
436 } else if (!(dst = malloc(size + 1))) {
437 - fuse_reply_err(req, ENOMEM);
438 + DL(fuse_reply_err)(req, ENOMEM);
439 } else if (sqfs_readlink(&lli.ll->fs, &lli.inode, dst, &size)) {
440 - fuse_reply_err(req, EIO);
441 + DL(fuse_reply_err)(req, EIO);
442 free(dst);
443 } else {
444 - fuse_reply_readlink(req, dst);
445 + DL(fuse_reply_readlink)(req, dst);
446 free(dst);
450 static void sqfs_ll_op_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size) {
451 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
452 + LOAD_SYMBOL(int,fuse_reply_xattr,(fuse_req_t req, size_t count));
453 + LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
454 sqfs_ll_i lli;
455 char *buf;
456 int ferr;
457 @@ -280,17 +305,17 @@
459 buf = NULL;
460 if (size && !(buf = malloc(size))) {
461 - fuse_reply_err(req, ENOMEM);
462 + DL(fuse_reply_err)(req, ENOMEM);
463 return;
466 ferr = sqfs_listxattr(&lli.ll->fs, &lli.inode, buf, &size);
467 if (ferr) {
468 - fuse_reply_err(req, ferr);
469 + DL(fuse_reply_err)(req, ferr);
470 } else if (buf) {
471 - fuse_reply_buf(req, buf, size);
472 + DL(fuse_reply_buf)(req, buf, size);
473 } else {
474 - fuse_reply_xattr(req, size);
475 + DL(fuse_reply_xattr)(req, size);
477 free(buf);
479 @@ -301,13 +326,16 @@
480 , uint32_t position
481 #endif
483 + LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err));
484 + LOAD_SYMBOL(int,fuse_reply_xattr,(fuse_req_t req, size_t count));
485 + LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size));
486 sqfs_ll_i lli;
487 char *buf = NULL;
488 size_t real = size;
490 #ifdef FUSE_XATTR_POSITION
491 if (position != 0) { /* We don't support resource forks */
492 - fuse_reply_err(req, EINVAL);
493 + DL(fuse_reply_err)(req, EINVAL);
494 return;
496 #endif
497 @@ -316,26 +344,27 @@
498 return;
500 if (!(buf = malloc(size)))
501 - fuse_reply_err(req, ENOMEM);
502 + DL(fuse_reply_err)(req, ENOMEM);
503 else if (sqfs_xattr_lookup(&lli.ll->fs, &lli.inode, name, buf, &real))
504 - fuse_reply_err(req, EIO);
505 + DL(fuse_reply_err)(req, EIO);
506 else if (real == 0)
507 - fuse_reply_err(req, sqfs_enoattr());
508 + DL(fuse_reply_err)(req, sqfs_enoattr());
509 else if (size == 0)
510 - fuse_reply_xattr(req, real);
511 + DL(fuse_reply_xattr)(req, real);
512 else if (size < real)
513 - fuse_reply_err(req, ERANGE);
514 + DL(fuse_reply_err)(req, ERANGE);
515 else
516 - fuse_reply_buf(req, buf, real);
517 + DL(fuse_reply_buf)(req, buf, real);
518 free(buf);
521 static void sqfs_ll_op_forget(fuse_req_t req, fuse_ino_t ino,
522 unsigned long nlookup) {
523 + LOAD_SYMBOL(void,fuse_reply_none,(fuse_req_t req));
524 sqfs_ll_i lli;
525 sqfs_ll_iget(req, &lli, SQFS_FUSE_INODE_NONE);
526 lli.ll->ino_forget(lli.ll, ino, nlookup);
527 - fuse_reply_none(req);
528 + DL(fuse_reply_none)(req);
532 @@ -348,23 +377,27 @@
534 static sqfs_err sqfs_ll_mount(sqfs_ll_chan *ch, const char *mountpoint,
535 struct fuse_args *args) {
536 + LOAD_SYMBOL(struct fuse_chan *,fuse_mount,(const char *mountpoint, struct fuse_args *args));
537 #ifdef HAVE_NEW_FUSE_UNMOUNT
538 - ch->ch = fuse_mount(mountpoint, args);
539 + ch->ch = DL(fuse_mount)(mountpoint, args);
540 #else
541 - ch->fd = fuse_mount(mountpoint, args);
542 + LOAD_SYMBOL(struct fuse_chan *,fuse_kern_chan_new,(int fd));
543 + ch->fd = DL(fuse_mount)(mountpoint, args);
544 if (ch->fd == -1)
545 return SQFS_ERR;
546 - ch->ch = fuse_kern_chan_new(ch->fd);
547 + ch->ch = DL(fuse_kern_chan_new)(ch->fd);
548 #endif
549 return ch->ch ? SQFS_OK : SQFS_ERR;
552 static void sqfs_ll_unmount(sqfs_ll_chan *ch, const char *mountpoint) {
553 #ifdef HAVE_NEW_FUSE_UNMOUNT
554 - fuse_unmount(mountpoint, ch->ch);
555 + LOAD_SYMBOL(void,fuse_unmount,(const char *mountpoint, struct fuse_chan *ch));
556 + DL(fuse_unmount)(mountpoint, ch->ch);
557 #else
558 + LOAD_SYMBOL(void,fuse_unmount,(const char *mountpoint));
559 close(ch->fd);
560 - fuse_unmount(mountpoint);
561 + DL(fuse_unmount)(mountpoint);
562 #endif
565 @@ -391,6 +424,19 @@
568 int fusefs_main(int argc, char *argv[], void (*mounted) (void)) {
569 + LOAD_SYMBOL(int,fuse_opt_parse,(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc));
570 + LOAD_SYMBOL(int,fuse_parse_cmdline,(struct fuse_args *args, char **mountpoint, int *multithreaded, int *foreground));
571 + LOAD_SYMBOL(struct fuse_session *,fuse_lowlevel_new,(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata));
572 + LOAD_SYMBOL(int,fuse_set_signal_handlers,(struct fuse_session *se));
573 + LOAD_SYMBOL(void,fuse_session_add_chan,(struct fuse_session *se, struct fuse_chan *ch));
574 + LOAD_SYMBOL(int,fuse_session_loop,(struct fuse_session *se));
575 + LOAD_SYMBOL(void,fuse_remove_signal_handlers,(struct fuse_session *se));
576 +#if HAVE_DECL_FUSE_SESSION_REMOVE_CHAN
577 + LOAD_SYMBOL(void,fuse_session_remove_chan,(struct fuse_chan *ch));
578 +#endif
579 + LOAD_SYMBOL(void,fuse_session_destroy,(struct fuse_session *se));
580 + LOAD_SYMBOL(void,fuse_opt_free_args,(struct fuse_args *args));
582 struct fuse_args args;
583 sqfs_opts opts;
585 @@ -429,10 +475,10 @@
586 opts.image = NULL;
587 opts.mountpoint = 0;
588 opts.offset = 0;
589 - if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
590 + if (DL(fuse_opt_parse)(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
591 sqfs_usage(argv[0], true);
593 - if (fuse_parse_cmdline(&args, &mountpoint, &mt, &fg) == -1)
594 + if (DL(fuse_parse_cmdline)(&args, &mountpoint, &mt, &fg) == -1)
595 sqfs_usage(argv[0], true);
596 if (mountpoint == NULL)
597 sqfs_usage(argv[0], true);
598 @@ -445,33 +491,34 @@
599 sqfs_ll_chan ch;
600 err = -1;
601 if (sqfs_ll_mount(&ch, mountpoint, &args) == SQFS_OK) {
602 - struct fuse_session *se = fuse_lowlevel_new(&args,
603 + struct fuse_session *se = DL(fuse_lowlevel_new)(&args,
604 &sqfs_ll_ops, sizeof(sqfs_ll_ops), ll);
605 if (se != NULL) {
606 if (sqfs_ll_daemonize(fg) != -1) {
607 - if (fuse_set_signal_handlers(se) != -1) {
608 - fuse_session_add_chan(se, ch.ch);
609 + if (DL(fuse_set_signal_handlers)(se) != -1) {
610 + DL(fuse_session_add_chan)(se, ch.ch);
611 if (mounted)
612 mounted ();
613 /* FIXME: multithreading */
614 - err = fuse_session_loop(se);
615 - fuse_remove_signal_handlers(se);
616 + err = DL(fuse_session_loop)(se);
617 + DL(fuse_remove_signal_handlers)(se);
618 #if HAVE_DECL_FUSE_SESSION_REMOVE_CHAN
619 - fuse_session_remove_chan(ch.ch);
620 + DL(fuse_session_remove_chan)(ch.ch);
621 #endif
624 - fuse_session_destroy(se);
625 + DL(fuse_session_destroy)(se);
627 sqfs_ll_destroy(ll);
628 sqfs_ll_unmount(&ch, mountpoint);
631 - fuse_opt_free_args(&args);
632 + DL(fuse_opt_free_args)(&args);
633 if (mounted)
634 rmdir (mountpoint);
635 free(ll);
636 free(mountpoint);
637 + CLOSE_LIBRARY;
639 return -err;