From 2e128cae6bba5cc3ba76a8f43468449342d0f2ef Mon Sep 17 00:00:00 2001 From: Jan Rydzewski Date: Mon, 1 Nov 2021 01:30:09 +0100 Subject: [PATCH] Expose API for modifying fuse_conn_info.max_read --- src/_pyfuse3.py | 2 +- src/handlers.pxi | 8 +++++--- src/pyfuse3.pyi | 5 +++++ src/pyfuse3.pyx | 11 +++++++++++ test/test_fs.py | 3 +++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/_pyfuse3.py b/src/_pyfuse3.py index f19f3a0..6c7513a 100644 --- a/src/_pyfuse3.py +++ b/src/_pyfuse3.py @@ -65,7 +65,7 @@ class Operations: enable_writeback_cache: bool = False enable_acl: bool = False - def init(self) -> None: + def init(self, conn_info) -> None: '''Initialize operations. This method will be called just before the file system starts handling diff --git a/src/handlers.pxi b/src/handlers.pxi index 21836cc..f7db0ac 100644 --- a/src/handlers.pxi +++ b/src/handlers.pxi @@ -45,9 +45,11 @@ cdef void fuse_init (void *userdata, fuse_conn_info *conn): conn.capable & FUSE_CAP_POSIX_ACL): conn.want |= FUSE_CAP_POSIX_ACL - # Blocking rather than async, in case we decide to let the - # init hander modify `conn` in the future. - operations.init() + # Blocking rather than async, to let the init hander modify `conn`. + cdef ConnInfo conn_obj + conn_obj = ConnInfo.__new__(ConnInfo) + conn_obj.conn = conn + operations.init(conn_obj) cdef void fuse_lookup (fuse_req_t req, fuse_ino_t parent, const_char *name): diff --git a/src/pyfuse3.pyi b/src/pyfuse3.pyi index 294c353..2018677 100644 --- a/src/pyfuse3.pyi +++ b/src/pyfuse3.pyi @@ -72,6 +72,11 @@ class FileInfo: def __cinit__(self, fh: FileHandleT, direct_io: bool, keep_cache: bool, nonseekable: bool) -> None: ... # def _copy_to_fuse(self, fuse_file_info *out) -> None: ... + +class ConnInfo: + max_read: int + + class StatvfsData: f_bsize: int f_frsize: int diff --git a/src/pyfuse3.pyx b/src/pyfuse3.pyx index bb9e74c..a43b77d 100644 --- a/src/pyfuse3.pyx +++ b/src/pyfuse3.pyx @@ -393,6 +393,17 @@ cdef class FileInfo: out.nonseekable = 0 +cdef class ConnInfo: + cdef fuse_conn_info *conn + + @property + def max_read(self): + return self.conn.max_read + @max_read.setter + def max_read(self, val): + self.conn.max_read = val + + @cython.freelist(1) cdef class StatvfsData: ''' diff --git a/test/test_fs.py b/test/test_fs.py index f6ea9dd..6e51fde 100755 --- a/test/test_fs.py +++ b/test/test_fs.py @@ -166,6 +166,9 @@ def __init__(self, cross_process): self.status.entry_timeout = 99999 self.status.attr_timeout = 99999 + def init(self, conn_info): + conn_info.max_read = 4096 + async def getattr(self, inode, ctx=None): entry = pyfuse3.EntryAttributes() if inode == pyfuse3.ROOT_INODE: