diff options
author | Jakob Unterwurzacher | 2017-06-18 15:40:38 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-06-18 15:43:22 +0200 |
commit | a4563e21ecaf7d2acce64212c96de69707d6f0bb (patch) | |
tree | 433f9917fdd734f7a06ae854f0713847aaa79f0c /internal | |
parent | afc3a8252bacbe15a0815e348aea7071447d7d87 (diff) |
main, syscallcompat: use Dup3 instead of Dup2
Dup2 is not implemented on linux/arm64.
Fixes https://github.com/rfjakob/gocryptfs/issues/121 .
Also adds cross-compilation to CI.
Diffstat (limited to 'internal')
-rw-r--r-- | internal/syscallcompat/sys_darwin.go | 9 | ||||
-rw-r--r-- | internal/syscallcompat/sys_linux.go | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go index e635034..e77cd98 100644 --- a/internal/syscallcompat/sys_darwin.go +++ b/internal/syscallcompat/sys_darwin.go @@ -1,6 +1,7 @@ package syscallcompat import ( + "log" "os" "path/filepath" "sync" @@ -122,3 +123,11 @@ func dirfdAbs(dirfd int, path string) (string, error) { } return filepath.Join(wd, path), nil } + +// Dup3 is not available on Darwin, so we use Dup2 instead. +func Dup3(oldfd int, newfd int, flags int) (err error) { + if flags != 0 { + log.Panic("darwin does not support dup3 flags") + } + return syscall.Dup2(oldfd, newfd) +} diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go index 93516f3..441f904 100644 --- a/internal/syscallcompat/sys_linux.go +++ b/internal/syscallcompat/sys_linux.go @@ -62,3 +62,9 @@ func Unlinkat(dirfd int, path string) error { func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { return syscall.Mknodat(dirfd, path, mode, dev) } + +// Dup3 wraps the Dup3 syscall. We want to use Dup3 rather than Dup2 because Dup2 +// is not implemented on arm64. +func Dup3(oldfd int, newfd int, flags int) (err error) { + return syscall.Dup3(oldfd, newfd, flags) +} |