Files
wazero/internal/platform/stat_unsupported.go
Crypt Keeper e77f24fe31 sysfs: drops os.File special casing for fs.FS to pass wasi-testsuite (#1174)
This adds a wazero adapter which passes wasi-testsuite 100pct on darwin,
linux and windows. While the main change was adding inodes to the wasi
`fd_readdir` dirents, there was a lot of incidental work needed.

Most of the work was troubleshooting in nature, around windows
specifically, but also wrapping of files. This backfills a lot of tests
and reworked how wrapping works, particularly around windows.

To accommodate this, we drop `os.File` special casing except for
`sysfs.DirFS`

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-01 13:28:57 +08:00

42 lines
884 B
Go

//go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js
package platform
import (
"io/fs"
"os"
)
func lstat(path string, st *Stat_t) (err error) {
t, err := os.Lstat(path)
if err = UnwrapOSError(err); err == nil {
fillStatFromFileInfo(st, t)
}
return
}
func stat(path string, st *Stat_t) (err error) {
t, err := os.Stat(path)
if err = UnwrapOSError(err); err == nil {
fillStatFromFileInfo(st, t)
}
return
}
func statFile(f fs.File, st *Stat_t) error {
return defaultStatFile(f, st)
}
func inoFromFileInfo(readdirFile, fs.FileInfo) (ino uint64, err error) {
return
}
func fillStatFromFileInfo(st *Stat_t, t fs.FileInfo) {
fillStatFromDefaultFileInfo(st, t)
}
func fillStatFromOpenFile(st *Stat_t, fd uintptr, t os.FileInfo) (err error) {
fillStatFromFileInfo(st, t)
return
}