mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00

All supported BSDs provide the SYS___GETCWD syscall which can be used to implement syscall.Getwd. With this change os.Getwd can use a single syscall instead of falling back to the current kludge solution on the BSDs. This doesn't add any new exported functions to the frozen syscall package, only ImplementsGetwd changes to true for dragonfly, freebsd, netbsd and openbsd. As suggested by Ian, this follows CL 83755 which did the same for golang.org/x/sys/unix. Also, an entry for netbsd/arm is added to mkall.sh which was used to generate the syscall wrappers there. Change-Id: I84da1ec61a6b8625443699a63cde556b6442ad41 Reviewed-on: https://go-review.googlesource.com/84484 Reviewed-by: Ian Lance Taylor <iant@golang.org>
22 lines
453 B
Go
22 lines
453 B
Go
// Copyright 2018 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.
|
|
|
|
// +build dragonfly freebsd netbsd openbsd
|
|
|
|
package syscall
|
|
|
|
const ImplementsGetwd = true
|
|
|
|
func Getwd() (string, error) {
|
|
var buf [pathMax]byte
|
|
_, err := getcwd(buf[:])
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
n := clen(buf[:])
|
|
if n < 1 {
|
|
return "", EINVAL
|
|
}
|
|
return string(buf[:n]), nil
|
|
}
|