syscall_illumos.mx raw

   1  // Copyright 2020 The Go Authors. All rights reserved.
   2  // Use of this source code is governed by a BSD-style
   3  // license that can be found in the LICENSE file.
   4  
   5  //go:build illumos
   6  
   7  package syscall
   8  
   9  import "unsafe"
  10  
  11  // F_DUP2FD_CLOEXEC has different values on Solaris and Illumos.
  12  const F_DUP2FD_CLOEXEC = 0x24
  13  
  14  //go:cgo_import_dynamic libc_flock flock "libc.so"
  15  
  16  //go:linkname procFlock libc_flock
  17  
  18  var procFlock libcFunc
  19  
  20  func Flock(fd int, how int) error {
  21  	_, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0)
  22  	if errno != 0 {
  23  		return errno
  24  	}
  25  	return nil
  26  }
  27