Remove "channels" and embed into session

This commit is contained in:
Antonio SJ Musumeci 2026-02-16 20:55:18 -06:00
parent d5cdd553b5
commit 550abed5ee
12 changed files with 203 additions and 261 deletions

View file

@ -273,14 +273,16 @@ struct fuse_operations
* Create a new FUSE filesystem.
*
* @param ch the communication channel
* @param fd the /dev/fuse file descriptor
* @param bufsize the buffer size for FUSE communication
* @param args argument vector
* @param op the filesystem operations
* @param op_size the size of the fuse_operations structure
* @return the created FUSE handle
*/
struct fuse *fuse_new(struct fuse_chan *ch,
struct fuse_args *args,
const struct fuse_operations *op);
struct fuse *fuse_new(int fd,
size_t bufsize,
struct fuse_args *args,
const struct fuse_operations *op);
/**
* Destroy the FUSE handle.

View file

@ -135,25 +135,24 @@ struct fuse_pollhandle_t;
typedef struct fuse_pollhandle_t fuse_pollhandle_t;
/**
* Create a FUSE mountpoint
* Mount a FUSE filesystem.
*
* Returns a control file descriptor suitable for passing to
* fuse_new()
* This function creates a FUSE mount and returns the /dev/fuse file descriptor.
* The file descriptor is stored in the session for internal use.
*
* @param mountpoint the mount point path
* @param args argument vector
* @return the communication channel on success, NULL on failure
* @return the /dev/fuse file descriptor on success, -1 on failure
*/
struct fuse_chan *fuse_mount(const char *mountpoint,
struct fuse_args *args);
int fuse_mount(const char *mountpoint, struct fuse_args *args);
/**
* Umount a FUSE mountpoint
*
* @param mountpoint the mount point path
* @param ch the communication channel
* @param fd the /dev/fuse file descriptor (or -1 if already closed)
*/
void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
void fuse_unmount(const char *mountpoint, int fd);
/**
* Parse common options

View file

@ -29,13 +29,7 @@ EXTERN_C_BEGIN
*/
struct fuse_session;
/**
* Channel
*
* A communication channel, providing hooks for sending and receiving
* messages
*/
struct fuse_chan;
/** Directory entry parameters supplied to fuse_reply_entry() */
struct fuse_entry_param
@ -425,14 +419,14 @@ int fuse_lowlevel_notify_poll(fuse_pollhandle_t *ph);
/**
* Notify to invalidate cache for an inode
*
* @param ch the channel through which to send the invalidation
* @param se the session through which to send the invalidation
* @param ino the inode number
* @param off the offset in the inode where to start invalidating
* or negative to invalidate attributes only
* @param len the amount of cache to invalidate or 0 for all
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, uint64_t ino,
int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, uint64_t ino,
off_t off, off_t len);
/**
@ -443,13 +437,13 @@ int fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, uint64_t ino,
* don't call it with a lock held that can also be held by a filesystem
* operation.
*
* @param ch the channel through which to send the invalidation
* @param se the session through which to send the invalidation
* @param parent inode number
* @param name file name
* @param namelen strlen() of file name
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_inval_entry(struct fuse_chan *ch, uint64_t parent,
int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, uint64_t parent,
const char *name, size_t namelen);
/**
@ -461,14 +455,14 @@ int fuse_lowlevel_notify_inval_entry(struct fuse_chan *ch, uint64_t parent,
* don't call it with a lock held that can also be held by a filesystem
* operation.
*
* @param ch the channel through which to send the notification
* @param se the session through which to send the notification
* @param parent inode number
* @param child inode number
* @param name file name
* @param namelen strlen() of file name
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_delete(struct fuse_chan *ch,
int fuse_lowlevel_notify_delete(struct fuse_session *se,
uint64_t parent, uint64_t child,
const char *name, size_t namelen);
@ -490,14 +484,14 @@ int fuse_lowlevel_notify_delete(struct fuse_chan *ch,
* buffer. For dirty pages the write() method will be called
* regardless of having been retrieved previously.
*
* @param ch the channel through which to send the invalidation
* @param se the session through which to send the invalidation
* @param ino the inode number
* @param size the number of bytes to retrieve
* @param offset the starting offset into the file to retrieve from
* @param cookie user data to supply to the reply callback
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_retrieve(struct fuse_chan *ch, uint64_t ino,
int fuse_lowlevel_notify_retrieve(struct fuse_session *se, uint64_t ino,
size_t size, off_t offset, void *cookie);
@ -554,8 +548,6 @@ struct fuse_session *fuse_session_new(void *data,
void *receive_buf,
void *process_buf,
void *destroy);
void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);
void fuse_session_remove_chan(struct fuse_chan *ch);
void fuse_session_destroy(struct fuse_session *se);
void fuse_session_exit(struct fuse_session *se);
int fuse_session_exited(struct fuse_session *se);
@ -573,44 +565,12 @@ int fuse_session_loop_mt(struct fuse_session *se,
const int process_thread_queue_depth,
const char *pin_threads_type);
/* ----------------------------------------------------------- *
* Channel interface *
* ----------------------------------------------------------- */
struct fuse_chan *fuse_chan_new(int fd, size_t bufsize);
/**
* Query the file descriptor of the channel
*
* @param ch the channel
* @return the file descriptor passed to fuse_chan_new()
*/
int fuse_chan_fd(struct fuse_chan *ch);
/**
* Query the minimal receive buffer size
*
* @param ch the channel
* @return the buffer size passed to fuse_chan_new()
*/
size_t fuse_chan_bufsize(struct fuse_chan *ch);
/**
* Query the user data
*
* @param ch the channel
* @return the user data passed to fuse_chan_new()
*/
void *fuse_chan_data(struct fuse_chan *ch);
/**
* Query the session to which this channel is assigned
*
* @param ch the channel
* @return the session, or NULL if the channel is not assigned
*/
struct fuse_session *fuse_chan_session(struct fuse_chan *ch);
void fuse_chan_destroy(struct fuse_chan *ch);
/* Direct file descriptor and buffer size accessors
* (channel fields inlined into session for single-mount simplicity) */
int fuse_session_fd(struct fuse_session *se);
size_t fuse_session_bufsize(struct fuse_session *se);
int fuse_session_clearfd(struct fuse_session *se);
void fuse_session_setfd(struct fuse_session *se, int fd);
void fuse_session_setbufsize(struct fuse_session *se, size_t bufsize);
EXTERN_C_END

View file

@ -21,16 +21,16 @@
#include "base_types.h"
#include "fuse_msgbuf_t.h"
u32 msgbuf_get_pagesize();
void msgbuf_set_bufsize(const uint32_t size);
uint64_t msgbuf_get_bufsize();
u32 msgbuf_get_pagesize();
void msgbuf_set_bufsize(const u64 size);
u64 msgbuf_get_bufsize();
fuse_msgbuf_t *msgbuf_alloc();
fuse_msgbuf_t *msgbuf_alloc_page_aligned();
void msgbuf_free(fuse_msgbuf_t *msgbuf);
void msgbuf_gc();
void msgbuf_gc_10percent();
void msgbuf_gc();
void msgbuf_gc_10percent();
uint64_t msgbuf_alloc_count();
uint64_t msgbuf_avail_count();
u64 msgbuf_alloc_count();
u64 msgbuf_avail_count();

View file

@ -2,11 +2,11 @@
#include <stdint.h>
struct fuse_chan;
struct fuse_session;
typedef struct fuse_pollhandle_t fuse_pollhandle_t;
struct fuse_pollhandle_t
{
uint64_t kh;
struct fuse_chan *ch;
struct fuse_session *se;
};

View file

@ -3,13 +3,13 @@
#include "fuse_req_ctx.h"
#include "fuse_conn_info.hpp"
struct fuse_chan;
struct fuse_session;
typedef struct fuse_req_t fuse_req_t;
struct fuse_req_t
{
fuse_req_ctx_t ctx;
struct fuse_chan *ch;
struct fuse_session *se;
fuse_conn_info_t conn;
unsigned int ioctl_64bit : 1;
};