From b98a5cc58dcd9951e1333d38a59a82f910158cca Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 12 Mar 2026 20:22:55 +0100 Subject: [PATCH] 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 --- block/src/disk_file.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/block/src/disk_file.rs b/block/src/disk_file.rs index 31c5ee085..9dd52be6d 100644 --- a/block/src/disk_file.rs +++ b/block/src/disk_file.rs @@ -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() + } +}