-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add note about filesystems to fs::rename #25128
Conversation
@@ -844,6 +844,8 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> { | |||
|
|||
/// Rename a file or directory to a new name. | |||
/// | |||
/// This will not work if the new name is on a different filesystem. | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, on linux, this will not work across mount points even if the filesystems are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stebalien by "filesystems are the same", is ext4 an example of a filesystem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filesystem as used in this comment (i.e. partition?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that you can have multiple mount points in the same partition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that depends on the filesystem. The trivial example is bind mount which lets you mount a directory:
mkdir /path/to/a
mkdir /path/to/b
mount -o bind /path/to/a /path/to/b
These both have the same filesystem (the directory /path/to/a
) but different mount points. See the EXDEV comment in man 2 rename
(on linux).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, filesystem is rather ambiguous. Maybe @steveklabnik should simply say mount point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, filesystem is incorrect on linux (both interpretations) HOWEVER, on reading the windows spec, I get the impression that you can rename files between mount points (you can mount drives in folders: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365733%28v=vs.85%29.aspx) as long as they refer to the same underlying filesystem (partition).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, impressive :)
@bors: rollup |
Fixes #24816
r? @alexcrichton