Skip to content

Commit

Permalink
Use nanoseconds in filestat
Browse files Browse the repository at this point in the history
This commit fixes the `filestat` type which contains three timestamps.
Per [WASI spec], they should be in nanoseconds.  This is only a problem
for directories.

[WASI spec]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-timestamp-u64

Signed-off-by: Yage Hu <[email protected]>
  • Loading branch information
yagehu authored and theduke committed Jan 15, 2024
1 parent 69c0aa2 commit d2f2d05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/virtual-fs/src/mem_fs/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1520,11 +1520,13 @@ mod test_filesystem {
modified,
len: 0
}) if
accessed == foo_metadata.accessed &&
created == foo_metadata.created &&
accessed <= foo_metadata.accessed &&
created <= foo_metadata.created &&
modified > foo_metadata.modified
),
"the modified time of the parent is updated when file is renamed",
"the modified time of the parent is updated when file is renamed \n{:?}\n{:?}",
fs.metadata(path!("/")),
foo_metadata,
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/virtual-fs/src/mem_fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn time() -> u64 {
std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
.as_nanos() as u64
}

#[cfg(feature = "no-time")]
Expand Down

0 comments on commit d2f2d05

Please sign in to comment.