fsapi: adds Oflag to decouple from syscall package (#1586)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
28
internal/sysfs/open_file_linux.go
Normal file
28
internal/sysfs/open_file_linux.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user