Skip to content

Commit

Permalink
feat: add support for Illumos/Solaris (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaige authored Jun 29, 2024
1 parent e5593aa commit d82685e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

# Not supported by flock:
# - plan9/*
# - solaris/*
# - js/wasm
# - wasp1/wasm

for row in $(go tool dist list -json | jq -r '.[] | select( .GOOS != "plan9" and .GOOS != "solaris" and .GOARCH != "wasm") | @base64'); do
for row in $(go tool dist list -json | jq -r '.[] | select( .GOOS != "plan9" and .GOARCH != "wasm") | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
Expand Down
2 changes: 1 addition & 1 deletion flock.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (f *Flock) setFh() error {
// open a new os.File instance
// create it if it doesn't exist, and open the file read-only.
flags := os.O_CREATE
if runtime.GOOS == "aix" {
if runtime.GOOS == "aix" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
// AIX cannot preform write-lock (ie exclusive) on a
// read-only file.
flags |= os.O_RDWR
Expand Down
2 changes: 1 addition & 1 deletion flock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *TestSuite) TestFlock_TryRLock() {
locked, err = flock2.TryRLock()
s.Require().NoError(err)

if runtime.GOOS == "aix" {
if runtime.GOOS == "aix" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
// When using POSIX locks, we can't safely read-lock the same
// inode through two different descriptors at the same time:
// when the first descriptor is closed, the second descriptor
Expand Down
2 changes: 1 addition & 1 deletion flock_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.

//go:build !aix && !windows
//go:build !aix && !solaris && !windows

package flock

Expand Down
2 changes: 1 addition & 1 deletion flock_aix.go → flock_unix_variants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// This code is adapted from the Go package:
// cmd/go/internal/lockedfile/internal/filelock

//go:build aix
//go:build aix || solaris

package flock

Expand Down

0 comments on commit d82685e

Please sign in to comment.