Files
wazero/internal/platform/stat_linux.go
Crypt Keeper 3609d74c92 Implements stat device/inode on WASI and GOOS=js (#1041)
This implements stat device and inode for WASI and GOOS=js, though it
does not implement the host side for windows, yet. Doing windows
requires plumbing as the values needed aren't exposed in Go. When we
re-do the syscallfs file type to have a stat method, we can address that
glitch. Meanwhile, I can find no Go sourcebase that does any better,
though the closest is the implementation details of os.SameFile.

I verified this with wasi-testsuite which now passes all but 1 case
which is unrelated (we haven't yet implemented `lseek`).

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-01-16 22:22:39 -06:00

27 lines
627 B
Go

//go:build (amd64 || arm64 || riscv64) && linux
// Note: This expression is not the same as compiler support, even if it looks
// similar. Platform functions here are used in interpreter mode as well.
package platform
import (
"os"
"syscall"
)
func statTimes(t os.FileInfo) (atimeNsec, mtimeNsec, ctimeNsec int64) {
d := t.Sys().(*syscall.Stat_t)
atime := d.Atim
mtime := d.Mtim
ctime := d.Ctim
return atime.Sec*1e9 + atime.Nsec, mtime.Sec*1e9 + mtime.Nsec, ctime.Sec*1e9 + ctime.Nsec
}
func statDeviceInode(t os.FileInfo) (dev, inode uint64) {
d := t.Sys().(*syscall.Stat_t)
dev = d.Dev
inode = d.Ino
return
}