def getattr(self, path: str, fh=None) -> Stat: try: logging.debug(f"getxattr for: {path}") return self.get_entity(path).st.dict() except: logging.debug(f'not found: {path}') raise FuseOSError(errno.ENOENT)
def readdir(self, path, fh): logging.debug(f"reading dir on '{path}'") user = self.get_current_user() dir = self.get_dir(path) if dir.level <= user.access_level: return ['.', '..'] + list(self.get_dir(path).child.keys()) else: return ['.', '..']
def read(self, path: str, size: int, offset: int, fh): logging.debug(f"uid: {fuse_get_context()}") self.s_log.emit(f"reading: {path} ({fh})") file = self.get_file(path) user = self.get_current_user() if user.access_level < file.level: self.s_warning.emit( f"Заблокирована попытка чтения: {user.login} -> {file.name}") raise FuseOSError(errno.EACCES) else: return self.get_file(path).data[offset:offset + size]
def rmdir(self, path: str): self.s_log.emit(f"rmdir: {path}") logging.debug(path) basename = "/".join(path.split('/')[:-1]) target_dir_name = path.split('/')[-1] dir: Dir = self.get_dir(basename) for childname, child in dir.child.items(): logging.debug(childname) self.s_log.emit(childname) if childname == target_dir_name: self.s_log.emit(f"Removing: {child}") dir.remove_child(child) break
def releasedir(self, path, fh): logging.debug(path)