From: Brad Fitzpatrick Date: Tue, 6 Aug 2013 19:04:08 +0000 (-0700) Subject: os: fix plan9 build X-Git-Tag: go1.2rc2~756 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ad119b9c4dcae8389a3700c245a923b0ebe449cd;p=gostls13.git os: fix plan9 build 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 --- diff --git a/src/pkg/os/getwd.go b/src/pkg/os/getwd.go index 1326e15259..8c5ff7fca5 100644 --- a/src/pkg/os/getwd.go +++ b/src/pkg/os/getwd.go @@ -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 index 0000000000..e51ffcd5e7 --- /dev/null +++ b/src/pkg/os/getwd_darwin.go @@ -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 +}