diff options
author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/golang.org/x/sys/unix/fcntl.go | |
parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip |
Make Nix builds work
Diffstat (limited to 'vendor/golang.org/x/sys/unix/fcntl.go')
-rw-r--r-- | vendor/golang.org/x/sys/unix/fcntl.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/fcntl.go b/vendor/golang.org/x/sys/unix/fcntl.go new file mode 100644 index 0000000..6200876 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/fcntl.go | |||
@@ -0,0 +1,36 @@ | |||
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 | //go:build dragonfly || freebsd || linux || netbsd | ||
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 fcntl_linux_32bit.go to be SYS_FCNTL64. | ||
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 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. | ||
25 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { | ||
26 | return fcntl(int(fd), cmd, arg) | ||
27 | } | ||
28 | |||
29 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. | ||
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 | } | ||