Skip to content

Commit

Permalink
Expose API for modifying fuse_conn_info.max_read
Browse files Browse the repository at this point in the history
  • Loading branch information
SupraSummus committed Nov 1, 2021
1 parent ce20b49 commit 2e128ca
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/_pyfuse3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/handlers.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions src/pyfuse3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/pyfuse3.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,17 @@ cdef class FileInfo:
out.nonseekable = 0


cdef class ConnInfo:
cdef fuse_conn_info *conn

This comment has been minimized.

Copy link
@Nikratio

Nikratio Nov 1, 2021

You can merge this into one @property function, see below for example.

@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:
'''
Expand Down
3 changes: 3 additions & 0 deletions test/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2e128ca

Please sign in to comment.