Skip to content

Commit

Permalink
add more stat properties
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Oct 11, 2023
1 parent 46d4fd0 commit b1c98dd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions rose/virtualfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,27 @@ def getattr(self, path: str) -> fuse.Stat:
logger.debug(f"Parsed getattr path as {p}")

def mkstat(mode: Literal["dir", "file"], file: Path | None = None) -> fuse.Stat:
st_size = 4096
st_atime = 0.0
st_mtime = 0.0
st_ctime = 0.0

if file:
s = file.stat()
st_size = s.st_size
st_atime = s.st_atime
st_mtime = s.st_mtime
st_ctime = s.st_ctime

return fuse.Stat(
st_nlink=1,
st_mode=(stat.S_IFDIR | 0o755) if mode == "dir" else (stat.S_IFREG | 0o644),
st_size=file.stat().st_size if file else 4096,
st_mode=(stat.S_IFDIR | 0o555) if mode == "dir" else (stat.S_IFREG | 0o444),
st_size=st_size,
st_uid=os.getuid(),
st_gid=os.getgid(),
st_atime=st_atime,
st_mtime=st_mtime,
st_ctime=st_ctime,
)

if p.view == "root":
Expand Down

0 comments on commit b1c98dd

Please sign in to comment.