From: Nikolaus Rath Date: Mon, 3 Oct 2016 04:48:47 +0000 (-0700) Subject: Added fuse_session_fd() X-Git-Tag: fuse-3.0.0pre0~4 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2ac973ef4c7dfaae96df864dd50eedaad54a04f3;p=qemu-gpiodev%2Flibfuse.git Added fuse_session_fd() Fixes #59. --- diff --git a/ChangeLog.rst b/ChangeLog.rst index 9afc173..b93cbb9 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -84,6 +84,9 @@ Unreleased Changes File systems that use `fuse_main` are not affected by this change. + For integration with custom event loops, the new `fuse_session_fd` + function provides the file descriptor that's used for communication + with the kernel. * Added *clone_fd* option. This creates a separate device file descriptor for each processing thread, which might improve diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index 3765598..9d57144 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -1728,9 +1728,25 @@ void fuse_session_unmount(struct fuse_session *se); void fuse_session_destroy(struct fuse_session *se); /* ----------------------------------------------------------- * - * Request processing (for custom event loops) * + * Custom event loop support * * ----------------------------------------------------------- */ +/** + * Return file descriptor for communication with kernel. + * + * The file selector can be used to integrate FUSE with a custom event + * loop. Whenever data is available for reading on the provided fd, + * the event loop should call `fuse_session_receive_buf` followed by + * `fuse_session_process_buf` to process the request. + * + * The returned file descriptor is valid until `fuse_session_unmount` + * is called. + * + * @param se the session + * @return a file descriptor + */ +int fuse_session_fd(struct fuse_session *se); + /** * Process a raw request supplied in a generic buffer * diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 368ac71..375ac69 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2975,6 +2975,11 @@ error_out: return -1; } +int fuse_session_fd(struct fuse_session *se) +{ + return fuse_session_chan(se)->fd; +} + void fuse_session_unmount(struct fuse_session *se) { fuse_session_remove_chan(se->ch); diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript index 4327429..4031664 100644 --- a/lib/fuse_versionscript +++ b/lib/fuse_versionscript @@ -19,6 +19,7 @@ FUSE_3.0 { fuse_session_loop; fuse_session_loop_mt; fuse_session_reset; + fuse_session_fd; fuse_opt_parse; fuse_opt_add_opt; fuse_opt_add_arg;