diff --git a/rose/virtualfs/__init__.py b/rose/virtualfs/__init__.py index 4448852..a5b5547 100644 --- a/rose/virtualfs/__init__.py +++ b/rose/virtualfs/__init__.py @@ -1,3 +1,6 @@ +import errno +import os +import stat import subprocess import fuse @@ -8,7 +11,25 @@ class VirtualFS(fuse.Fuse): # type: ignore - pass + def getattr(self, path: str) -> fuse.Stat | int: + if path[1:] == "some_dir" or path in ["..", "/"]: + st_mode = stat.S_IFDIR | 0o755 + elif path[1:] == "some_file": + st_mode = stat.S_IFREG | 0o644 + else: + return -errno.ENOENT + + return fuse.Stat( + st_nlink=1, + st_mode=st_mode, + st_uid=os.getuid(), + st_gid=os.getgid(), + ) + + def readdir(self, path: str, _): + if path == "/": + for name in [".", "..", "some_file", "some_dir"]: + yield fuse.Direntry(name) def mount_virtualfs(c: Config) -> None: