xfs support in test_rename_directory_to_non_empty_directory#156762
Merged
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.
06a46ea to
c7a9cdc
Compare
the8472
reviewed
May 20, 2026
Member
The linux So this looks correct. |
Member
|
r=me with commits squashed. Thanks! |
Member
|
@bors squash Actually I'll just go via our squash tooling. |
Contributor
|
🔑 The |
Member
|
Ah, ok. @rustbot author |
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
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
```
bce4a4e to
3cbe424
Compare
Contributor
Author
|
@rustbot ready |
Member
|
@bors r+ rollup |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
…uwer Rollup of 13 pull requests Successful merges: - #147302 (asm! support for the Xtensa architecture) - #148820 (Add very basic "comptime" fn implementation) - #157299 (Fix unstable diagnostics in tests) - #143511 (Improve TLS codegen by marking the panic/init path as cold) - #154608 (Add `_value` API for number literals in proc-macro) - #156762 (xfs support in `test_rename_directory_to_non_empty_directory`) - #157300 (Relax test requirements for consistency) - #157383 (tests: codegen-llvm: Ignore BPF targets in c-variadic-opt) - #157413 (fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option) - #157578 (Fix diagnostics for non-exhaustive destructuring assignments (#157553)) - #157587 (explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls) - #157596 (test: remove ineffective link-extern-crate-with-drop-type test) - #157602 (rustdoc: Remove unnecessary fast path)
rust-timer
added a commit
that referenced
this pull request
Jun 8, 2026
Rollup merge of #156762 - ferrocene:hoverbear/xfs-test-fix, r=Mark-Simulacrum xfs support in `test_rename_directory_to_non_empty_directory` 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](ferrocene/ferrocene#2375). The test failing: https://github.com/rust-lang/rust/blob/1ea1171c1e537f295225be1c7b67dba46794e6ad/library/std/src/fs/tests.rs#L2141-L2157 It was recently removed from being Windows-only in: a0298aa#diff-0ec4075fea7f5f4cc82c306e975ae7638b1fc500d30c11a83f337a69ef1dfd65L2177 Seemingly on XFS only, the `AlreadyExists` variant 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: ```bash ana@autonoma ~/git/ferrocene/scratch ❯ mkdir blap flap ana@autonoma ~/git/ferrocene/scratch ❯ touch flap/zap ana@autonoma ~/git/ferrocene/scratch ❯ python Python 3.13.13 (main, May 15 2026, 12:38:54) [GCC 15.2.1 20260214] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.rename("blap", "flap") Traceback (most recent call last): File "<python-input-3>", line 1, in <module> os.rename("blap", "flap") ~~~~~~~~~^^^^^^^^^^^^^^^^ FileExistsError: [Errno 17] File exists: 'blap' -> 'flap' ana@autonoma ~/git/ferrocene/scratch ❯ cd /tmp/ ana@autonoma /tmp ❯ mkdir blap flap ana@autonoma /tmp ❯ touch flap/zap ana@autonoma /tmp ❯ python Python 3.13.13 (main, May 15 2026, 12:38:54) [GCC 15.2.1 20260214] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.rename("blap", "flap") Traceback (most recent call last): File "<python-input-1>", line 1, in <module> os.rename("blap", "flap") ~~~~~~~~~^^^^^^^^^^^^^^^^ OSError: [Errno 39] Directory not empty: 'blap' -> 'flap' ``` I tested on `ext4`, `tmpfs`, `overlayfs`, `btrfs`, and `xfs`. Only XFS seems to display this error. ## Reproduction 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 ``` You can run this test directly: ```bash ./x.py --stage 2 test library/std --target x86_64-unknown-linux-gnu -- fs::tests::test_rename_directory_to_non_empty_directory --nocapture ```
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