From b078ac226ee6d16aa9867c88af2b116a457e46cd Mon Sep 17 00:00:00 2001 From: Renzo Davoli Date: Tue, 19 Nov 2024 13:23:59 +0100 Subject: [PATCH] port vufuse to fuse3 --- CMakeLists.txt | 7 ++--- vufuse/CMakeLists.txt | 2 +- vufuse/vufuse.c | 41 +++++++++++++++------------- vufuse/vufuse.h | 5 +--- vufuse/vufuse_default_ops.c | 44 ++++++------------------------ vufuse/vufuse_default_ops.h | 2 +- vufuse/vufuseop.c | 50 ++++++++++++++--------------------- vufuse_modules/CMakeLists.txt | 2 +- vufuse_modules/vufusenull.c | 15 ++++++----- vufuse_modules/vufusereal.c | 44 ++++++++++-------------------- 10 files changed, 80 insertions(+), 132 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcaa156..7dedb06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,10 @@ include(GNUInstallDirs) include(CheckIncludeFile) include(CheckSymbolExists) -set(LIBS_REQUIRED stropt volatilestream execs vdeplug fuse) -set(HEADERS_REQUIRED stropt.h strcase.h volatilestream.h execs.h libvdeplug.h fuse.h pthread.h) -set(CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64) +set(LIBS_REQUIRED stropt volatilestream execs vdeplug fuse3) +set(HEADERS_REQUIRED stropt.h strcase.h volatilestream.h execs.h libvdeplug.h fuse3/fuse.h pthread.h) +# DFUSE_USE_VERSION 300 is just to test fuse3-dev availability +set(CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=300) foreach(THISLIB IN LISTS LIBS_REQUIRED) find_library(LIB${THISLIB}_OK ${THISLIB}) diff --git a/vufuse/CMakeLists.txt b/vufuse/CMakeLists.txt index e17679e..7532ca9 100644 --- a/vufuse/CMakeLists.txt +++ b/vufuse/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=29") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=314") include_directories(${VU_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/vufuse/vufuse.c b/vufuse/vufuse.c index 7a031d8..1dc5e3e 100644 --- a/vufuse/vufuse.c +++ b/vufuse/vufuse.c @@ -169,7 +169,9 @@ int vu_vufuse_mount(const char *source, const char *target, struct fuse_conn_info conn; struct fuse_context fcx, *ofcx; ofcx = fuse_push_context (&fcx); - new_fuse->private_data=new_fuse->fops.init(&conn); + struct fuse_config cfg; /* XXX */ + memset(&cfg, 0, sizeof(cfg)); + new_fuse->private_data=new_fuse->fops.init(&conn, &cfg); fuse_pop_context(ofcx); } @@ -275,7 +277,7 @@ void fuse_pop_context(struct fuse_context *old) { /*******************************************************************************************/ /* fuse related functions*/ -int fuse_version(void) { return VUFUSE_FUSE_VERSION;} +int fuse_version(void) { return FUSE_USE_VERSION;} struct fuse_context *fuse_get_context(void) { @@ -286,9 +288,9 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, void *user_data) { struct fuse *f; - struct fuse_chan *fusechan = fuse_mount(NULL, NULL); /*options have been already parsed*/ - if (fusechan != NULL) { - f = fuse_new(fusechan, NULL, op, op_size, user_data); + int res = fuse_mount(NULL, NULL); /*options have been already parsed*/ + if (res != -1) { + f = fuse_new(NULL, op, op_size, user_data); return fuse_loop(f); } else @@ -297,13 +299,12 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, /* fuse_mount and fuse_unmount are dummy functions, * the real mount operation has been done in vufuse_mount */ -struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args) +int fuse_mount(struct fuse *f, const char *mountpoint) { - return vu_get_ht_private_data(); + return 0; } -void fuse_unmount(const char *mountpoint, struct fuse_chan *ch) -{ +void fuse_unmount(struct fuse* f) { return; } @@ -325,11 +326,11 @@ static void fopsmerge (const struct fuse_operations *fops, const struct fuse_ope } } -struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args, +struct fuse *fuse_new(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data) { - struct fuse *fuse = (struct fuse *)ch; + struct fuse *fuse = vu_get_ht_private_data(); if (op_size != sizeof(struct fuse_operations)) { printk(KERN_ERR "Fuse module vs vufuse support version mismatch\n"); return NULL; @@ -379,12 +380,21 @@ void fuse_exit(struct fuse *f) } -int fuse_loop_mt(struct fuse *f) +#if FUSE_USE_VERSION < 32 +int fuse_loop_mt(struct fuse *f, int clone_fd) { //in fuselib is FUSE event loop with multiple threads, //but hereeverything has multiple threads ;-) return fuse_loop(f); } +#else +int fuse_loop_mt(struct fuse *f, struct fuse_loop_config *config) +{ + //in fuselib is FUSE event loop with multiple threads, + //but hereeverything has multiple threads ;-) + return fuse_loop(f); +} +#endif /* other dummy functions. useless for vufuse */ struct fuse_session *fuse_get_session(struct fuse *f) { @@ -410,13 +420,6 @@ int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint, return 0; } -int fuse_chan_fd(struct fuse_chan *ch) { - struct fuse *fuse = vu_get_ht_private_data(); - if (fuse->fake_chan_fd == -1) - fuse->fake_chan_fd = open("/", O_PATH); - return fuse->fake_chan_fd; -} - /* constructor / destructor */ __attribute__((constructor)) static void init(void) { diff --git a/vufuse/vufuse.h b/vufuse/vufuse.h index 92457b1..9f09a83 100644 --- a/vufuse/vufuse.h +++ b/vufuse/vufuse.h @@ -20,11 +20,8 @@ #ifndef VUFUSE_H #define VUFUSE_H -#include -#ifndef VUFUSE_FUSE_VERSION -#define VUFUSE_FUSE_VERSION 29 -#endif +#include /** Enable hard remove */ #define FUSE_HARDREMOVE (1 << 0) diff --git a/vufuse/vufuse_default_ops.c b/vufuse/vufuse_default_ops.c index d1a8131..da6f45e 100644 --- a/vufuse/vufuse_default_ops.c +++ b/vufuse/vufuse_default_ops.c @@ -20,7 +20,7 @@ * */ -#include +#include #include #include #include @@ -28,7 +28,7 @@ /* Check fuse.h for the documentation*/ -static int vustd_getattr (const char *path, struct stat *stat) +static int vustd_getattr (const char *path, struct stat *stat, struct fuse_file_info *fi) { printkdebug(F,"DEFAULT getattr %s\n", path); return -ENOTSUP; @@ -40,12 +40,6 @@ static int vustd_readlink (const char *path, char *link, size_t size) return -EINVAL; } -static int vustd_getdir (const char *path, fuse_dirh_t dir, fuse_dirfil_t dirf) -{ - printkdebug(F,"DEFAULT getdir %s\n", path); - return -ENOSYS; -} - static int vustd_mknod (const char *path, mode_t mode, dev_t dev) { printkdebug(F,"DEFAULT mknod %s\n", path); @@ -76,7 +70,7 @@ static int vustd_symlink (const char *path, const char *newpath) return -ENOSYS; } -static int vustd_rename (const char *path, const char *newpath) +static int vustd_rename (const char *path, const char *newpath, unsigned int flags) { printkdebug(F,"DEFAULT rename %s\n", path); return -ENOSYS; @@ -88,31 +82,25 @@ static int vustd_link (const char *path, const char *newpath) return -ENOSYS; } -static int vustd_chmod (const char *path, mode_t mode) +static int vustd_chmod (const char *path, mode_t mode, struct fuse_file_info *fi) { printkdebug(F,"DEFAULT chmod %s\n", path); return -ENOSYS; } -static int vustd_chown (const char *path, uid_t uid, gid_t gid) +static int vustd_chown (const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi) { printkdebug(F,"DEFAULT chown %s\n", path); return -ENOSYS; } -static int vustd_truncate (const char *path, off_t off) +static int vustd_truncate (const char *path, off_t off, struct fuse_file_info *fi) { printkdebug(F,"DEFAULT truncat %s\n", path); return -ENOSYS; } -static int vustd_utime (const char *path, struct utimbuf *timbuf) -{ - printkdebug(F,"DEFAULT utime %s\n", path); - return -ENOSYS; -} - -static int vustd_open (const char *path, struct fuse_file_info *fileinfo) +static int vustd_open (const char *path, struct fuse_file_info *fi) { printkdebug(F,"DEFAULT open %s\n", path); return -ENOSYS; @@ -222,25 +210,13 @@ static int vustd_create (const char *path, mode_t mode, struct fuse_file_info *f return -ENOSYS; } -static int vustd_ftruncate (const char *path, off_t length, struct fuse_file_info *fileinfo) -{ - printkdebug(F,"DEFAULT ftruncate %s\n", path); - return -ENOSYS; -} - -static int vustd_fgetattr (const char *path, struct stat *buf, struct fuse_file_info *fileinfo) -{ - printkdebug(F,"DEFAULT ftruncate %s\n", path); - return -ENOSYS; -} - static int vustd_lock (const char *path, struct fuse_file_info *fileinfo, int cmd, struct flock *fl) { printkdebug(F,"DEFAULT lock %s\n", path); return -ENOSYS; } -static int vustd_utimens(const char *path, const struct timespec tv[2]) +static int vustd_utimens(const char *path, const struct timespec tv[2], struct fuse_file_info *fi) { printkdebug(F,"DEFAULT utimens %s\n", path); return -ENOSYS; @@ -255,7 +231,6 @@ static int vustd_bmap (const char *path, size_t blocksize, uint64_t *idx) struct fuse_operations vufuse_default_ops = { .getattr = vustd_getattr, .readlink = vustd_readlink, - .getdir = vustd_getdir, .mknod = vustd_mknod, .mkdir = vustd_mkdir, .unlink = vustd_unlink, @@ -266,7 +241,6 @@ struct fuse_operations vufuse_default_ops = { .chmod = vustd_chmod, .chown = vustd_chown, .truncate = vustd_truncate, - .utime = vustd_utime, .open = vustd_open, .read = vustd_read, .write = vustd_write, @@ -287,8 +261,6 @@ struct fuse_operations vufuse_default_ops = { .access = vustd_access, .create = vustd_create, - .ftruncate = vustd_ftruncate, - .fgetattr = vustd_fgetattr, .lock = vustd_lock, .utimens = vustd_utimens, .bmap = vustd_bmap, diff --git a/vufuse/vufuse_default_ops.h b/vufuse/vufuse_default_ops.h index 1031ced..8f6cecb 100644 --- a/vufuse/vufuse_default_ops.h +++ b/vufuse/vufuse_default_ops.h @@ -22,7 +22,7 @@ #ifndef VUFUSE_DEFAULT_OPS_H #define VUFUSE_DEFAULT_OPS_H -#include +#include extern struct fuse_operations vufuse_default_ops; diff --git a/vufuse/vufuseop.c b/vufuse/vufuseop.c index 5dc0e44..c8f94e2 100644 --- a/vufuse/vufuseop.c +++ b/vufuse/vufuseop.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,8 @@ VU_PROTOTYPES(vufuse) #define FILEPATH(x) vufuse_node_path(x->node) +#define FFI(priv) (priv != NULL ? &((struct fileinfo *)(priv))->ffi : NULL) + /*heuristics for file system which does not set st_ino */ static inline unsigned long hash_inodeno (const char *s) { unsigned long sum = 0; @@ -52,7 +53,7 @@ static off_t vufuse_get_filesize(char *pathname) { struct vu_stat buf; int rv; memset(&buf, 0, sizeof(struct vu_stat)); - rv = fuse->fops.getattr(pathname, &buf); + rv = fuse->fops.getattr(pathname, &buf, NULL); return (rv >= 0) ? buf.st_size : 0; } @@ -63,7 +64,7 @@ int vu_vufuse_lstat(char *pathname, struct vu_stat *buf, int flags, int sfd, voi pthread_mutex_lock(&(fc.fuse->mutex)); memset(buf, 0, sizeof(struct vu_stat)); - rv = fc.fuse->fops.getattr(pathname, buf); + rv = fc.fuse->fops.getattr(pathname, buf, FFI(private)); fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); @@ -93,7 +94,8 @@ int vu_vufuse_access(char *path, int mode, int flags) { rv = fc.fuse->fops.access(path, mode); if (rv == -ENOSYS) { struct vu_stat buf; - rv = fc.fuse->fops.getattr(path, &buf); + // Pass fileinfo instead of null if the file is open + rv = fc.fuse->fops.getattr(path, &buf, NULL); } fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); @@ -258,7 +260,7 @@ int vu_vufuse_chmod (const char *pathname, mode_t mode, int fd, void *fdprivate) } pthread_mutex_lock(&(fc.fuse->mutex)); - rv = fc.fuse->fops.chmod(pathname, mode); + rv = fc.fuse->fops.chmod(pathname, mode, FFI(fdprivate)); fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); @@ -282,7 +284,7 @@ int vu_vufuse_lchown (const char *pathname, uid_t owner, gid_t group,int fd, voi } pthread_mutex_lock(&(fc.fuse->mutex)); - rv = fc.fuse->fops.chown(pathname, owner, group); + rv = fc.fuse->fops.chown(pathname, owner, group, FFI(fdprivate)); fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); @@ -330,7 +332,7 @@ int vu_vufuse_truncate(const char *path, off_t length, int fd, void *fdprivate) } pthread_mutex_lock(&(fc.fuse->mutex)); - rv = fc.fuse->fops.truncate(path, length); + rv = fc.fuse->fops.truncate(path, length, FFI(fdprivate)); fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); @@ -377,7 +379,7 @@ int vu_vufuse_open(const char *pathname, int flags, mode_t mode, void **private) ofc = fuse_push_context(&fc); pthread_mutex_lock(&(fc.fuse->mutex)); - exists_err = fc.fuse->fops.getattr(pathname, &buf); /* if 0 the file already exists.*/ + exists_err = fc.fuse->fops.getattr(pathname, &buf, NULL); /* if 0 the file already exists.*/ if ((flags & O_ACCMODE) != O_RDONLY && fc.fuse->mountflags & MS_RDONLY) { fuse_pop_context(ofc); @@ -408,7 +410,7 @@ int vu_vufuse_open(const char *pathname, int flags, mode_t mode, void **private) } if ((flags & O_TRUNC) && (flags & O_ACCMODE)!= O_RDONLY) { - rv = fc.fuse->fops.truncate(pathname, 0); + rv = fc.fuse->fops.truncate(pathname, 0, NULL); printkdebug(F,"TRUNCATE path:%s flags:%x retvalue:%d",pathname,flags,rv); if (rv < 0) { @@ -701,7 +703,8 @@ static int vufuse_common_filldir(FILE *f, const char *name, unsigned char type, } /* Function to add an entry in a readdir() operation */ -static int vufusefillreaddir(void *buf, const char *name, const struct stat *stbuf, off_t off) { +static int vufusefillreaddir(void *buf, const char *name, const struct stat *stbuf, off_t off, + enum fuse_fill_dir_flags flags) { FILE *f = buf; __ino64_t d_ino; unsigned char d_type; @@ -719,10 +722,6 @@ struct fuse_dirhandle { FILE *f; }; -static int vufusefilldir(fuse_dirh_t h, const char *name, int type, ino_t ino) { - return vufuse_common_filldir(h->f, name, type, ino); -} - int vu_vufuse_getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int count, void *fdprivate) { if (fdprivate == NULL) { errno = EBADF; @@ -739,12 +738,7 @@ int vu_vufuse_getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int co ofc = fuse_push_context(&fc); pthread_mutex_lock(&(fc.fuse->mutex)); ft->dirf = volstream_open(); - if (fc.fuse->fops.readdir != NULL) - rv = fc.fuse->fops.readdir(FILEPATH(ft), ft->dirf, vufusefillreaddir, 0, &ft->ffi); - else { - struct fuse_dirhandle dh = {.f = ft->dirf}; - rv = fc.fuse->fops.getdir(FILEPATH(ft), &dh, vufusefilldir); - } + rv = fc.fuse->fops.readdir(FILEPATH(ft), ft->dirf, vufusefillreaddir, 0, &ft->ffi, 0); fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); if (rv < 0) { @@ -803,7 +797,7 @@ int vu_vufuse_unlink (const char *pathname) { } pthread_mutex_lock(&(fc.fuse->mutex)); - if (fc.fuse->fops.getattr(pathname, &buf) < 0) { + if (fc.fuse->fops.getattr(pathname, &buf, NULL) < 0) { pthread_mutex_unlock(&(fc.fuse->mutex)); fuse_pop_context(ofc); errno = ENOENT; @@ -811,7 +805,7 @@ int vu_vufuse_unlink (const char *pathname) { } if (fc.fuse->fuseflags & FUSE_HARDREMOVE || (hiddenpath = vufuse_node_rename(fc.fuse, pathname, NULL)) == NULL || - (rv = fc.fuse->fops.rename(pathname,hiddenpath)) < 0) { + (rv = fc.fuse->fops.rename(pathname, hiddenpath, 0)) < 0) { if (hiddenpath) vufuse_node_rename(fc.fuse, hiddenpath, pathname); @@ -847,20 +841,20 @@ int vu_vufuse_rename (const char *target, const char *linkpath, int flags) { pthread_mutex_lock(&(fc.fuse->mutex)); if (fc.fuse->fuseflags & FUSE_HARDREMOVE || (hiddenpath = vufuse_node_rename(fc.fuse, linkpath, NULL)) == NULL || - fc.fuse->fops.rename(linkpath,hiddenpath) < 0) { + fc.fuse->fops.rename(linkpath, hiddenpath, flags) < 0) { if (hiddenpath) { vufuse_node_rename(fc.fuse, hiddenpath, linkpath); hiddenpath = NULL; } } - rv = fc.fuse->fops.rename(target,linkpath); + rv = fc.fuse->fops.rename(target, linkpath, flags); if (rv >= 0) vufuse_node_rename(fc.fuse, target, linkpath); else if (hiddenpath) { // revert the renaming to hiddenpath - if (fc.fuse->fops.rename(hiddenpath, linkpath) >= 0) + if (fc.fuse->fops.rename(hiddenpath, linkpath, flags) >= 0) vufuse_node_rename(fc.fuse, hiddenpath, linkpath); } pthread_mutex_unlock(&(fc.fuse->mutex)); @@ -887,11 +881,7 @@ int vu_vufuse_utimensat(int dirfd, const char *pathname, } pthread_mutex_lock(&(fc.fuse->mutex)); - rv = fc.fuse->fops.utimens(pathname, times); - if (rv == -ENOSYS) { - struct utimbuf utimes = {times[0].tv_sec, times[1].tv_sec}; - rv = fc.fuse->fops.utime(pathname, &utimes); - } + rv = fc.fuse->fops.utimens(pathname, times, FFI(private)); fuse_pop_context(ofc); pthread_mutex_unlock(&(fc.fuse->mutex)); diff --git a/vufuse_modules/CMakeLists.txt b/vufuse_modules/CMakeLists.txt index fa16b96..c78965a 100644 --- a/vufuse_modules/CMakeLists.txt +++ b/vufuse_modules/CMakeLists.txt @@ -25,6 +25,6 @@ foreach(VUFUSE_MOD ${VUFUSE_MODULES}) add_executable(${VUFUSE_MOD_TARGET} ${VUFUSE_MOD}) set_target_properties(${VUFUSE_MOD_TARGET} PROPERTIES OUTPUT_NAME ${VUFUSE_MOD_EXE}) target_compile_definitions(${VUFUSE_MOD_TARGET} PUBLIC PROGNAME="${VUFUSE_MOD_TARGET}") - target_link_libraries(${VUFUSE_MOD_TARGET} -lfuse) + target_link_libraries(${VUFUSE_MOD_TARGET} -lfuse3) install(TARGETS ${VUFUSE_MOD_TARGET} RUNTIME DESTINATION bin) endforeach(VUFUSE_MOD) diff --git a/vufuse_modules/vufusenull.c b/vufuse_modules/vufusenull.c index 562944d..b74b4db 100644 --- a/vufuse_modules/vufusenull.c +++ b/vufuse_modules/vufusenull.c @@ -13,12 +13,12 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program (in the main directory of the fuse-ext2 + * along with this program (in the main directory of the vuos * distribution in the file COPYING); if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#define FUSE_USE_VERSION 29 +#define FUSE_USE_VERSION FUSE_MAKE_VERSION(3, 14) #include #include @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -45,7 +45,7 @@ int fuse_reentrant_tag = 0; -int op_getattr(const char *path, struct stat *stbuf){ +int op_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi){ if (strcmp(path, "/") == 0) { memset(stbuf, 0, sizeof(*stbuf)); stbuf->st_mode = 0755 | S_IFDIR; @@ -54,9 +54,10 @@ int op_getattr(const char *path, struct stat *stbuf){ } else return -ENOENT; } -int op_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi){ - filler(buf, ".", NULL, 0); - filler(buf, "..", NULL, 0); +int op_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, + struct fuse_file_info *fi, enum fuse_readdir_flags flags){ + filler(buf, ".", NULL, 0, 0); + filler(buf, "..", NULL, 0, 0); return 0; } diff --git a/vufuse_modules/vufusereal.c b/vufuse_modules/vufusereal.c index 66c884e..01b1a30 100644 --- a/vufuse_modules/vufusereal.c +++ b/vufuse_modules/vufusereal.c @@ -13,12 +13,12 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program (in the main directory of the fuse-ext2 + * along with this program (in the main directory of the vuos * distribution in the file COPYING); if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#define FUSE_USE_VERSION 29 +#define FUSE_USE_VERSION FUSE_MAKE_VERSION(3, 14) #include #include @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -54,7 +54,7 @@ path = path ## _fullpath #define RETURNZER0(retvalue) return ((retvalue < 0) ? -errno : 0) -void * op_init (struct fuse_conn_info *conn){ +void * op_init (struct fuse_conn_info *conn, struct fuse_config *cfg){ struct fuse_context *cntx=fuse_get_context(); return cntx->private_data; } @@ -72,14 +72,7 @@ int op_access(const char *path, int mask){ RETURN(rv); } -int op_fgetattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi){ - int fd = (int) fi->fh; - int rv = fstat(fd,stbuf); - - RETURN(rv); -} - -int op_getattr(const char *path, struct stat *stbuf){ +int op_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi){ struct fuse_context *cntx=fuse_get_context(); char *sourcepath = cntx->private_data; GETPATH(sourcepath, path); @@ -119,7 +112,8 @@ int op_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_ RETURN(rv); } -int op_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi){ +int op_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, + struct fuse_file_info *fi, enum fuse_readdir_flags flags){ struct fuse_context *cntx = fuse_get_context(); char *sourcepath = cntx->private_data; GETPATH(sourcepath, path); @@ -142,9 +136,9 @@ int op_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset //ignoring offset if (lstat(filename, &stbuf) >= 0) - filler(buf, de->d_name, &stbuf, 0); + filler(buf, de->d_name, &stbuf, 0, 0); else - filler(buf, de->d_name, NULL, 0); + filler(buf, de->d_name, NULL, 0, 0); //test for return value 1 ? } closedir(dr); @@ -182,7 +176,7 @@ int op_statfs(const char *path, struct statvfs *buf){ RETURN(rv); } -int op_chmod(const char *path, mode_t mode){ +int op_chmod(const char *path, mode_t mode, struct fuse_file_info *fi){ struct fuse_context *cntx=fuse_get_context(); char *sourcepath = cntx->private_data; GETPATH(sourcepath, path); @@ -191,7 +185,7 @@ int op_chmod(const char *path, mode_t mode){ RETURN(rv); } -int op_chown(const char *path, uid_t uid, gid_t gid){ +int op_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi){ struct fuse_context *cntx=fuse_get_context(); char *sourcepath = cntx->private_data; GETPATH(sourcepath, path); @@ -251,7 +245,7 @@ int op_unlink(const char *path){ RETURN(rv); } -int op_utimens(const char *path, const struct timespec tv[2]){ +int op_utimens(const char *path, const struct timespec tv[2], struct fuse_file_info *fi){ struct fuse_context *cntx=fuse_get_context(); char *sourcepath = cntx->private_data; GETPATH(sourcepath, path); @@ -290,7 +284,7 @@ int op_symlink(const char *sourcename, const char *destname){ RETURN(rv); } -int op_truncate(const char *path, off_t length){ +int op_truncate(const char *path, off_t length, struct fuse_file_info *fi){ struct fuse_context *cntx=fuse_get_context(); char *sourcepath = cntx->private_data; GETPATH(sourcepath, path); @@ -299,14 +293,6 @@ int op_truncate(const char *path, off_t length){ RETURN(rv); } -int op_ftruncate(const char *path, off_t length, struct fuse_file_info *fi){ - int fd = (int) fi->fh; - - int rv = ftruncate(fd,length); - - RETURN(rv); -} - //only allowed hardlink internal to the mount point int op_link (const char *source, const char *dest){ struct fuse_context *cntx=fuse_get_context(); @@ -320,7 +306,7 @@ int op_link (const char *source, const char *dest){ } //called only on internal rename -int op_rename(const char *source, const char *dest){ +int op_rename(const char *source, const char *dest, unsigned int flags){ struct fuse_context *cntx=fuse_get_context(); char *sourcepath = cntx->private_data; @@ -363,8 +349,6 @@ static const struct fuse_operations real_ops = { .destroy = op_destroy, .access = op_access, .create = op_create, - .ftruncate = op_ftruncate, - .fgetattr = op_fgetattr, .lock = NULL, .utimens = op_utimens, .bmap = NULL,