blob: 62736ae9dcb4c442d00afe7f268a32f7db8a3877 [file] [log] [blame]
Brad Fitzpatrick5d3033c2014-01-21 14:52:44 -08001// +build linux darwin freebsd openbsd netbsd dragonfly
2
3// Copyright 2014 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package syscall
8
9import "unsafe"
10
11// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
12// systems by flock_linux_32bit.go to be SYS_FCNTL64.
13var fcntl64Syscall uintptr = SYS_FCNTL
14
Brad Fitzpatrick367ad452014-01-21 16:27:39 -080015// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
16func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
Brad Fitzpatrick5d3033c2014-01-21 14:52:44 -080017 _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
18 if errno == 0 {
19 return nil
20 }
21 return errno
22}