mirror of
https://github.com/libfuse/libfuse.git
synced 2024-12-04 01:24:18 +08:00
fix
This commit is contained in:
parent
52cb09d16e
commit
c706ad9ca0
@ -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
|
||||
|
@ -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 ])
|
||||
|
@ -12,9 +12,13 @@
|
||||
/* 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
|
||||
|
@ -13,10 +13,6 @@
|
||||
#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
|
||||
|
||||
|
@ -11,6 +11,55 @@
|
||||
|
||||
#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 *);
|
||||
|
@ -13,6 +13,14 @@
|
||||
* 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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user