From da1b1044937e946a3d382737a1986cede158e822 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 12 Mar 2026 20:25:01 +0100 Subject: [PATCH] block: disk_file: Add Resizable trait Live disk resize support. Single method resize() taking &mut self and the new size in bytes. Implementations may return an error if the backend does not support resizing. Signed-off-by: Anatol Belski --- block/src/disk_file.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block/src/disk_file.rs b/block/src/disk_file.rs index 3b3aa0fec..69a1152c8 100644 --- a/block/src/disk_file.rs +++ b/block/src/disk_file.rs @@ -81,3 +81,12 @@ pub trait SparseCapable: Send + Debug { false } } + +/// Live disk resize support. +/// +/// Implementations may return an error if the backend does not +/// support resizing (e.g. fixed size formats). +pub trait Resizable: Send + Debug { + /// Resizes the disk image to the given size in bytes, if the backend supports it. + fn resize(&mut self, size: u64) -> BlockResult<()>; +}