Skip to content

Commit 6d1df56

Browse files
authored
cp: Avoid other error at cp stream /dev/full (#10139)
Co-authored-by: oech3 <>
2 parents 9a6059b + 25c0881 commit 6d1df56

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/uu/cp/src/platform/linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ where
251251
}
252252

253253
let num_bytes_copied = buf_copy::copy_stream(&mut src_file, &mut dst_file)
254-
.map_err(|_| std::io::Error::from(std::io::ErrorKind::Other))?;
254+
.map_err(|e| std::io::Error::other(format!("{e}")))?;
255255

256256
Ok(num_bytes_copied)
257257
}

tests/by-util/test_cp.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ macro_rules! assert_metadata_eq {
8888
}};
8989
}
9090

91+
#[test]
92+
#[cfg(target_os = "linux")]
93+
fn test_cp_stream_to_full() {
94+
let (_, mut ucmd) = at_and_ucmd!();
95+
ucmd.arg("/dev/zero")
96+
.arg("/dev/full")
97+
.fails()
98+
.stderr_contains("No space");
99+
}
100+
91101
#[test]
92102
fn test_cp_cp() {
93103
let (at, mut ucmd) = at_and_ucmd!();

0 commit comments

Comments
 (0)