async def lookup( self, inode_p: int, name: bytes, ctx: pyfuse3.RequestContext = None) -> pyfuse3.EntryAttributes: """ Look up a directory entry by name and get its attributes. This method should return an EntryAttributes instance for the directory entry name in the directory with inode parent_inode. If there is no such entry, the method should either return an EntryAttributes instance with zero st_ino value (in which case the negative lookup will be cached as specified by entry_timeout), or it should raise FUSEError with an errno of errno.ENOENT (in this case the negative result will not be cached). ctx will be a RequestContext instance. The file system must be able to handle lookups for . and .., no matter if these entries are returned by readdir or not. (Successful) execution of this handler increases the lookup count for the returned inode by one. """ if name == '.': info = Inode.by_inode(inode_p) elif name == '..': info = Inode.by_inode(inode_p) info = info.parent_obj() else: info = Inode.by_name(inode_p, name.decode()) return self._getattr(info, ctx)
def _update_file_handle(self, fh: int) -> Inode: log.debug('_update_file_handle %s', fh) self.fh_lock.acquire() inode = self.file_handles[fh].inode() inode_info = Inode.by_inode(inode) self.file_handles[fh] = inode_info self.fh_lock.release() return inode_info
async def setattr(self, inode: int, attr: pyfuse3.EntryAttributes, fields: pyfuse3.SetattrFields, fh: int, ctx: pyfuse3.RequestContext) -> pyfuse3.EntryAttributes: """ Change attributes of inode fields will be an SetattrFields instance that specifies which attributes are to be updated. attr will be an EntryAttributes instance for inode that contains the new values for changed attributes, and undefined values for all other attributes. Most file systems will additionally set the st_ctime_ns attribute to the current time (to indicate that the inode metadata was changed). If the syscall that is being processed received a file descriptor argument (like e.g. ftruncate(2) or fchmod(2)), fh will be the file handle returned by the corresponding call to the open handler. If the syscall was path based (like e.g. truncate(2) or chmod(2)), fh will be None. ctx will be a RequestContext instance. The method should return an EntryAttributes instance (containing both the changed and unchanged values). """ if fields.update_size: log.warning('Ignoring update_size, not supported') if fields.update_mode: log.warning('Ignoring update_mode, not supported') if fields.update_uid: log.warning('Ignoring update_uid, not supported') if fields.update_gid: log.warning('Ignoring update_gid, not supported') if fields.update_atime: log.warning('Ignoring uptime_atime, not supported') if fields.update_ctime: log.warning('Ignoring update_ctime, not supported') info = Inode.by_inode(inode) if fields.update_mtime: info.update_mtime(attr.st_mtime_ns // 1e6) return self._getattr(info, ctx)
async def getattr( self, inode: int, ctx: pyfuse3.RequestContext = None) -> pyfuse3.EntryAttributes: info = Inode.by_inode(inode) return self._getattr(info, ctx)
def _obtain_file_handle(self, inode: int) -> Tuple[int, Inode]: inode_info = Inode.by_inode(inode) return self._obtain_file_handle_nofetch(inode_info), inode_info