fix compat bugs in lowlevel interface
authorMiklos Szeredi <miklos@szeredi.hu>
Fri, 22 Sep 2006 19:30:17 +0000 (19:30 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Fri, 22 Sep 2006 19:30:17 +0000 (19:30 +0000)
ChangeLog
include/fuse.h
include/fuse_common_compat.h
include/fuse_compat.h
include/fuse_lowlevel.h
include/fuse_lowlevel_compat.h
lib/fuse.c
lib/fuse_lowlevel.c
lib/fuse_session.c

index eedd12d7441995b7bd3f1a6b43e9017f51bb7dce..7cd502365332023d88c367d5d616fef6ede415b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-22  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Fix compatibility bugs in low level interface.  Reported by
+       Ricardo Correia
+
+       * Add workaround for ARM caching bug
+
 2006-09-16  Miklos Szeredi <miklos@szeredi.hu>
 
        * Rename new utimes() method to more logical utimens()
index 1e0bd3c3da3a01c3a26e16b9ac4a24bad51c49eb..8237422d44b72e7141a91d854df031d8df49a013 100644 (file)
@@ -617,7 +617,7 @@ struct fuse_session *fuse_get_session(struct fuse *f);
 #    define fuse_new fuse_new_compat22
 #    define fuse_setup fuse_setup_compat22
 #    define fuse_operations fuse_operations_compat22
-#    define fuse_file_info fuse_file_info_compat22
+#    define fuse_file_info fuse_file_info_compat
 #  elif FUSE_USE_VERSION == 24
 #    error Compatibility with high-level API version 24 not supported
 #  else
index 6b6bf3216fee1ed1342df222ecc2a09b3014c34a..60ca944cd792f977a0169ed4cf3540dcffaeddfe 100644 (file)
@@ -9,6 +9,14 @@
 /* these definitions provide source compatibility to prior versions.
    Do not include this file directly! */
 
+struct fuse_file_info_compat {
+    int flags;
+    unsigned long fh;
+    int writepage;
+    unsigned int direct_io : 1;
+    unsigned int keep_cache : 1;
+};
+
 int fuse_mount_compat25(const char *mountpoint, struct fuse_args *args);
 
 int fuse_mount_compat22(const char *mountpoint, const char *opts);
index c89637308d00bc2882274faa988c7109c92b74d1..c8393e4e40ccf21618185b578ed892f21c60e371 100644 (file)
@@ -67,14 +67,6 @@ void fuse_teardown_compat25(struct fuse *fuse, int fd, char *mountpoint);
 #ifndef __FreeBSD__
 #include <sys/statfs.h>
 
-struct fuse_file_info_compat22 {
-    int flags;
-    unsigned long fh;
-    int writepage;
-    unsigned int direct_io : 1;
-    unsigned int keep_cache : 1;
-};
-
 struct fuse_operations_compat22 {
     int (*getattr) (const char *, struct stat *);
     int (*readlink) (const char *, char *, size_t);
@@ -90,24 +82,24 @@ struct fuse_operations_compat22 {
     int (*chown) (const char *, uid_t, gid_t);
     int (*truncate) (const char *, off_t);
     int (*utime) (const char *, struct utimbuf *);
-    int (*open) (const char *, struct fuse_file_info_compat22 *);
+    int (*open) (const char *, struct fuse_file_info_compat *);
     int (*read) (const char *, char *, size_t, off_t,
-                 struct fuse_file_info_compat22 *);
+                 struct fuse_file_info_compat *);
     int (*write) (const char *, const char *, size_t, off_t,
-                  struct fuse_file_info_compat22 *);
+                  struct fuse_file_info_compat *);
     int (*statfs) (const char *, struct statfs *);
-    int (*flush) (const char *, struct fuse_file_info_compat22 *);
-    int (*release) (const char *, struct fuse_file_info_compat22 *);
-    int (*fsync) (const char *, int, struct fuse_file_info_compat22 *);
+    int (*flush) (const char *, struct fuse_file_info_compat *);
+    int (*release) (const char *, struct fuse_file_info_compat *);
+    int (*fsync) (const char *, int, struct fuse_file_info_compat *);
     int (*setxattr) (const char *, const char *, const char *, size_t, int);
     int (*getxattr) (const char *, const char *, char *, size_t);
     int (*listxattr) (const char *, char *, size_t);
     int (*removexattr) (const char *, const char *);
-    int (*opendir) (const char *, struct fuse_file_info_compat22 *);
+    int (*opendir) (const char *, struct fuse_file_info_compat *);
     int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
-                    struct fuse_file_info_compat22 *);
-    int (*releasedir) (const char *, struct fuse_file_info_compat22 *);
-    int (*fsyncdir) (const char *, int, struct fuse_file_info_compat22 *);
+                    struct fuse_file_info_compat *);
+    int (*releasedir) (const char *, struct fuse_file_info_compat *);
+    int (*fsyncdir) (const char *, int, struct fuse_file_info_compat *);
     void *(*init) (void);
     void (*destroy) (void *);
 };
index 58f568c47ea00d05b86a030f00c6f121bb08fb35..00b22bccabf20ea2b43f0997c4db0f118bf1ba83 100644 (file)
@@ -1304,17 +1304,18 @@ void fuse_chan_destroy(struct fuse_chan *ch);
 
 #if FUSE_USE_VERSION < 26
 #  include "fuse_lowlevel_compat.h"
-#  undef FUSE_MINOR_VERSION
+#  define fuse_chan_ops fuse_chan_ops_compat24
+#  define fuse_chan_new fuse_chan_new_compat24
 #  if FUSE_USE_VERSION == 25
 #    define fuse_lowlevel_ops fuse_lowlevel_ops_compat25
 #    define fuse_lowlevel_new fuse_lowlevel_new_compat25
-#    define fuse_chan_ops fuse_chan_ops_compat25
-#    define fuse_chan_new fuse_chan_new_compat25
 #  elif FUSE_USE_VERSION == 24
+#    define fuse_lowlevel_ops fuse_lowlevel_ops_compat
+#    define fuse_lowlevel_new fuse_lowlevel_new_compat
 #    define fuse_file_info fuse_file_info_compat
 #    define fuse_reply_statfs fuse_reply_statfs_compat
 #    define fuse_reply_open fuse_reply_open_compat
-#  else 
+#  else
 #    error Compatibility with low-level API version < 24 not supported
 #  endif
 #endif
index c8e767323383031465e555679f723c8a0810cfe7..285239cae4e6bf1a7bb60c6fd6f104f12596f57b 100644 (file)
@@ -71,12 +71,53 @@ char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
 
 #include <sys/statfs.h>
 
-struct fuse_file_info_compat {
-    int flags;
-    unsigned long fh;
-    int writepage;
-    unsigned int direct_io : 1;
-    unsigned int keep_cache : 1;
+struct fuse_lowlevel_ops_compat {
+    void (*init) (void *userdata);
+    void (*destroy) (void *userdata);
+    void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name);
+    void (*forget) (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup);
+    void (*getattr) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info_compat *fi);
+    void (*setattr) (fuse_req_t req, fuse_ino_t ino, struct stat *attr,
+                     int to_set, struct fuse_file_info_compat *fi);
+    void (*readlink) (fuse_req_t req, fuse_ino_t ino);
+    void (*mknod) (fuse_req_t req, fuse_ino_t parent, const char *name,
+                   mode_t mode, dev_t rdev);
+    void (*mkdir) (fuse_req_t req, fuse_ino_t parent, const char *name,
+                   mode_t mode);
+    void (*unlink) (fuse_req_t req, fuse_ino_t parent, const char *name);
+    void (*rmdir) (fuse_req_t req, fuse_ino_t parent, const char *name);
+    void (*symlink) (fuse_req_t req, const char *link, fuse_ino_t parent,
+                     const char *name);
+    void (*rename) (fuse_req_t req, fuse_ino_t parent, const char *name,
+                    fuse_ino_t newparent, const char *newname);
+    void (*link) (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
+                  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,
+                  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);
+    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, struct fuse_file_info_compat *fi);
+    void (*fsync) (fuse_req_t req, fuse_ino_t ino, int datasync,
+                   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,
+                     struct fuse_file_info_compat *fi);
+    void (*releasedir) (fuse_req_t req, fuse_ino_t ino,
+                        struct fuse_file_info_compat *fi);
+    void (*fsyncdir) (fuse_req_t req, fuse_ino_t ino, int datasync,
+                      struct fuse_file_info_compat *fi);
+    void (*statfs) (fuse_req_t req);
+    void (*setxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
+                      const char *value, size_t size, int flags);
+    void (*getxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
+                      size_t size);
+    void (*listxattr) (fuse_req_t req, fuse_ino_t ino, size_t size);
+    void (*removexattr) (fuse_req_t req, fuse_ino_t ino, const char *name);
+    void (*access) (fuse_req_t req, fuse_ino_t ino, int mask);
+    void (*create) (fuse_req_t req, fuse_ino_t parent, const char *name,
+                    mode_t mode, struct fuse_file_info_compat *fi);
 };
 
 int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf);
@@ -85,8 +126,8 @@ int fuse_reply_open_compat(fuse_req_t req,
                            const struct fuse_file_info_compat *fi);
 
 struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
-                                              const struct fuse_lowlevel_ops *op,
-                                              size_t op_size, void *userdata);
+                            const struct fuse_lowlevel_ops_compat *op,
+                            size_t op_size, void *userdata);
 
 #endif /* __FreeBSD__ */
 
@@ -100,4 +141,4 @@ struct fuse_chan *fuse_chan_new_compat24(struct fuse_chan_ops_compat24 *op,
                                          int fd, size_t bufsize, void *data);
 
 int fuse_chan_receive(struct fuse_chan *ch, char *buf, size_t size);
-
+struct fuse_chan *fuse_kern_chan_new(int fd);
index 8c507d9d14a77588bb3918fee5db409b8227a3a8..16eb7ada39c85671716f1e5407d2027c14c48a6d 100644 (file)
@@ -2777,6 +2777,7 @@ void fuse_destroy(struct fuse *f)
     fuse_delete_context_key();
 }
 
+#include "fuse_common_compat.h"
 #include "fuse_compat.h"
 
 static struct fuse *fuse_new_common_compat25(int fd, struct fuse_args *args,
@@ -2802,7 +2803,7 @@ static int fuse_compat_open(struct fuse *f, fuse_req_t req, char *path,
     if (!f->compat || f->compat >= 25)
         err = fuse_do_open(f, req, path, fi);
     else if (f->compat == 22) {
-        struct fuse_file_info_compat22 tmp;
+        struct fuse_file_info_compat tmp;
         memcpy(&tmp, fi, sizeof(tmp));
         fuse_prepare_interrupt(f, req, &d);
         err = ((struct fuse_operations_compat22 *) &f->op)->open(path, &tmp);
@@ -2838,7 +2839,7 @@ static int fuse_compat_opendir(struct fuse *f, fuse_req_t req, char *path,
         return fuse_do_opendir(f, req, path, fi);
     } else {
         int err;
-        struct fuse_file_info_compat22 tmp;
+        struct fuse_file_info_compat tmp;
         struct fuse_intr_data d;
         memcpy(&tmp, fi, sizeof(tmp));
         fuse_prepare_interrupt(f, req, &d);
index e7044d3b615c2087014cd867ab1ad3526d66c643..27a3d204546e99eb68ff4a48f7ba0cc20f506e03 100644 (file)
@@ -1243,6 +1243,7 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
 }
 
 
+#include "fuse_common_compat.h"
 #include "fuse_lowlevel_compat.h"
 
 #ifndef __FreeBSD__
@@ -1290,8 +1291,8 @@ int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf)
 }
 
 struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
-                                              const struct fuse_lowlevel_ops *op,
-                                              size_t op_size, void *userdata)
+                            const struct fuse_lowlevel_ops_compat *op,
+                            size_t op_size, void *userdata)
 {
     struct fuse_session *se;
     struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
@@ -1303,7 +1304,8 @@ struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
         fuse_opt_free_args(&args);
         return NULL;
     }
-    se = fuse_lowlevel_new(&args, op, op_size, userdata);
+    se = fuse_lowlevel_new(&args, (const struct fuse_lowlevel_ops *) op,
+                           op_size, userdata);
     fuse_opt_free_args(&args);
 
     return se;
index 6cfd462b37d4f5904cfd398bd64f07bd866110e2..73f5f5702f0de8b517e44bbf5cdb5f7591a76a5d 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include "fuse_lowlevel.h"
+#include "fuse_common_compat.h"
 #include "fuse_lowlevel_compat.h"
 
 #include <stdio.h>