Files
wazero/internal/platform/stat_unsupported.go
Crypt Keeper 36bf277534 sysfs: requires all methods to return syscall.Errno (#1264)
This forces all syscall functions, notably filesystem, to return numeric
codes as opposed to mapping in two different areas. The result of this
change is better consolidation in call sites of `sysfs.FS`, while
further refactoring is needed to address consolidation of file errors.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-22 07:47:57 +01:00

40 lines
844 B
Go

//go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js
package platform
import (
"io/fs"
"os"
"syscall"
)
func lstat(path string) (Stat_t, syscall.Errno) {
t, err := os.Lstat(path)
if errno := UnwrapOSError(err); errno == 0 {
return statFromFileInfo(t), 0
} else {
return Stat_t{}, errno
}
}
func stat(path string) (Stat_t, syscall.Errno) {
t, err := os.Stat(path)
if errno := UnwrapOSError(err); errno == 0 {
return statFromFileInfo(t), 0
} else {
return Stat_t{}, errno
}
}
func statFile(f fs.File) (Stat_t, syscall.Errno) {
return defaultStatFile(f)
}
func inoFromFileInfo(_ readdirFile, t fs.FileInfo) (ino uint64, err syscall.Errno) {
return
}
func statFromFileInfo(t fs.FileInfo) Stat_t {
return statFromDefaultFileInfo(t)
}