Closed yagehu closed 7 months ago
The filestat type returned by fd_filestat_get should contain timestamps in nanoseconds. However, currently Wasmer returns timestamps in seconds for directories, e.g. preopened directories.
filestat
fd_filestat_get
wasmer 4.2.4 (1abcd2c 2023-12-16) binary: wasmer-cli commit-hash: 1abcd2cc63deeca13af6506add6029edaba4d657 commit-date: 2023-12-16 host: x86_64-unknown-linux-gnu compiler: singlepass,cranelift rustc 1.73.0 (cc66ad468 2023-10-03) binary: rustc commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33 commit-date: 2023-10-03 host: x86_64-unknown-linux-gnu release: 1.73.0 LLVM version: 17.0.2
Compile this C snippet with wasi-sdk and run the binary with Wasmer.
clang wasmer-dir-time.c wasmer run --dir . a.out
#include <unistd.h> #include <sys/stat.h> #include <stdio.h> int main(void) { struct stat buf; int ret = fstat(4, &buf); if (ret != 0) { perror("fstat"); return 1; } printf("atime %lld seconds", buf.st_atime); return 0; }
It should print a reasonable timestamp like:
atime 1702794075 seconds
It prints a very small number:
atime 1 seconds
RUN-23 `filestat` should contain timestamps in nanoseconds, not seconds
Describe the bug
The
filestat
type returned byfd_filestat_get
should contain timestamps in nanoseconds. However, currently Wasmer returns timestamps in seconds for directories, e.g. preopened directories.Steps to reproduce
Compile this C snippet with wasi-sdk and run the binary with Wasmer.
Expected behavior
It should print a reasonable timestamp like:
Actual behavior
It prints a very small number: