From: Kir Kolyshkin Date: Wed, 3 Sep 2025 19:48:44 +0000 (-0700) Subject: path/filepath: fix EvalSymlinks to return ENOTDIR on plan9 X-Git-Tag: go1.26rc1~842 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6a8dbbecbf;p=gostls13.git path/filepath: fix EvalSymlinks to return ENOTDIR on plan9 CL 155597 added a test to check EvalSymlinks returns ENOTDIR for existing path which ends with a slash. CL 404954 added a separate evalSymlinks implementation for plan9, which has a kludge to ensure the ENOTDIR is returned in the above case. Apparently the added kludge is not working now (and maybe never worked), as seen in [1]: === RUN TestIssue29372 path_test.go:1730: test#0: want "not a directory", got "stat /tmp/TestIssue293724085649913/001/file.txt/: not a directory: '/tmp/TestIssue293724085649913/001/file.txt/'" --- FAIL: TestIssue29372 (0.00s) This happens because on plan9 errors are strings and they contain the file name after the error text, and the check assumes the "not a directory" text is at the end of the message. The fix is to check whether the error is somewhere in the error text, not ends with it (as it is done in other plan9 code, for example, see checkErrMessageContent added in CL 163058). This should fix the above test failure. PS perhaps the kludge should be moved up the call chain to os.Stat/Lstat? [1]: https://ci.chromium.org/ui/p/golang/builders/try/gotip-plan9-amd64/b8704772617873749345/test-results?q=ExactID%3Apath%2Ffilepath.TestIssue29372+VHash%3Aa63f5798e9f8f502 Change-Id: I6afb68be5f65a28929b2f717247ab34ff3b4a812 Reviewed-on: https://go-review.googlesource.com/c/go/+/700775 Auto-Submit: Emmanuel Odeke Reviewed-by: Michael Knyszek Reviewed-by: Dmitri Shuralyov Reviewed-by: Richard Miller TryBot-Bypass: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov --- diff --git a/src/path/filepath/symlink_plan9.go b/src/path/filepath/symlink_plan9.go index 820d150d97..b29abe1dfd 100644 --- a/src/path/filepath/symlink_plan9.go +++ b/src/path/filepath/symlink_plan9.go @@ -16,8 +16,8 @@ func evalSymlinks(path string) (string, error) { // Check validity of path _, err := os.Lstat(path) if err != nil { - // Return the same error value as on other operating systems - if strings.HasSuffix(err.Error(), "not a directory") { + // Return the same error value as on other operating systems. + if strings.Contains(err.Error(), "not a directory") { err = syscall.ENOTDIR } return "", err