diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2020-09-16 22:15:13 +0200 |
---|---|---|
committer | Tobias Klauser <tobias.klauser@gmail.com> | 2020-09-17 06:20:06 +0000 |
commit | 7f24142b7b289df7e98ed3e1ccd673824dd1d0ee (patch) | |
tree | 493d5c0591413e9423d529c1c0e74e165a83e3ae /src/syscall | |
parent | f5d59d0e382dc59195537a128fe9423a49a4cea8 (diff) | |
download | go-7f24142b7b289df7e98ed3e1ccd673824dd1d0ee.tar.gz go-7f24142b7b289df7e98ed3e1ccd673824dd1d0ee.zip |
syscall, cmd/go/internal/lockedfile/internal/filelock: add and use Flock on illumos
Copy the syscall wrapper from golang.org/x/sys/unix CL 255377 to provide
Flock on illumos and switch cmd/go/internal/lockedfile/internal/filelock
to use it.
Fixes #35618
Change-Id: I876a2b782329a988fa85361fb1ea58eb6f329af1
Reviewed-on: https://go-review.googlesource.com/c/go/+/255258
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/syscall')
-rw-r--r-- | src/syscall/syscall_illumos.go | 25 | ||||
-rw-r--r-- | src/syscall/types_illumos_amd64.go | 17 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/syscall/syscall_illumos.go b/src/syscall/syscall_illumos.go new file mode 100644 index 0000000000..1484337e1b --- /dev/null +++ b/src/syscall/syscall_illumos.go @@ -0,0 +1,25 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build illumos + +// Illumos system calls not present on Solaris. + +package syscall + +import "unsafe" + +//go:cgo_import_dynamic libc_flock flock "libc.so" + +//go:linkname procFlock libc_flock + +var procFlock libcFunc + +func Flock(fd int, how int) error { + _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0) + if errno != 0 { + return errno + } + return nil +} diff --git a/src/syscall/types_illumos_amd64.go b/src/syscall/types_illumos_amd64.go new file mode 100644 index 0000000000..abb282f3e4 --- /dev/null +++ b/src/syscall/types_illumos_amd64.go @@ -0,0 +1,17 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build illumos + +// Illumos consts not present on Solaris. These are added manually rather than +// auto-generated by mkerror.sh + +package syscall + +const ( + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 +) |