From 3bf28631de08f36b2700452bfc99a9bca1dcca84 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 3 Nov 2026 03:45:51 +0100 Subject: [PATCH] leleka-memory: gate guard_archive_extents like guard_archive (unix-only fd/mmap code broke the Windows build); model-format kar_extents test: portable seek+write instead of FileExt Co-Authored-By: Claude Sonnet 5.5 --- crates/leleka-memory/src/governor.rs | 5 ++++- crates/model-format/tests/kar_extents.rs | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/leleka-memory/src/governor.rs b/crates/leleka-memory/src/governor.rs index ed34760b..a92770b8 100644 --- a/crates/leleka-memory/src/governor.rs +++ b/crates/leleka-memory/src/governor.rs @@ -9,7 +9,9 @@ use crate::census::Census; use crate::host::{HostFacts, ProcSource, RealProc}; use crate::inventory::Inventory; use crate::ledger::Ledger; -use crate::lock::{LockDecision, LockMode, LockOutcome, plan_lock, residency_from_smaps}; +use crate::lock::{LockDecision, LockMode, LockOutcome}; +#[cfg(all(target_os = "linux", target_pointer_width = "64"))] +use crate::lock::{plan_lock, residency_from_smaps}; use crate::plan::{GIB, MIB, Plan, Policy, Refusal, gib}; use crate::pressure::{Level, Monitor, Sample, Transition}; use serde::Serialize; @@ -656,6 +658,7 @@ impl Governor { /// `len`-byte descriptor is a hole. Only the extents are locked and healed (locking or populating a hole allocates zero /// pages for it, which would turn the sparse copy back into the full archive), the lock limit is judged against their /// size, and the report says so. `None` is the whole archive. + #[cfg(all(target_os = "linux", target_pointer_width = "64"))] pub fn guard_archive_extents(&self, fd: std::os::fd::BorrowedFd<'_>, len: u64, extents: Option<&[crate::lock::Span]>) -> Result { let started = Instant::now(); let facts = self.probe(); diff --git a/crates/model-format/tests/kar_extents.rs b/crates/model-format/tests/kar_extents.rs index 0c63989d..d5ec9aaf 100644 --- a/crates/model-format/tests/kar_extents.rs +++ b/crates/model-format/tests/kar_extents.rs @@ -3,7 +3,7 @@ //! records); no model bytes. They never qualify a serving capability. use super::*; use std::{ - os::unix::fs::FileExt, + io::{Seek, SeekFrom, Write}, path::PathBuf, sync::atomic::{AtomicU64, Ordering}, }; @@ -230,10 +230,11 @@ impl Drop for Temp { /// A sparse copy of `bytes`: the final length, and only the extents written. fn sparse_copy(tag: &str, bytes: &[u8], extents: &[Extent]) -> Temp { let t = Temp::new(tag); - let f = std::fs::OpenOptions::new().write(true).create_new(true).open(&t.0).unwrap(); + let mut f = std::fs::OpenOptions::new().write(true).create_new(true).open(&t.0).unwrap(); f.set_len(bytes.len() as u64).unwrap(); for e in extents { - f.write_all_at(&bytes[e.offset as usize..e.end() as usize], e.offset).unwrap(); + f.seek(SeekFrom::Start(e.offset)).unwrap(); + f.write_all(&bytes[e.offset as usize..e.end() as usize]).unwrap(); } t }