block: disk_file: Add Geometry trait

Sector and cluster geometry of a disk image. Returns
DiskTopology with a default implementation providing
512B logical and physical block sizes. Formats that
probe the underlying device override this.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-12 20:22:55 +01:00
committed by Rob Bradford
parent 2fa877e087
commit b98a5cc58d

View File

@@ -35,8 +35,8 @@
use std::fmt::Debug;
use crate::BlockResult;
use crate::async_io::BorrowedDiskFd;
use crate::{BlockResult, DiskTopology};
/// Reported capacity of a disk image.
pub trait DiskSize: Send + Debug {
@@ -55,3 +55,13 @@ pub trait DiskFd: Send + Debug {
/// Borrows the underlying file descriptor.
fn fd(&self) -> BorrowedDiskFd<'_>;
}
/// Sector and cluster geometry of a disk image.
///
/// Default returns `DiskTopology::default()` (512B logical/physical).
pub trait Geometry: Send + Debug {
/// Returns the disk topology.
fn topology(&self) -> DiskTopology {
DiskTopology::default()
}
}