aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/fs_wasip1.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall/fs_wasip1.go')
-rw-r--r--src/syscall/fs_wasip1.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/syscall/fs_wasip1.go b/src/syscall/fs_wasip1.go
index 4d3d7d72c6..fc361ee898 100644
--- a/src/syscall/fs_wasip1.go
+++ b/src/syscall/fs_wasip1.go
@@ -7,6 +7,7 @@
package syscall
import (
+ "internal/stringslite"
"runtime"
"unsafe"
)
@@ -287,12 +288,18 @@ func fd_fdstat_get(fd int32, buf unsafe.Pointer) Errno
//go:noescape
func fd_fdstat_set_flags(fd int32, flags fdflags) Errno
+// fd_fdstat_get_flags is accessed from internal/syscall/unix
+//go:linkname fd_fdstat_get_flags
+
func fd_fdstat_get_flags(fd int) (uint32, error) {
var stat fdstat
errno := fd_fdstat_get(int32(fd), unsafe.Pointer(&stat))
return uint32(stat.fdflags), errnoErr(errno)
}
+// fd_fdstat_get_type is accessed from net
+//go:linkname fd_fdstat_get_type
+
func fd_fdstat_get_type(fd int) (uint8, error) {
var stat fdstat
errno := fd_fdstat_get(int32(fd), unsafe.Pointer(&stat))
@@ -468,19 +475,11 @@ func joinPath(dir, file string) string {
}
func isAbs(path string) bool {
- return hasPrefix(path, "/")
+ return stringslite.HasPrefix(path, "/")
}
func isDir(path string) bool {
- return hasSuffix(path, "/")
-}
-
-func hasPrefix(s, p string) bool {
- return len(s) >= len(p) && s[:len(p)] == p
-}
-
-func hasSuffix(s, x string) bool {
- return len(s) >= len(x) && s[len(s)-len(x):] == x
+ return stringslite.HasSuffix(path, "/")
}
// preparePath returns the preopen file descriptor of the directory to perform
@@ -500,7 +499,7 @@ func preparePath(path string) (int32, unsafe.Pointer, size) {
path = joinPath(dir, path)
for _, p := range preopens {
- if len(p.name) > len(dirName) && hasPrefix(path, p.name) {
+ if len(p.name) > len(dirName) && stringslite.HasPrefix(path, p.name) {
dirFd, dirName = p.fd, p.name
}
}