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

cmd/go/internal/fsys: TestWalk fails on Plan 9 #42115

Closed
millerresearch opened this issue Oct 21, 2020 · 8 comments
Closed

cmd/go/internal/fsys: TestWalk fails on Plan 9 #42115

millerresearch opened this issue Oct 21, 2020 · 8 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Plan9
Milestone

Comments

@millerresearch
Copy link
Contributor

CL 262617 has a test which fails on Plan 9.

--- FAIL: TestWalk (0.06s)
    --- FAIL: TestWalk/no_overlay (0.01s)
        fsys_test.go:583: name of file #0 in walk, got "root", want "."
FAIL
FAIL	cmd/go/internal/fsys	0.780s
@bcmills
Copy link
Contributor

bcmills commented Oct 21, 2020

This appears to be due to a difference in the behavior of os.Lstat on Plan 9.

On other platforms, os.Lstat(".") empirically returns a FileInfo such that fi.Name() == ".", but on Plan 9 it seems to instead return the resolved name of the current working directory.

Is that difference intentional?

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Plan9 labels Oct 21, 2020
@bcmills bcmills added this to the Go1.16 milestone Oct 21, 2020
@bcmills
Copy link
Contributor

bcmills commented Oct 21, 2020

What does the program in https://play.golang.org/p/OHAkKG-4Tp- output when run on Plan 9?

(I can't run it myself due to #42117.)

@millerresearch
Copy link
Contributor Author

millerresearch commented Oct 21, 2020

Is that difference intentional?

It reflects the underlying semantics of Plan 9 file system. Plan 9 doesn't have separate directories and inodes, or links - the filesystem is a tree, not an arbitrary graph. The directory entry contains the name of the file element as well as the usual 'inode' information, and that's what stat returns in the name field. No resolving needed.

@millerresearch
Copy link
Contributor Author

What does the program in https://play.golang.org/p/OHAkKG-4Tp- output when run on Plan 9?

I copied it into /tmp, and did 'go run' from there. It outputs "tmp".

@millerresearch
Copy link
Contributor Author

go doc os.FileInfo says that the Name field is "base name of the file". On Plan 9 that's unambiguous because files have only one name. (You can dynamically bind other names to it, but that's something else.) On other systems with hard links, it can only give "a base name" because "the base name" doesn't seem to have a meaning.

@bcmills
Copy link
Contributor

bcmills commented Oct 21, 2020

Hmm. On other systems, there is one obvious base name to choose for ., which is the name given by calling filepath.Base on the result of os.Getwd(). But they don't do that today. 😞

Given your argument above, I suppose that the Lstat behavior on Plan 9 is correct and it is the other platforms that are not quite right.

@bcmills
Copy link
Contributor

bcmills commented Oct 21, 2020

Given your argument above, I suppose that the Lstat behavior on Plan 9 is correct and it is the other platforms that are not quite right.

Hrm. The stat(1) command on Linux is consistent with Go's Stat and Lstat:

$ cd /tmp
/tmp$ stat . --format=%n
.

I guess this is just a plain old platform variation. 😞

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/264177 mentions this issue: cmd/go/internal/fsys: use a root other than "." in Walk tests

@golang golang locked and limited conversation to collaborators Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Plan9
Projects
None yet
Development

No branches or pull requests

3 participants