1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

mv: fix moving FIFO to a different filesystem

Fix a bug in `mv` where it would hang indefinitely while trying to copy
a FIFO across filesystems. The solution is to remove the old FIFO and
create a new one on the new filesystem.

Fixes #7076
This commit is contained in:
Jeffrey Finkelstein 2025-04-17 20:32:34 -04:00
parent 1d89ea5b6d
commit 2717f9c8b5
3 changed files with 51 additions and 1 deletions

View file

@ -7,6 +7,8 @@
use filetime::FileTime;
use rstest::rstest;
use std::io::Write;
#[cfg(not(windows))]
use std::path::Path;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::{at_and_ucmd, util_name};
@ -1876,3 +1878,18 @@ fn test_mv_error_msg_with_multiple_sources_that_does_not_exist() {
.stderr_contains("mv: cannot stat 'a': No such file or directory")
.stderr_contains("mv: cannot stat 'b/': No such file or directory");
}
#[cfg(not(windows))]
#[ignore = "requires access to a different filesystem"]
#[test]
fn test_special_file_different_filesystem() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkfifo("f");
// TODO Use `TestScenario::mount_temp_fs()` for this purpose and
// un-ignore this test.
std::fs::create_dir("/dev/shm/tmp").unwrap();
ucmd.args(&["f", "/dev/shm/tmp"]).succeeds().no_output();
assert!(!at.file_exists("f"));
assert!(Path::new("/dev/shm/tmp/f").exists());
std::fs::remove_dir_all("/dev/shm/tmp").unwrap();
}