Path: blob/main/vendor/golang.org/x/sys/unix/fcntl.go
2880 views
// Copyright 2014 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34//go:build dragonfly || freebsd || linux || netbsd56package unix78import "unsafe"910// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux11// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.12var fcntl64Syscall uintptr = SYS_FCNTL1314func fcntl(fd int, cmd, arg int) (int, error) {15valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))16var err error17if errno != 0 {18err = errno19}20return int(valptr), err21}2223// FcntlInt performs a fcntl syscall on fd with the provided command and argument.24func FcntlInt(fd uintptr, cmd, arg int) (int, error) {25return fcntl(int(fd), cmd, arg)26}2728// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.29func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {30_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))31if errno == 0 {32return nil33}34return errno35}363738