forked from AppImage/AppImageKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
squashfuse_dlopen.patch
640 lines (578 loc) · 19.1 KB
/
squashfuse_dlopen.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
--- 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;
}