mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
fixup! dd: support the [io]flag=nocache option
This commit is contained in:
parent
bd18a2a344
commit
4ff318aee1
2 changed files with 7 additions and 1 deletions
|
@ -793,6 +793,7 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
|
||||||
// TODO Better error handling for overflowing `len`.
|
// TODO Better error handling for overflowing `len`.
|
||||||
if i.settings.iflags.nocache {
|
if i.settings.iflags.nocache {
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
#[allow(clippy::useless_conversion)]
|
||||||
let len = i.src.len()?.try_into().unwrap();
|
let len = i.src.len()?.try_into().unwrap();
|
||||||
i.discard_cache(offset, len);
|
i.discard_cache(offset, len);
|
||||||
}
|
}
|
||||||
|
@ -801,6 +802,7 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
|
||||||
// TODO Better error handling for overflowing `len`.
|
// TODO Better error handling for overflowing `len`.
|
||||||
if i.settings.oflags.nocache {
|
if i.settings.oflags.nocache {
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
#[allow(clippy::useless_conversion)]
|
||||||
let len = o.dst.len()?.try_into().unwrap();
|
let len = o.dst.len()?.try_into().unwrap();
|
||||||
o.discard_cache(offset, len);
|
o.discard_cache(offset, len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1541,11 +1541,15 @@ fn test_multiple_processes_reading_stdin() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn test_nocache_stdin_error() {
|
fn test_nocache_stdin_error() {
|
||||||
|
#[cfg(not(target_env = "musl"))]
|
||||||
|
let detail = "Illegal seek";
|
||||||
|
#[cfg(target_env = "musl")]
|
||||||
|
let detail = "Invalid seek";
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["iflag=nocache", "count=0", "status=noxfer"])
|
.args(&["iflag=nocache", "count=0", "status=noxfer"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("dd: failed to discard cache for: 'standard input': Illegal seek\n0+0 records in\n0+0 records out\n");
|
.stderr_only(format!("dd: failed to discard cache for: 'standard input': {detail}\n0+0 records in\n0+0 records out\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test for discarding system file cache.
|
/// Test for discarding system file cache.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue