import sys import errno import stat from fuse import FUSE, Operations class HelloWorld(Operations): def getattr(self, path, fh=None): if path == '/' or path == '/hello': return { 'st_mode': stat.S_IFREG | 0o444, # Regular file, read-only 'st_nlink': 1, 'st_size': len("hello world"), } else: raise OSError(errno.ENOENT, '') def readdir(self, path, fh): return ['.', '..', 'hello'] def open(self, path, flags): if path != '/hello': raise OSError(errno.ENOENT, '') def read(self, path, size, offset, fh): if path == '/hello': return b"hello world"[offset:offset + size] else: raise OSError(errno.ENOENT, '') def main(mountpoint): FUSE(HelloWorld(), mountpoint, nothreads=True, foreground=True) if __name__ == '__main__': if len(sys.argv) != 2: print(f'Usage: {sys.argv[0]} ') sys.exit(1) main(sys.argv[1])