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 7package syscall 8 9import "unsafe" 10 11// F_DUP2FD_CLOEXEC has different values on Solaris and Illumos. 12const F_DUP2FD_CLOEXEC = 0x24 13 14//go:cgo_import_dynamic libc_flock flock "libc.so" 15 16//go:linkname procFlock libc_flock 17 18var procFlock libcFunc 19 20func 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