github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/sysfs/open_file_linux.go (about)

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