1
2
3
4
5
6
7 package unix
8
9 import "unsafe"
10
11
12
13 var fcntl64Syscall uintptr = SYS_FCNTL
14
15 func fcntl(fd int, cmd, arg int) (int, error) {
16 valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
17 var err error
18 if errno != 0 {
19 err = errno
20 }
21 return int(valptr), err
22 }
23
24
25 func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
26 return fcntl(int(fd), cmd, arg)
27 }
28
29
30 func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
31 _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
32 if errno == 0 {
33 return nil
34 }
35 return errno
36 }
37
View as plain text