From 56aec72e25b1c43bd89334b4744c1cc6162c2ff7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 30 Jun 2026 16:18:03 +0200 Subject: [PATCH] block: qcow: Use physical_size in add_cluster_end add_cluster_end queried the file length by seeking to the end. Use the existing physical_size helper instead, which reads the length from the file metadata. This removes the final cursor access in QcowRawFile, so the Seek and SeekFrom imports are no longer needed. Signed-off-by: Anatol Belski --- block/src/formats/qcow/internal/qcow_raw_file.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/src/formats/qcow/internal/qcow_raw_file.rs b/block/src/formats/qcow/internal/qcow_raw_file.rs index e37c3bf16..22fedf29a 100644 --- a/block/src/formats/qcow/internal/qcow_raw_file.rs +++ b/block/src/formats/qcow/internal/qcow_raw_file.rs @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause use std::fmt::Debug; -use std::io::{self, Read, Seek, SeekFrom, Write}; +use std::io::{self, Read, Write}; use std::os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd}; use std::os::unix::fs::FileExt; @@ -284,7 +284,7 @@ impl QcowRawFile { pub fn add_cluster_end(&mut self, max_valid_cluster_offset: u64) -> io::Result> { // Determine where the new end of the file should be and set_len, which // translates to truncate(2). - let file_end: u64 = self.file.seek(SeekFrom::End(0))?; + let file_end: u64 = self.physical_size()?; let new_cluster_address: u64 = (file_end + self.cluster_size - 1) & !self.cluster_mask; if new_cluster_address > max_valid_cluster_offset {