Commit 58a9268f authored by David du Colombier's avatar David du Colombier

os: fix Rename on Plan 9

Rename should fail when the directory doesn't match.
It will fix the newly introduced test from cmd/pack
on Plan 9.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/65270044
parent 5a6af5fc
...@@ -332,6 +332,8 @@ func rename(oldname, newname string) error { ...@@ -332,6 +332,8 @@ func rename(oldname, newname string) error {
dirname := oldname[:lastIndex(oldname, '/')+1] dirname := oldname[:lastIndex(oldname, '/')+1]
if hasPrefix(newname, dirname) { if hasPrefix(newname, dirname) {
newname = newname[len(dirname):] newname = newname[len(dirname):]
} else {
return &LinkError{"rename", oldname, newname, ErrInvalid}
} }
// If newname still contains slashes after removing the oldname // If newname still contains slashes after removing the oldname
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment