Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
28 changes: 28 additions & 0 deletions tests/by-util/test_mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading