1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // The working directory in Plan 9 is effectively per P, so different
6 // goroutines and even the same goroutine as it's rescheduled on
7 // different Ps can see different working directories.
9 // Instead, track a Go process-wide intent of the current working directory,
10 // and switch to it at important points.
17 wdmu sync
.Mutex
// guards following
32 // always call chdir when getwd returns an error
37 if err
:= chdir(wdStr
); err
!= nil {
42 // goroutine-specific getwd
43 func getwd() (wd
string, err error
) {
44 fd
, err
:= open(".", O_RDONLY
)
52 func Getwd() (wd
string, err error
) {
68 func Chdir(path
string) error
{
72 if err
:= chdir(path
); err
!= nil {