From 2fa877e087b86c4d03aacbb46b82827ab6b72336 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 12 Mar 2026 20:19:00 +0100 Subject: [PATCH] block: disk_file: Add DiskFd trait Backing file descriptor access for disk images backed by a file. Returns a BorrowedDiskFd that wraps the raw fd with lifetime tracking. Not available for network or memory backed disk formats. Signed-off-by: Anatol Belski --- block/src/disk_file.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/src/disk_file.rs b/block/src/disk_file.rs index 1dbaf1945..31c5ee085 100644 --- a/block/src/disk_file.rs +++ b/block/src/disk_file.rs @@ -36,6 +36,7 @@ use std::fmt::Debug; use crate::BlockResult; +use crate::async_io::BorrowedDiskFd; /// Reported capacity of a disk image. pub trait DiskSize: Send + Debug { @@ -48,3 +49,9 @@ pub trait PhysicalSize: Send + Debug { /// Actual bytes occupied on the host filesystem. fn physical_size(&self) -> BlockResult; } + +/// Backing file descriptor access for disk images backed by a file. +pub trait DiskFd: Send + Debug { + /// Borrows the underlying file descriptor. + fn fd(&self) -> BorrowedDiskFd<'_>; +}