Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
os: Rename on Plan 9 handles newname incorrectly #6401
os.Rename on Plan 9 simply does a Wstat, which has some limitations that make its use behave different than normal use cases. http://plan9.bell-labs.com/magic/man2html/5/stat you cannot move a file between directories with os.Rename on plan 9, since it only does Wstat. to do this you must do a create/copy/remove. much code appears to expect to be able to pass a full path component in the newname argument. this fails because you cannot pass a slash to Wstat. with both of these, code must have a special case for doing renaming operations on plan 9. os.Rename should probably try to closer match the code in http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/mv.c
The handling of newname is definitely wrong. The code must check that the two paths have the same leading directory and then pass only the final element. However, the first half of the suggestion is wrong too: os.Rename is allowed to fail for different directories and on Plan 9 it should. It is a mistake to do the Copy behind the user's back. os.Rename can fail on Unix too, if the directories are on different file systems. Since Plan 9 is not a supported system, this will have to wait until Go 1.3.
Labels changed: added priority-later, go1.3, removed priority-triage.
Status changed to Accepted.
This issue was closed.