github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/sys/stat_linux.go (about) 1 //go:build (amd64 || arm64 || riscv64) && linux 2 3 // Note: This expression is not the same as compiler support, even if it looks 4 // similar. Platform functions here are used in interpreter mode as well. 5 6 package sys 7 8 import ( 9 "io/fs" 10 "syscall" 11 ) 12 13 const sysParseable = true 14 15 func statFromFileInfo(info fs.FileInfo) Stat_t { 16 if d, ok := info.Sys().(*syscall.Stat_t); ok { 17 st := Stat_t{} 18 st.Dev = uint64(d.Dev) 19 st.Ino = uint64(d.Ino) 20 st.Mode = info.Mode() 21 st.Nlink = uint64(d.Nlink) 22 st.Size = d.Size 23 atime := d.Atim 24 st.Atim = atime.Sec*1e9 + atime.Nsec 25 mtime := d.Mtim 26 st.Mtim = mtime.Sec*1e9 + mtime.Nsec 27 ctime := d.Ctim 28 st.Ctim = ctime.Sec*1e9 + ctime.Nsec 29 return st 30 } 31 return defaultStatFromFileInfo(info) 32 }