Skip to content

Add note about filesystems to fs::rename #25128

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

Merged
merged 1 commit into from
May 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 mount point.
///
Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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?)

Copy link
Member

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?

Copy link
Contributor

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).

Copy link
Member

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?

Copy link
Contributor

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, impressive :)

/// # Errors
///
/// This function will return an error if the provided `from` doesn't exist, if
Expand Down