mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
mv: handle FIFOs inside directories during cross-partition move (#10857)
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
@@ -1141,6 +1141,8 @@ fn copy_file_with_hardlinks_helper(
|
||||
if from.is_symlink() {
|
||||
// Copy a symlink file (no-follow).
|
||||
rename_symlink_fallback(from, to)?;
|
||||
} else if is_fifo(from.symlink_metadata()?.file_type()) {
|
||||
make_fifo(to)?;
|
||||
} else {
|
||||
// Copy a regular file.
|
||||
fs::copy(from, to)?;
|
||||
|
||||
@@ -2444,6 +2444,34 @@ mod inter_partition_copying {
|
||||
"nested content"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn test_mv_dir_with_fifo_across_partitions() {
|
||||
use std::os::unix::fs::FileTypeExt;
|
||||
use tempfile::TempDir;
|
||||
use uutests::util::TestScenario;
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
at.mkdir("dir");
|
||||
at.mkfifo("dir/fifo");
|
||||
|
||||
let other_fs_tempdir =
|
||||
TempDir::new_in("/dev/shm/").expect("Unable to create temp directory in /dev/shm");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("dir")
|
||||
.arg(other_fs_tempdir.path().to_str().unwrap())
|
||||
.succeeds()
|
||||
.no_output();
|
||||
|
||||
assert!(!at.dir_exists("dir"));
|
||||
let moved_fifo = other_fs_tempdir.path().join("dir/fifo");
|
||||
assert!(moved_fifo.symlink_metadata().unwrap().file_type().is_fifo());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user