fix
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 7 Nov 2005 15:30:48 +0000 (15:30 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 7 Nov 2005 15:30:48 +0000 (15:30 +0000)
ChangeLog
configure.in
include/fuse.h
include/fuse_common.h
include/fuse_compat.h
include/fuse_lowlevel.h
lib/fuse.c
lib/fuse_lowlevel.c
lib/fuse_versionscript

index 17f24c7c011ab14971cbba72665fe734a7eb8204..3b69c127cba29403b936e7f48413f3cbab6e9e82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-07  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Make the statfs change backwards compatible.
+
 2005-11-06  Miklos Szeredi <miklos@szeredi.hu>
 
        * Change ->statfs() method to use 'struct statvfs' instead of
index 5a8c8b5d8a5f487761071b8cb168f88c6a6e072f..633d436cfe25015735cf3a02f8badc30b55bd020 100644 (file)
@@ -16,7 +16,7 @@ fi
 if test "$ac_env_CFLAGS_set" != set; then
        CFLAGS="-Wall -W -g -O2"
 fi
-CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=22"
+CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=25"
 
 AC_ARG_ENABLE(kernel-module,
        [  --enable-kernel-module  Compile kernel module ])
index 831dbff01997e50fd72c6e6ab32838985e908acc..2e977b2437cca4c0d6c8e0525b8edc6d0aa14f8d 100644 (file)
 /* This file defines the library interface of FUSE */
 
 /* IMPORTANT: you should define FUSE_USE_VERSION before including this
-   header.  To use the new API define it to 22 (recommended for any
-   new application), to use the old API define it to 21 (this is the
-   default), to use the even older 1.X API define it to 11. */
+   header.  To use the newest API define it to 25 (recommended for any
+   new application), to use the old API define it to 21 (default) or
+   22, to use the even older 1.X API define it to 11. */
+
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 21
+#endif
 
 #include "fuse_common.h"
 
@@ -162,8 +166,8 @@ struct fuse_operations {
     int (*write) (const char *, const char *, size_t, off_t,
                   struct fuse_file_info *);
 
-    /** Old statfs interface, deprecated */
-    int (*statfs_old) (const char *, void *stbuf);
+    /** Just a placeholder, don't set */
+    void (*statfs_old) (void);
 
     /** Possibly flush cached data
      *
@@ -357,7 +361,7 @@ struct fuse_operations {
      * Replaced 'struct statfs' parameter with 'struct statvfs' in
      * version 2.5
      */
-    int (*statfs) (const char *, struct statvfs *stbuf);
+    int (*statfs) (const char *, struct statvfs *);
 };
 
 /** Extra context that may be needed by some filesystems
@@ -539,37 +543,42 @@ void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
  * Compatibility stuff                                         *
  * ----------------------------------------------------------- */
 
-#if FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11
+#if FUSE_USE_VERSION == 22 || FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11
 #  include "fuse_compat.h"
-#  define fuse_dirfil_t fuse_dirfil_t_compat
-#  define __fuse_read_cmd fuse_read_cmd
-#  define __fuse_process_cmd fuse_process_cmd
-#  define __fuse_loop_mt fuse_loop_mt_proc
-#  undef fuse_main
 #  undef FUSE_MINOR_VERSION
-#  undef FUSE_MAJOR_VERSION
-#  if FUSE_USE_VERSION == 21
-#    define FUSE_MAJOR_VERSION 2
-#    define FUSE_MINOR_VERSION 1
-#    define fuse_operations fuse_operations_compat2
-#    define fuse_main fuse_main_compat2
-#    define fuse_new fuse_new_compat2
-#    define __fuse_setup fuse_setup_compat2
-#    define __fuse_teardown fuse_teardown
-#    define __fuse_exited fuse_exited
-#    define __fuse_set_getcontext_func fuse_set_getcontext_func
+#  undef fuse_main
+#  if FUSE_USE_VERSION == 22
+#    define FUSE_MINOR_VERSION 4
+#    define fuse_main fuse_main_compat22
+#    define fuse_operations fuse_operations_compat22
 #  else
-#    define FUSE_MAJOR_VERSION 1
-#    define FUSE_MINOR_VERSION 1
-#    define fuse_statfs fuse_statfs_compat1
-#    define fuse_operations fuse_operations_compat1
-#    define fuse_main fuse_main_compat1
-#    define fuse_new fuse_new_compat1
-#    define fuse_mount fuse_mount_compat1
-#    define FUSE_DEBUG FUSE_DEBUG_COMPAT1
+#    define fuse_dirfil_t fuse_dirfil_t_compat
+#    define __fuse_read_cmd fuse_read_cmd
+#    define __fuse_process_cmd fuse_process_cmd
+#    define __fuse_loop_mt fuse_loop_mt_proc
+#    if FUSE_USE_VERSION == 21
+#      define FUSE_MAJOR_VERSION 2
+#      define fuse_operations fuse_operations_compat2
+#      define fuse_main fuse_main_compat2
+#      define fuse_new fuse_new_compat2
+#      define __fuse_setup fuse_setup_compat2
+#      define __fuse_teardown fuse_teardown
+#      define __fuse_exited fuse_exited
+#      define __fuse_set_getcontext_func fuse_set_getcontext_func
+#    else
+#      undef FUSE_MAJOR_VERSION
+#      define FUSE_MAJOR_VERSION 1
+#      define FUSE_MINOR_VERSION 1
+#      define fuse_statfs fuse_statfs_compat1
+#      define fuse_operations fuse_operations_compat1
+#      define fuse_main fuse_main_compat1
+#      define fuse_new fuse_new_compat1
+#      define fuse_mount fuse_mount_compat1
+#      define FUSE_DEBUG FUSE_DEBUG_COMPAT1
+#    endif
 #  endif
-#elif FUSE_USE_VERSION < 22
-#  error Compatibility with API version other than 21 and 11 not supported
+#elif FUSE_USE_VERSION < 25
+#  error Compatibility with API version other than 21, 22 and 11 not supported
 #endif
 
 #ifdef __cplusplus
index a59aea68c58fdd561908438cf99373a8740b787e..96f470231c93408e71e945a756dd1847de57de3b 100644 (file)
 #ifndef _FUSE_COMMON_H_
 #define _FUSE_COMMON_H_
 
-#ifndef FUSE_USE_VERSION
-#define FUSE_USE_VERSION 21
-#endif
-
 /** Major version of FUSE library interface */
 #define FUSE_MAJOR_VERSION 2
 
index 08d391ac675b47f9837c775ff8e7dfa71ecb0c36..176560f2798c7cf616167e0f82c36aa599265b10 100644 (file)
 
 #include <sys/statfs.h>
 
+struct fuse_operations_compat22 {
+    int (*getattr) (const char *, struct stat *);
+    int (*readlink) (const char *, char *, size_t);
+    int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t);
+    int (*mknod) (const char *, mode_t, dev_t);
+    int (*mkdir) (const char *, mode_t);
+    int (*unlink) (const char *);
+    int (*rmdir) (const char *);
+    int (*symlink) (const char *, const char *);
+    int (*rename) (const char *, const char *);
+    int (*link) (const char *, const char *);
+    int (*chmod) (const char *, mode_t);
+    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 *);
+    int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *);
+    int (*write) (const char *, const char *, size_t, off_t,
+                  struct fuse_file_info *);
+    int (*statfs) (const char *, struct statfs *);
+    int (*flush) (const char *, struct fuse_file_info *);
+    int (*release) (const char *, struct fuse_file_info *);
+    int (*fsync) (const char *, int, struct fuse_file_info *);
+    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 *);
+    int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
+                    struct fuse_file_info *);
+    int (*releasedir) (const char *, struct fuse_file_info *);
+    int (*fsyncdir) (const char *, int, struct fuse_file_info *);
+    void *(*init) (void);
+    void (*destroy) (void *);
+    int (*access) (const char *, int);
+    int (*create) (const char *, mode_t, struct fuse_file_info *);
+    int (*ftruncate) (const char *, off_t, struct fuse_file_info *);
+    int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *);
+    void (*statfs_new) (void);
+};
+
+static inline int fuse_main_compat22(int argc, char *argv[],
+                                     const struct fuse_operations_compat22 *op)
+{
+    return fuse_main_real(argc, argv, (const struct fuse_operations *) op,
+                          sizeof(*op));
+}
+
+
 typedef int (*fuse_dirfil_t_compat) (fuse_dirh_t h, const char *name, int type);
 struct fuse_operations_compat2 {
     int (*getattr)     (const char *, struct stat *);
index f90d0210d202c6686320dfcc6fcd2d47889ea0c8..d2b43a299f85d2f301c13666ad211cf6b9a010cf 100644 (file)
  * Low level API                                               *
  * =========================================================== */
 
+/* IMPORTANT: you should define FUSE_USE_VERSION before including this
+   header.  To use the newest API define it to 25 (recommended for any
+   new application), to use the old API define it to 24 (default) */
+
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 24
+#endif
+
 #include "fuse_common.h"
 
 #include <utime.h>
@@ -1198,6 +1206,23 @@ int fuse_chan_send(struct fuse_chan *ch, const struct iovec iov[],
  */
 void fuse_chan_destroy(struct fuse_chan *ch);
 
+/* ----------------------------------------------------------- *
+ * Compatibility stuff                                         *
+ * ----------------------------------------------------------- */
+
+#if FUSE_USE_VERSION == 24
+#include <sys/statfs.h>
+
+int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf);
+
+#undef FUSE_MINOR_VERSION
+#define FUSE_MINOR_VERSION 4
+#define fuse_reply_statfs fuse_reply_statfs_compat
+
+#elif FUSE_USE_VERSION < 25
+#  error Compatibility with low level API version other than 24 not supported
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 3557c3b870b7760fd21f1cf3d446ed35835f5765..f3bec936643b39f1a17e7041cc9d136588c11b72 100644 (file)
@@ -1569,7 +1569,7 @@ static void fuse_statfs(fuse_req_t req)
     } else if (f->op.statfs_old) {
         if (!f->compat || f->compat > 11) {
             struct statfs oldbuf;
-            err = f->op.statfs_old("/", &oldbuf);
+            err = ((struct fuse_operations_compat22 *) &f->op)->statfs("/", &oldbuf);
             if (!err)
                 convert_statfs_old(&oldbuf, &buf);
         } else {
@@ -1578,7 +1578,7 @@ static void fuse_statfs(fuse_req_t req)
             err = ((struct fuse_operations_compat1 *) &f->op)->statfs(&compatbuf);
             if (!err)
                 convert_statfs_compat(&compatbuf, &buf);
-        }        
+        }
     } else
         err = default_statfs(&buf);
 
index 9edef54d4c7e897ec2493c8761846831472c22bb..ad6b241209e1f238f02e959c5fa7ade5637df1a9 100644 (file)
@@ -17,6 +17,7 @@
 #include <limits.h>
 #include <errno.h>
 #include <stdint.h>
+#include <sys/statfs.h>
 
 #define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
 
@@ -197,6 +198,18 @@ static void convert_statfs(const struct statvfs *stbuf,
     kstatfs->namelen   = stbuf->f_namemax;
 }
 
+static void convert_statfs_compat(const struct statfs *stbuf,
+                                  struct fuse_kstatfs *kstatfs)
+{
+    kstatfs->bsize     = stbuf->f_bsize;
+    kstatfs->blocks    = stbuf->f_blocks;
+    kstatfs->bfree     = stbuf->f_bfree;
+    kstatfs->bavail    = stbuf->f_bavail;
+    kstatfs->files     = stbuf->f_files;
+    kstatfs->ffree     = stbuf->f_ffree;
+    kstatfs->namelen   = stbuf->f_namelen;
+}
+
 static int send_reply_ok(fuse_req_t req, const void *arg, size_t argsize)
 {
     return send_reply(req, 0, arg, argsize);
@@ -330,6 +343,16 @@ int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf)
     return send_reply_ok(req, &arg, sizeof(arg));
 }
 
+int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf)
+{
+    struct fuse_statfs_out arg;
+
+    memset(&arg, 0, sizeof(arg));
+    convert_statfs_compat(stbuf, &arg.st);
+
+    return send_reply_ok(req, &arg, sizeof(arg));
+}
+
 int fuse_reply_xattr(fuse_req_t req, size_t count)
 {
     struct fuse_getxattr_out arg;
@@ -954,3 +977,5 @@ struct fuse_session *fuse_lowlevel_new(const char *opts,
  out:
     return NULL;
 }
+
+__asm__(".symver fuse_reply_statfs_compat,fuse_reply_statfs@FUSE_2.4");
index 3969c42af1a11ec7ac7db16a1dcf07c34492230a..9f17c99afdc5219764d372ef3a17a0a2218aa26e 100644 (file)
@@ -46,11 +46,9 @@ FUSE_2.4 {
                fuse_reply_buf;
                fuse_reply_entry;
                fuse_reply_err;
-               fuse_reply_getlk;
                fuse_reply_none;
                fuse_reply_open;
                fuse_reply_readlink;
-               fuse_reply_statfs;
                fuse_reply_write;
                fuse_reply_xattr;
                fuse_req_ctx;
@@ -65,6 +63,14 @@ FUSE_2.4 {
                fuse_session_next_chan;
                fuse_session_process;
                fuse_session_reset;
+} FUSE_2.2;
+
+FUSE_2.5 {
+       global:
+               fuse_reply_statfs;
+               fuse_reply_create;
+               fuse_reply_statfs_compat;
+
        local:
                 *;
-} FUSE_2.2;
+} FUSE_2.4;