fsapi: adds Oflag to decouple from syscall package (#1586)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-07-19 16:01:44 +08:00
committed by GitHub
parent 1e0c73d569
commit b842d6cbfd
47 changed files with 646 additions and 514 deletions

View File

@@ -0,0 +1,28 @@
package sysfs
import (
"syscall"
"github.com/tetratelabs/wazero/internal/fsapi"
)
const supportedSyscallOflag = fsapi.O_DIRECTORY | fsapi.O_DSYNC | fsapi.O_NOFOLLOW | fsapi.O_NONBLOCK | fsapi.O_RSYNC
func withSyscallOflag(oflag fsapi.Oflag, flag int) int {
if oflag&fsapi.O_DIRECTORY != 0 {
flag |= syscall.O_DIRECTORY
}
if oflag&fsapi.O_DSYNC != 0 {
flag |= syscall.O_DSYNC
}
if oflag&fsapi.O_NOFOLLOW != 0 {
flag |= syscall.O_NOFOLLOW
}
if oflag&fsapi.O_NONBLOCK != 0 {
flag |= syscall.O_NONBLOCK
}
if oflag&fsapi.O_RSYNC != 0 {
flag |= syscall.O_RSYNC
}
return flag
}