or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyfuse3@3.4.x

docs

examples

anti-patterns.mdcommon-patterns.mdedge-cases.mdreal-world-scenarios.md
index.md
tile.json

tessl/pypi-pyfuse3

tessl install tessl/pypi-pyfuse3@3.4.0

Python 3 bindings for libfuse 3 with async I/O support

common-patterns.mddocs/examples/

Common Patterns

Reusable code patterns for pyfuse3 filesystems.

File Handle Management

class FileHandleManager:
    def __init__(self):
        self.next_fh = 1
        self.open_files = {}
        self.fh_lock = trio.Lock()
    
    async def allocate(self, inode):
        async with self.fh_lock:
            fh = self.next_fh
            self.next_fh += 1
            self.open_files[fh] = inode
            return fh
    
    async def release(self, fh):
        async with self.fh_lock:
            if fh in self.open_files:
                del self.open_files[fh]

Permission Checking

def check_permission(self, inode_data, mode, ctx):
    """Check if ctx has permission for mode on inode."""
    # Owner
    if ctx.uid == inode_data['uid']:
        owner_perms = (inode_data['mode'] >> 6) & 0o7
        return (mode & owner_perms) == mode
    
    # Group
    if ctx.gid == inode_data['gid']:
        group_perms = (inode_data['mode'] >> 3) & 0o7
        return (mode & group_perms) == mode
    
    # Others
    other_perms = inode_data['mode'] & 0o7
    return (mode & other_perms) == mode

See Also

  • Quick Start Guide
  • Real-World Scenarios