1
0
mirror of https://github.com/golang/go synced 2024-11-12 08:40:21 -07:00

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
This commit is contained in:
Brad Fitzpatrick 2013-08-06 12:04:08 -07:00
parent 9115345925
commit ad119b9c4d
2 changed files with 20 additions and 1 deletions

View 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)
}
}

View File

@ -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
}