-
Notifications
You must be signed in to change notification settings - Fork 79
Implement Darwin (MacOS) #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7cf956a
Implement Darwin (macOS) support
lancepioch c3a4905
Reduce log level for expected websocket disconnects
lancepioch 93d47ba
Add Darwin build targets and macOS CI job
lancepioch a1c69f1
Document running Wings on macOS
lancepioch 74ca284
Fix zero CTime for os.File-backed Stats on Linux
lancepioch 3e6536f
Add explicit go:build constraints to platform-split files
lancepioch fe06864
Close fd on openat path-validation failure
lancepioch bf1015b
Disable credential persistence in CI checkouts
lancepioch 430f01a
Split quota stubs into darwin-specific file
lancepioch a8986d6
Tag unix-only files and fix self-update OS in binary name
lancepioch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| //go:build darwin | ||
|
|
||
| package config | ||
|
|
||
| // UseOpenat2 always returns false on Darwin as the openat2 syscall is | ||
| // Linux-specific (kernel 5.6+). | ||
| func UseOpenat2() bool { | ||
| return false | ||
| } |
|
lancepioch marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //go:build linux | ||
|
|
||
| package config | ||
|
|
||
| import ( | ||
| "sync/atomic" | ||
|
|
||
| "github.com/apex/log" | ||
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| var ( | ||
| openat2 atomic.Bool | ||
| openat2Set atomic.Bool | ||
| ) | ||
|
|
||
| func UseOpenat2() bool { | ||
| if openat2Set.Load() { | ||
| return openat2.Load() | ||
| } | ||
| defer openat2Set.Store(true) | ||
|
|
||
| c := Get() | ||
| openatMode := c.System.OpenatMode | ||
| switch openatMode { | ||
| case "openat2": | ||
| openat2.Store(true) | ||
| return true | ||
| case "openat": | ||
| openat2.Store(false) | ||
| return false | ||
| default: | ||
| fd, err := unix.Openat2(unix.AT_FDCWD, "/", &unix.OpenHow{}) | ||
| if err != nil { | ||
| log.WithError(err).Warn("error occurred while checking for openat2 support, falling back to openat") | ||
| openat2.Store(false) | ||
| return false | ||
| } | ||
| _ = unix.Close(fd) | ||
| openat2.Store(true) | ||
| return true | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //go:build linux | ||
|
|
||
| package config | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestUseOpenat2ConfigOverride(t *testing.T) { | ||
| Set(&Configuration{ | ||
| AuthenticationToken: "test", | ||
| System: SystemConfiguration{ | ||
| OpenatMode: "openat", | ||
| }, | ||
| }) | ||
| openat2Set.Store(false) | ||
|
|
||
| if UseOpenat2() { | ||
| t.Error("expected UseOpenat2() to return false when mode is 'openat'") | ||
| } | ||
|
|
||
| openat2Set.Store(false) | ||
| Update(func(c *Configuration) { | ||
| c.System.OpenatMode = "openat2" | ||
| }) | ||
|
|
||
| if !UseOpenat2() { | ||
| t.Error("expected UseOpenat2() to return true when mode is 'openat2'") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "runtime" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestUseOpenat2(t *testing.T) { | ||
| // Ensure UseOpenat2 doesn't panic. | ||
| Set(&Configuration{ | ||
| AuthenticationToken: "test", | ||
| System: SystemConfiguration{ | ||
| OpenatMode: "auto", | ||
| }, | ||
| }) | ||
|
|
||
| result := UseOpenat2() | ||
|
|
||
| switch runtime.GOOS { | ||
| case "darwin": | ||
| if result { | ||
| t.Error("expected UseOpenat2() to return false on Darwin") | ||
| } | ||
| case "linux": | ||
| // On Linux it may be true or false depending on kernel version. | ||
| // Just verify it returns without error. | ||
| t.Logf("UseOpenat2() returned %v on Linux", result) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| //go:build darwin | ||
|
|
||
| package ufs | ||
|
|
||
| // O_LARGEFILE is a no-op on Darwin as all files support large offsets. | ||
| const O_LARGEFILE = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| //go:build linux | ||
|
|
||
| package ufs | ||
|
|
||
| import "golang.org/x/sys/unix" | ||
|
|
||
| const O_LARGEFILE = unix.O_LARGEFILE |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.