]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix plan9 build
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 6 Aug 2013 19:04:08 +0000 (12:04 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 6 Aug 2013 19:04:08 +0000 (12:04 -0700)
I broke it with the darwin getwd attrlist stuff (0583e9d36dd).
plan9 doesn't have syscall.ENOTSUP.

It's in api/go1.txt as a symbol always available (not context-specific):

pkg syscall, const ENOTSUP Errno

... but plan9 isn't considered by cmd/api, so it only looks
universally available.  Alternatively, we could add a fake ENOTSUP
to plan9, but they were making efforts earlier to clean their
syscall package, so I'd prefer not to dump more in it.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12509044

src/pkg/os/getwd.go
src/pkg/os/getwd_darwin.go [new file with mode: 0644]

index 1326e152593d52cbbd9fa038af1f28e9076b7cb9..8c5ff7fca51a53ad64ab7e202e23d3061d095b6a 100644 (file)
@@ -14,6 +14,10 @@ var getwdCache struct {
        dir string
 }
 
+// useSyscallwd determines whether to use the return value of
+// syscall.Getwd based on its error.
+var useSyscallwd = func(error) bool { return true }
+
 // Getwd returns a rooted path name corresponding to the
 // current directory.  If the current directory can be
 // reached via multiple paths (due to symbolic links),
@@ -22,7 +26,7 @@ func Getwd() (pwd string, err error) {
        // If the operating system provides a Getwd call, use it.
        if syscall.ImplementsGetwd {
                s, e := syscall.Getwd()
-               if e != syscall.ENOTSUP {
+               if useSyscallwd(e) {
                        return s, NewSyscallError("getwd", e)
                }
        }
diff --git a/src/pkg/os/getwd_darwin.go b/src/pkg/os/getwd_darwin.go
new file mode 100644 (file)
index 0000000..e51ffcd
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2009 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.
+
+package os
+
+import "syscall"
+
+func init() {
+       useSyscallwd = useSyscallwdDarwin
+}
+
+func useSyscallwdDarwin(err error) bool {
+       return err != syscall.ENOTSUP
+}