github.com/gaukas/wazerofs@v0.1.0/sysfs/open_file_freebsd.go (about)

     1  package sysfs
     2  
     3  import (
     4  	"syscall"
     5  
     6  	"github.com/tetratelabs/wazero/experimental/sys"
     7  )
     8  
     9  const supportedSyscallOflag = sys.O_DIRECTORY | sys.O_NOFOLLOW | sys.O_NONBLOCK
    10  
    11  func withSyscallOflag(oflag sys.Oflag, flag int) int {
    12  	if oflag&sys.O_DIRECTORY != 0 {
    13  		flag |= syscall.O_DIRECTORY
    14  	}
    15  	// syscall.O_DSYNC not defined on darwin
    16  	if oflag&sys.O_NOFOLLOW != 0 {
    17  		flag |= syscall.O_NOFOLLOW
    18  	}
    19  	if oflag&sys.O_NONBLOCK != 0 {
    20  		flag |= syscall.O_NONBLOCK
    21  	}
    22  	// syscall.O_RSYNC not defined on darwin
    23  	return flag
    24  }