From a8b059328fc2b86271895ffb58c39e4f6eb13618 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 12 Jun 2026 12:23:03 +0100 Subject: [PATCH] block: Implement FileExt for RawFile Implement std::os::unix::fs::FileExt for RawFile by delegating to the inner File. This enables callers holding a reference to a RawFile to use read_exact_at and write_all_at directly for non-cursor I/O (like pread, etc) without going through custom helper functions. Assisted-by: Claude:Opus-4.6 Signed-off-by: Rob Bradford --- block/src/formats/qcow/internal/raw_file.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/src/formats/qcow/internal/raw_file.rs b/block/src/formats/qcow/internal/raw_file.rs index 1a3be85fe..ed152b8bc 100644 --- a/block/src/formats/qcow/internal/raw_file.rs +++ b/block/src/formats/qcow/internal/raw_file.rs @@ -12,6 +12,7 @@ use std::alloc::{Layout, alloc_zeroed, dealloc}; use std::fs::{File, Metadata}; use std::io::{self, Read, Seek, SeekFrom, Write}; use std::os::fd::{AsFd, BorrowedFd}; +use std::os::unix::fs::FileExt; use std::os::unix::io::{AsRawFd, RawFd}; use std::{result, slice}; @@ -404,3 +405,13 @@ impl AsFd for RawFile { self.file.as_fd() } } + +impl FileExt for RawFile { + fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { + self.file.read_at(buf, offset) + } + + fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { + self.file.write_at(buf, offset) + } +}