async def read(self, fh, off, size): # Some applications seem to close files and then try to read from them... fuse_assert(fh in self.open_handles) inode, deref = self.open_handles[fh] read_data = await deref().read(inode, off, size) self.total_bytes_read += len(read_data) return read_data
async def lookup(self, parent_inode, name, ctx=None): if parent_inode == pyfuse3.ROOT_INODE: for _, sub in self: if name.decode('utf-8') == sub.name: return await sub.getattr(sub.root_inode, ctx) fuse_assert(False) return await self.root_child.lookup(parent_inode, name, ctx)
async def lookup(self, parent_inode, name, ctx=None): if not self.inode_belongs(parent_inode): return await self.child.lookup(parent_inode, name, ctx) found_inode = self.listings[parent_inode].name_to_inode( name.decode('utf-8')) fuse_assert(found_inode is not None) return await self.getattr(found_inode)
async def readdir(self, fh, start_id, token): # TODO: Could probably implement this with a `DirectoryListing` as well. Class decorator to monkey-patch method from a .listing field? logger.trace(f"readdir({fh})") if fh == pyfuse3.ROOT_INODE: for num, sub in self: if num < start_id: continue if not pyfuse3.readdir_reply(token, sub.name.encode('utf-8'), await sub.getattr(sub.root_inode ), num + 1): return else: fuse_assert(fh in self.open_handles) inode, deref = self.open_handles[fh] # deref() is not None as each SubFS instance is in memory for the life of the program return await deref().readdir(inode, start_id, token)
async def open(self, _inode, _flags, _ctx): fuse_assert(False)
async def opendir(self, _inode, _ctx): fuse_assert(False)
async def lookup(self, _parent_inode, _name, _ctx=None): fuse_assert(False)
async def getattr(self, _inode, _ctx=None): fuse_assert(False)