Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: DirFS has interaction with Chdir #47214

Open
kortschak opened this issue Jul 15, 2021 · 1 comment
Open

os: DirFS has interaction with Chdir #47214

kortschak opened this issue Jul 15, 2021 · 1 comment

Comments

@kortschak
Copy link
Contributor

@kortschak kortschak commented Jul 15, 2021

This is something that may not be significant enough to address, but I thought it was worth raising.

What version of Go are you using (go version)?

$ go version
go version go1.17rc1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/user/bin"
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/user/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17rc1"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build511087247=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Given a main.go from https://play.golang.org/p/Tccj4KWcX7X

$ cd /home/user/dirfs
$ mkdir dirA
$ go run main.go

What did you see?

I saw exactly what I expected, but it could be something that may surprise some users.

2021/07/15 15:02:04 from "/home/user/dirfs/dirA": open dirA/file: no such file or directory
exit status 1

Given that the DirFS was handed a relative path, it's entirely reasonable for reads subsequent to a chdir to be now relative to the new working directory, but it may be worth clarifying that the DirFS does not hold an absolute path as its root unless it was handed one or some other way to indicate that chdir will alter the effective filesystem that's seen.

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jul 15, 2021

cc @rsc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants