diff --git a/ChangeLog.rst b/ChangeLog.rst index cab3e81..184878d 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,3 +1,11 @@ +libfuse 3.17.x (tbd) +==================== + +When using -DFUSE_USE_VERSION=317 then +* Added new fuse_session_custom_io_317 function to allow extra callbacks. + +* Use clone_fd callback in struct fuse_custom_io + libfuse 3.16.2 (2023-10-10) =========================== diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index 330d40e..170d1a6 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -136,7 +136,10 @@ struct fuse_custom_io { ssize_t (*splice_send)(int fdin, off_t *offin, int fdout, off_t *offout, size_t len, unsigned int flags, void *userdata); + +#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 17) int (*clone_fd)(int master_fd); +#endif }; /** @@ -2042,6 +2045,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, * * @param se session object * @param io Custom io to use when retrieving/sending requests/responses + * @param io_size sizeof(struct fuse_custom_io) * @param fd file descriptor for the session * * @return 0 on success @@ -2050,8 +2054,14 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, * @return -errno if failed to allocate memory to store `io` * **/ +#if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 17) int fuse_session_custom_io(struct fuse_session *se, - const struct fuse_custom_io *io, int fd); + const struct fuse_custom_io *io, int fd); +#else +int fuse_session_custom_io_317(struct fuse_session *se, + const struct fuse_custom_io *io, size_t io_size, int fd); +#define fuse_session_custom_io(_SE, _IO, _FD) fuse_session_custom_io_317(_SE, _IO, (sizeof(_IO)), _FD) +#endif /** * Mount a FUSE file system. diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 5129a3b..93be5f2 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -3116,9 +3116,16 @@ out1: return NULL; } -int fuse_session_custom_io(struct fuse_session *se, const struct fuse_custom_io *io, - int fd) +int fuse_session_custom_io_317(struct fuse_session *se, const struct fuse_custom_io *io, + size_t io_size, int fd) { + + if (sizeof(struct fuse_custom_io) < io_size) + { + fuse_log(FUSE_LOG_ERR, "fuse: warning: library too old, some operations may not work\n"); + io_size = sizeof(struct fuse_custom_io); + } + if (fd < 0) { fuse_log(FUSE_LOG_ERR, "Invalid file descriptor value %d passed to " "fuse_session_custom_io()\n", fd); @@ -3138,7 +3145,7 @@ int fuse_session_custom_io(struct fuse_session *se, const struct fuse_custom_io return -EINVAL; } - se->io = malloc(sizeof(struct fuse_custom_io)); + se->io = calloc(1, sizeof(struct fuse_custom_io)); if (se->io == NULL) { fuse_log(FUSE_LOG_ERR, "Failed to allocate memory for custom io. " "Error: %s\n", strerror(errno)); @@ -3146,10 +3153,21 @@ int fuse_session_custom_io(struct fuse_session *se, const struct fuse_custom_io } se->fd = fd; - *se->io = *io; + memcpy(se->io, io, io_size); return 0; } +#undef fuse_session_custom_io + +int fuse_session_custom_io(struct fuse_session *se, + const struct fuse_custom_io *io, int fd); + +int fuse_session_custom_io(struct fuse_session *se, const struct fuse_custom_io *io, + int fd) +{ + return fuse_session_custom_io_317(se, io, offsetof(struct fuse_custom_io, clone_fd), fd); +} + int fuse_session_mount(struct fuse_session *se, const char *mountpoint) { int fd; diff --git a/lib/meson.build b/lib/meson.build index 9044630..1822ce0 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -37,7 +37,7 @@ libfuse = library('fuse3', libfuse_sources, version: meson.project_version(), soversion: '3', include_directories: include_dirs, dependencies: deps, install: true, link_depends: 'fuse_versionscript', - c_args: [ '-DFUSE_USE_VERSION=312', + c_args: [ '-DFUSE_USE_VERSION=317', '-DFUSERMOUNT_DIR="@0@"'.format(fusermount_path) ], link_args: ['-Wl,--version-script,' + meson.current_source_dir() + '/fuse_versionscript' ]) diff --git a/util/meson.build b/util/meson.build index 47aac14..01c92f0 100644 --- a/util/meson.build +++ b/util/meson.build @@ -11,7 +11,7 @@ executable('mount.fuse3', ['mount.fuse.c'], link_with: [ libfuse ], install: true, install_dir: get_option('sbindir'), - c_args: '-DFUSE_USE_VERSION=312') + c_args: '-DFUSE_USE_VERSION=317') udevrulesdir = get_option('udevrulesdir')