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