1 Index: fuse-2.7.1/include/fuse_common_compat.h
2 ===================================================================
3 --- fuse-2.7.1.orig/include/fuse_common_compat.h 2007-10-20 17:13:51.409738304 +0200
4 +++ fuse-2.7.1/include/fuse_common_compat.h 2007-10-20 17:14:26.323727941 +0200
6 unsigned int keep_cache : 1;
9 +#ifndef DISABLE_COMPAT
10 int fuse_mount_compat25(const char *mountpoint, struct fuse_args *args);
12 int fuse_mount_compat22(const char *mountpoint, const char *opts);
14 int fuse_mount_compat1(const char *mountpoint, const char *args[]);
16 void fuse_unmount_compat22(const char *mountpoint);
19 Index: fuse-2.7.1/lib/fuse.c
20 ===================================================================
21 --- fuse-2.7.1.orig/lib/fuse.c 2007-10-20 17:13:51.417738760 +0200
22 +++ fuse-2.7.1/lib/fuse.c 2007-10-20 17:26:30.657005340 +0200
24 #include "fuse_lowlevel.h"
26 #include "fuse_misc.h"
27 -#include "fuse_common_compat.h"
28 -#include "fuse_compat.h"
33 fuse_do_prepare_interrupt(req, d);
38 -static int fuse_compat_open(struct fuse_fs *fs, const char *path,
39 - struct fuse_file_info *fi)
42 - if (!fs->compat || fs->compat >= 25)
43 - err = fs->op.open(path, fi);
44 - else if (fs->compat == 22) {
45 - struct fuse_file_info_compat tmp;
46 - memcpy(&tmp, fi, sizeof(tmp));
47 - err = ((struct fuse_operations_compat22 *) &fs->op)->open(path, &tmp);
48 - memcpy(fi, &tmp, sizeof(tmp));
51 - err = ((struct fuse_operations_compat2 *) &fs->op)
52 - ->open(path, fi->flags);
56 -static int fuse_compat_release(struct fuse_fs *fs, const char *path,
57 - struct fuse_file_info *fi)
59 - if (!fs->compat || fs->compat >= 22)
60 - return fs->op.release(path, fi);
62 - return ((struct fuse_operations_compat2 *) &fs->op)
63 - ->release(path, fi->flags);
66 -static int fuse_compat_opendir(struct fuse_fs *fs, const char *path,
67 - struct fuse_file_info *fi)
69 - if (!fs->compat || fs->compat >= 25)
70 - return fs->op.opendir(path, fi);
73 - struct fuse_file_info_compat tmp;
74 - memcpy(&tmp, fi, sizeof(tmp));
75 - err = ((struct fuse_operations_compat22 *) &fs->op)
76 - ->opendir(path, &tmp);
77 - memcpy(fi, &tmp, sizeof(tmp));
83 -static void convert_statfs_compat(struct fuse_statfs_compat1 *compatbuf,
84 - struct statvfs *stbuf)
86 - stbuf->f_bsize = compatbuf->block_size;
87 - stbuf->f_blocks = compatbuf->blocks;
88 - stbuf->f_bfree = compatbuf->blocks_free;
89 - stbuf->f_bavail = compatbuf->blocks_free;
90 - stbuf->f_files = compatbuf->files;
91 - stbuf->f_ffree = compatbuf->files_free;
92 - stbuf->f_namemax = compatbuf->namelen;
95 -static void convert_statfs_old(struct statfs *oldbuf, struct statvfs *stbuf)
97 - stbuf->f_bsize = oldbuf->f_bsize;
98 - stbuf->f_blocks = oldbuf->f_blocks;
99 - stbuf->f_bfree = oldbuf->f_bfree;
100 - stbuf->f_bavail = oldbuf->f_bavail;
101 - stbuf->f_files = oldbuf->f_files;
102 - stbuf->f_ffree = oldbuf->f_ffree;
103 - stbuf->f_namemax = oldbuf->f_namelen;
106 -static int fuse_compat_statfs(struct fuse_fs *fs, const char *path,
107 - struct statvfs *buf)
111 - if (!fs->compat || fs->compat >= 25) {
112 - err = fs->op.statfs(fs->compat == 25 ? "/" : path, buf);
113 - } else if (fs->compat > 11) {
114 - struct statfs oldbuf;
115 - err = ((struct fuse_operations_compat22 *) &fs->op)
116 - ->statfs("/", &oldbuf);
118 - convert_statfs_old(&oldbuf, buf);
120 - struct fuse_statfs_compat1 compatbuf;
121 - memset(&compatbuf, 0, sizeof(struct fuse_statfs_compat1));
122 - err = ((struct fuse_operations_compat1 *) &fs->op)->statfs(&compatbuf);
124 - convert_statfs_compat(&compatbuf, buf);
129 -#else /* __FreeBSD__ */
131 -static inline int fuse_compat_open(struct fuse_fs *fs, char *path,
132 - struct fuse_file_info *fi)
134 - return fs->op.open(path, fi);
137 -static inline int fuse_compat_release(struct fuse_fs *fs, const char *path,
138 - struct fuse_file_info *fi)
140 - return fs->op.release(path, fi);
143 -static inline int fuse_compat_opendir(struct fuse_fs *fs, const char *path,
144 - struct fuse_file_info *fi)
146 - return fs->op.opendir(path, fi);
149 -static inline int fuse_compat_statfs(struct fuse_fs *fs, const char *path,
150 - struct statvfs *buf)
152 - return fs->op.statfs(fs->compat == 25 ? "/" : path, buf);
155 -#endif /* __FreeBSD__ */
157 int fuse_fs_getattr(struct fuse_fs *fs, const char *path, struct stat *buf)
159 fuse_get_context()->private_data = fs->user_data;
162 fuse_get_context()->private_data = fs->user_data;
164 - return fuse_compat_release(fs, path, fi);
165 + return fs->op.release(path, fi);
171 fuse_get_context()->private_data = fs->user_data;
173 - return fuse_compat_opendir(fs, path, fi);
174 + return fs->op.opendir(path, fi);
180 fuse_get_context()->private_data = fs->user_data;
182 - return fuse_compat_open(fs, path, fi);
183 + return fs->op.open(path, fi);
189 fuse_get_context()->private_data = fs->user_data;
191 - return fuse_compat_statfs(fs, path, buf);
192 + return fs->op.statfs(path, buf);
194 buf->f_namemax = 255;
196 @@ -3037,7 +2914,6 @@
200 - fs->compat = compat;
203 /* Oh f**k, this is ugly! */
204 @@ -3079,11 +2955,6 @@
205 f->conf.readdir_ino = 1;
208 - if (compat && compat <= 25) {
209 - if (fuse_sync_compat_args(args) == -1)
213 f->se = fuse_lowlevel_new_common(args, &llop, sizeof(llop), f);
216 @@ -3217,19 +3088,6 @@
217 fuse_delete_context_key();
220 -static struct fuse *fuse_new_common_compat25(int fd, struct fuse_args *args,
221 - const struct fuse_operations *op,
222 - size_t op_size, int compat)
224 - struct fuse *f = NULL;
225 - struct fuse_chan *ch = fuse_kern_chan_new(fd);
228 - f = fuse_new_common(ch, args, op, op_size, NULL, compat);
233 /* called with fuse_context_lock held or during initialization (before
234 main() has been called) */
235 void fuse_register_module(struct fuse_module *mod)
236 @@ -3242,69 +3100,3 @@
242 -static struct fuse *fuse_new_common_compat(int fd, const char *opts,
243 - const struct fuse_operations *op,
244 - size_t op_size, int compat)
247 - struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
249 - if (fuse_opt_add_arg(&args, "") == -1)
252 - (fuse_opt_add_arg(&args, "-o") == -1 ||
253 - fuse_opt_add_arg(&args, opts) == -1)) {
254 - fuse_opt_free_args(&args);
257 - f = fuse_new_common_compat25(fd, &args, op, op_size, compat);
258 - fuse_opt_free_args(&args);
263 -struct fuse *fuse_new_compat22(int fd, const char *opts,
264 - const struct fuse_operations_compat22 *op,
267 - return fuse_new_common_compat(fd, opts, (struct fuse_operations *) op,
271 -struct fuse *fuse_new_compat2(int fd, const char *opts,
272 - const struct fuse_operations_compat2 *op)
274 - return fuse_new_common_compat(fd, opts, (struct fuse_operations *) op,
275 - sizeof(struct fuse_operations_compat2), 21);
278 -struct fuse *fuse_new_compat1(int fd, int flags,
279 - const struct fuse_operations_compat1 *op)
281 - const char *opts = NULL;
282 - if (flags & FUSE_DEBUG_COMPAT1)
284 - return fuse_new_common_compat(fd, opts, (struct fuse_operations *) op,
285 - sizeof(struct fuse_operations_compat1), 11);
288 -__asm__(".symver fuse_exited,__fuse_exited@");
289 -__asm__(".symver fuse_process_cmd,__fuse_process_cmd@");
290 -__asm__(".symver fuse_read_cmd,__fuse_read_cmd@");
291 -__asm__(".symver fuse_set_getcontext_func,__fuse_set_getcontext_func@");
292 -__asm__(".symver fuse_new_compat2,fuse_new@");
293 -__asm__(".symver fuse_new_compat22,fuse_new@FUSE_2.2");
295 -#endif /* __FreeBSD__ */
297 -struct fuse *fuse_new_compat25(int fd, struct fuse_args *args,
298 - const struct fuse_operations_compat25 *op,
301 - return fuse_new_common_compat25(fd, args, (struct fuse_operations *) op,
305 -__asm__(".symver fuse_new_compat25,fuse_new@FUSE_2.5");
306 Index: fuse-2.7.1/lib/fuse_lowlevel.c
307 ===================================================================
308 --- fuse-2.7.1.orig/lib/fuse_lowlevel.c 2007-10-20 17:13:51.425739218 +0200
309 +++ fuse-2.7.1/lib/fuse_lowlevel.c 2007-10-20 17:22:46.396225455 +0200
311 #include "fuse_opt.h"
313 #include "fuse_misc.h"
314 -#include "fuse_common_compat.h"
315 -#include "fuse_lowlevel_compat.h"
319 @@ -1310,129 +1308,3 @@
320 return fuse_lowlevel_new_common(args, op, op_size, userdata);
326 -static void fill_open_compat(struct fuse_open_out *arg,
327 - const struct fuse_file_info_compat *f)
331 - arg->open_flags |= FOPEN_DIRECT_IO;
333 - arg->open_flags |= FOPEN_KEEP_CACHE;
336 -static void convert_statfs_compat(const struct statfs *compatbuf,
337 - struct statvfs *buf)
339 - buf->f_bsize = compatbuf->f_bsize;
340 - buf->f_blocks = compatbuf->f_blocks;
341 - buf->f_bfree = compatbuf->f_bfree;
342 - buf->f_bavail = compatbuf->f_bavail;
343 - buf->f_files = compatbuf->f_files;
344 - buf->f_ffree = compatbuf->f_ffree;
345 - buf->f_namemax = compatbuf->f_namelen;
348 -int fuse_reply_open_compat(fuse_req_t req,
349 - const struct fuse_file_info_compat *f)
351 - struct fuse_open_out arg;
353 - memset(&arg, 0, sizeof(arg));
354 - fill_open_compat(&arg, f);
355 - return send_reply_ok(req, &arg, sizeof(arg));
358 -int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf)
360 - struct statvfs newbuf;
362 - memset(&newbuf, 0, sizeof(newbuf));
363 - convert_statfs_compat(stbuf, &newbuf);
365 - return fuse_reply_statfs(req, &newbuf);
368 -struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
369 - const struct fuse_lowlevel_ops_compat *op,
370 - size_t op_size, void *userdata)
372 - struct fuse_session *se;
373 - struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
376 - (fuse_opt_add_arg(&args, "") == -1 ||
377 - fuse_opt_add_arg(&args, "-o") == -1 ||
378 - fuse_opt_add_arg(&args, opts) == -1)) {
379 - fuse_opt_free_args(&args);
382 - se = fuse_lowlevel_new(&args, (const struct fuse_lowlevel_ops *) op,
383 - op_size, userdata);
384 - fuse_opt_free_args(&args);
389 -struct fuse_ll_compat_conf {
394 -static const struct fuse_opt fuse_ll_opts_compat[] = {
395 - { "max_read=", offsetof(struct fuse_ll_compat_conf, set_max_read), 1 },
396 - { "max_read=%u", offsetof(struct fuse_ll_compat_conf, max_read), 0 },
397 - FUSE_OPT_KEY("max_read=", FUSE_OPT_KEY_KEEP),
401 -int fuse_sync_compat_args(struct fuse_args *args)
403 - struct fuse_ll_compat_conf conf;
405 - memset(&conf, 0, sizeof(conf));
406 - if (fuse_opt_parse(args, &conf, fuse_ll_opts_compat, NULL) == -1)
409 - if (fuse_opt_insert_arg(args, 1, "-osync_read"))
412 - if (conf.set_max_read) {
415 - sprintf(tmpbuf, "-omax_readahead=%u", conf.max_read);
416 - if (fuse_opt_insert_arg(args, 1, tmpbuf) == -1)
422 -__asm__(".symver fuse_reply_statfs_compat,fuse_reply_statfs@FUSE_2.4");
423 -__asm__(".symver fuse_reply_open_compat,fuse_reply_open@FUSE_2.4");
424 -__asm__(".symver fuse_lowlevel_new_compat,fuse_lowlevel_new@FUSE_2.4");
426 -#else /* __FreeBSD__ */
428 -int fuse_sync_compat_args(struct fuse_args *args)
434 -#endif /* __FreeBSD__ */
436 -struct fuse_session *fuse_lowlevel_new_compat25(struct fuse_args *args,
437 - const struct fuse_lowlevel_ops_compat25 *op,
438 - size_t op_size, void *userdata)
440 - if (fuse_sync_compat_args(args) == -1)
443 - return fuse_lowlevel_new_common(args,
444 - (const struct fuse_lowlevel_ops *) op,
445 - op_size, userdata);
448 -__asm__(".symver fuse_lowlevel_new_compat25,fuse_lowlevel_new@FUSE_2.5");
449 Index: fuse-2.7.1/lib/helper.c
450 ===================================================================
451 --- fuse-2.7.1.orig/lib/helper.c 2007-10-20 17:13:51.433739673 +0200
452 +++ fuse-2.7.1/lib/helper.c 2007-10-20 17:21:32.508014797 +0200
455 #include "fuse_opt.h"
456 #include "fuse_lowlevel.h"
457 -#include "fuse_common_compat.h"
463 } while (fd >= 0 && fd <= 2);
465 - fd = fuse_mount_compat25(mountpoint, args);
466 + fd = fuse_kern_mount(mountpoint, args);
475 -#include "fuse_compat.h"
479 -struct fuse *fuse_setup_compat22(int argc, char *argv[],
480 - const struct fuse_operations_compat22 *op,
481 - size_t op_size, char **mountpoint,
482 - int *multithreaded, int *fd)
484 - return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
485 - op_size, mountpoint, multithreaded, fd, NULL, 22);
488 -struct fuse *fuse_setup_compat2(int argc, char *argv[],
489 - const struct fuse_operations_compat2 *op,
490 - char **mountpoint, int *multithreaded,
493 - return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
494 - sizeof(struct fuse_operations_compat2),
495 - mountpoint, multithreaded, fd, NULL, 21);
498 -int fuse_main_real_compat22(int argc, char *argv[],
499 - const struct fuse_operations_compat22 *op,
502 - return fuse_main_common(argc, argv, (struct fuse_operations *) op, op_size,
506 -void fuse_main_compat1(int argc, char *argv[],
507 - const struct fuse_operations_compat1 *op)
509 - fuse_main_common(argc, argv, (struct fuse_operations *) op,
510 - sizeof(struct fuse_operations_compat1), NULL, 11);
513 -int fuse_main_compat2(int argc, char *argv[],
514 - const struct fuse_operations_compat2 *op)
516 - return fuse_main_common(argc, argv, (struct fuse_operations *) op,
517 - sizeof(struct fuse_operations_compat2), NULL, 21);
520 -int fuse_mount_compat1(const char *mountpoint, const char *args[])
522 - /* just ignore mount args for now */
524 - return fuse_mount_compat22(mountpoint, NULL);
527 -__asm__(".symver fuse_setup_compat2,__fuse_setup@");
528 -__asm__(".symver fuse_setup_compat22,fuse_setup@FUSE_2.2");
529 -__asm__(".symver fuse_teardown,__fuse_teardown@");
530 -__asm__(".symver fuse_main_compat2,fuse_main@");
531 -__asm__(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");
533 -#endif /* __FreeBSD__ */
536 -struct fuse *fuse_setup_compat25(int argc, char *argv[],
537 - const struct fuse_operations_compat25 *op,
538 - size_t op_size, char **mountpoint,
539 - int *multithreaded, int *fd)
541 - return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
542 - op_size, mountpoint, multithreaded, fd, NULL, 25);
545 -int fuse_main_real_compat25(int argc, char *argv[],
546 - const struct fuse_operations_compat25 *op,
549 - return fuse_main_common(argc, argv, (struct fuse_operations *) op, op_size,
553 -void fuse_teardown_compat22(struct fuse *fuse, int fd, char *mountpoint)
556 - fuse_teardown_common(fuse, mountpoint);
559 -int fuse_mount_compat25(const char *mountpoint, struct fuse_args *args)
561 - return fuse_kern_mount(mountpoint, args);
564 -__asm__(".symver fuse_setup_compat25,fuse_setup@FUSE_2.5");
565 -__asm__(".symver fuse_teardown_compat22,fuse_teardown@FUSE_2.2");
566 -__asm__(".symver fuse_main_real_compat25,fuse_main_real@FUSE_2.5");
567 -__asm__(".symver fuse_mount_compat25,fuse_mount@FUSE_2.5");
568 Index: fuse-2.7.1/lib/mount.c
569 ===================================================================
570 --- fuse-2.7.1.orig/lib/mount.c 2007-10-20 17:13:51.441740129 +0200
571 +++ fuse-2.7.1/lib/mount.c 2007-10-20 17:22:07.209992349 +0200
575 #include "fuse_opt.h"
576 -#include "fuse_common_compat.h"
577 #include "mount_util.h"
581 waitpid(pid, NULL, 0);
584 -void fuse_unmount_compat22(const char *mountpoint)
586 - fuse_kern_unmount(mountpoint, -1);
589 static int fuse_mount_fusermount(const char *mountpoint, const char *opts,
596 -int fuse_mount_compat22(const char *mountpoint, const char *opts)
598 - return fuse_mount_fusermount(mountpoint, opts, 0);
601 static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,
602 const char *mnt_opts)
608 -__asm__(".symver fuse_mount_compat22,fuse_mount@FUSE_2.2");
609 -__asm__(".symver fuse_unmount_compat22,fuse_unmount@FUSE_2.2");