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

     1  //go:build illumos || solaris
     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  		// See https://github.com/illumos/illumos-gate/blob/edd580643f2cf1434e252cd7779e83182ea84945/usr/src/uts/common/sys/fcntl.h#L90
    16  		flag |= 0x1000000
    17  	}
    18  	if oflag&sys.O_DSYNC != 0 {
    19  		flag |= syscall.O_DSYNC
    20  	}
    21  	if oflag&sys.O_NOFOLLOW != 0 {
    22  		flag |= syscall.O_NOFOLLOW
    23  	}
    24  	if oflag&sys.O_NONBLOCK != 0 {
    25  		flag |= syscall.O_NONBLOCK
    26  	}
    27  	if oflag&sys.O_RSYNC != 0 {
    28  		flag |= syscall.O_RSYNC
    29  	}
    30  	return flag
    31  }