xfs support in test_rename_directory_to_non_empty_directory#156762
Open
Hoverbear wants to merge 2 commits into
Open
xfs support in test_rename_directory_to_non_empty_directory#156762Hoverbear wants to merge 2 commits into
test_rename_directory_to_non_empty_directory#156762Hoverbear wants to merge 2 commits into
Conversation
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
Seemingly on XFS only, the `AlreadyExists` variant is returned.
Reproducible on Linux hosts:
```rust
use clap::Parser;
struct Args {
/// Destination to try
#[arg()]
path: std::path::PathBuf,
}
fn main() {
let args = Args::parse();
// Renaming a directory over a non-empty existing directory should fail.
let tmpdir = std::path::Path::new(&args.path);
std::fs::create_dir_all(tmpdir).unwrap();
let source_path = tmpdir.join("source_directory");
let target_path = tmpdir.join("target_directory");
std::fs::create_dir(&source_path).unwrap();
std::fs::create_dir(&target_path).unwrap();
let target_path_file = target_path.join("target_file.txt");
std::fs::write(target_path.join("target_file.txt"), b"target hello world").unwrap();
println!("wrote {target_path_file:?}");
println!("{source_path:?} -> {target_path:?}");
let err = std::fs::rename(source_path, target_path).unwrap_err();
assert_eq!(err.kind(), std::io::ErrorKind::DirectoryNotEmpty);
}
```
```bash
XFS_BLOCK=image-xfs
truncate -s 512M image-xfs
mkfs.xfs -q image-xfs
mkdir mnt-xfs
sudo mount -o loop image-xfs mnt-xfs
sudo chmod 777 mnt-xfs
cargo run -- mnt-xfs/
```
Output:
```
wrote "mnt-xfs/target_directory/target_file.txt"
"mnt-xfs/source_directory" -> "mnt-xfs/target_directory"
thread 'main' (267220) panicked at src/main.rs:30:5:
assertion `left == right` failed
left: AlreadyExists
right: DirectoryNotEmpty
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
06a46ea to
c7a9cdc
Compare
the8472
reviewed
May 20, 2026
Member
The linux So this looks correct. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

While running Ferrocene's test suite we use a variety of filesystems, including XFS. Those systems caught a failing test in a recent upstream pull.
The test failing:
rust/library/std/src/fs/tests.rs
Lines 2141 to 2157 in 1ea1171
It was recently removed from being Windows-only in: a0298aa#diff-0ec4075fea7f5f4cc82c306e975ae7638b1fc500d30c11a83f337a69ef1dfd65L2177
Seemingly on XFS only, the
AlreadyExistsvariant is returned instead.This workaround allows both possible errors. I am unsure at this time if it is a signal of incorrectness in Rust somewhere, but on Python a similar failure can be noted:
I tested on
ext4,tmpfs,overlayfs,btrfs, andxfs. Only XFS seems to display this error.Reproduction
On Linux hosts:
Output:
You can run this test directly:
./x.py --stage 2 test library/std --target x86_64-unknown-linux-gnu -- fs::tests::test_rename_directory_to_non_empty_directory --nocapture