From 71a6f0a790eb3f9a6fccbaf08aa915396a9d6749 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 18 Sep 2019 11:22:07 -0700 Subject: sys_util: add write_zeroes_all() function In the same spirit as write_all() for the standard io::Write::write() function, add a write_zeroes_all() function with a default implementation that calls write_zeroes() in a loop until the requested length is met. This will allow write_zeroes implementations that don't necessarily fulfill the entire requested length. BUG=None TEST=cargo test -p sys_util write_zeroes Change-Id: I0fc3a4b3fe8904946e253ab8a2687555b12657be Signed-off-by: Daniel Verkamp Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1811466 Reviewed-by: Zach Reizner Reviewed-by: Cody Schuffelen Tested-by: kokoro --- devices/src/virtio/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'devices/src/virtio/block.rs') diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs index 5939652..73fd416 100644 --- a/devices/src/virtio/block.rs +++ b/devices/src/virtio/block.rs @@ -673,7 +673,7 @@ impl Block { } else { disk.seek(SeekFrom::Start(offset)) .map_err(|e| ExecuteError::Seek { ioerr: e, sector })?; - disk.write_zeroes(length as usize).map_err(|e| { + disk.write_zeroes_all(length as usize).map_err(|e| { ExecuteError::DiscardWriteZeroes { ioerr: Some(e), sector, -- cgit 1.4.1