diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index f7103f78b07..9970c1e426e 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -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)?; diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 761f62b5a05..266c812df59 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -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]