github.com/aayushi-bansal/sys@v0.0.0-20180118120756-90d962a959d8/unix/flock.go (about)

     1  // Copyright 2014 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  // +build darwin dragonfly freebsd linux netbsd openbsd
     6  
     7  package unix
     8  
     9  import "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.
    13  var fcntl64Syscall uintptr = SYS_FCNTL
    14  
    15  // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
    16  func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
    17  	_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
    18  	if errno == 0 {
    19  		return nil
    20  	}
    21  	return errno
    22  }