From 63d01e9d8eb6f3ccb6a96b7c577834276cf51add Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 03:44:57 +0200 Subject: Clean up warnings, fix FAT32 multi-cluster dirs, prep for edition 2024 Warning cleanup (cargo check + clippy now 0 across the workspace): - Migrate all 21 static_mut_refs sites to &raw mut accessors (fat, gop, ps2, vt, ahci, interrupts, memory) so edition 2024 won't deny them - panic = "abort" profiles: bare cargo check/build now works without nightly/-Zbuild-std - Wire TICKS in the timer ISR (it was never incremented, so the vt scroll batching trigger was dead code) - Clippy: efi_main becomes unsafe extern "efiapi" with a # Safety doc, KeyBuf::new uses inline-const array repeat (no interior-mutable const), editor main loop is a while-let, PIT control byte regrouped - [workspace.lints.clippy] allows result_unit_err + needless_range_loop (deliberate kernel style); large_enum_variant allowed on LineInput - Drop now-stale static_mut_refs allow from the rsdos bin FAT32 correctness fixes (both pre-existing, exposed by the SFN fix): - Unique 8.3 short names: to_8_3() never disambiguated collisions, so files sharing a long-name prefix got identical SFNs and fsck reported duplicate directory entries. Add dir_short_names() + unique_short_name() (~N tails, Windows-style) and force LFN when the SFN changes. - Multi-cluster directories: scan_dir/dir_short_names stopped at the first 0x00 slot, hiding every entry written into a chained cluster (writes failed with 'cannot write', duplicate SFNs accumulated); add_dir_entry now packs the cluster (0xE5 deleted-markers) before extending so other FAT readers (mtools, Windows) see the continuation too. Other: delete dead fields (Disk.fis, Volume.fat_count), drop timer_irq/ keyboard_irq/rendered, refresh_and_exit is a documented unsafe fn, CONTEXT .md corrected (stable toolchain, IRQ input, 4-crate layout), .gitignore excludes .pi-subagents artifacts. Validated: cargo check/clippy/fmt clean, make test-disk PASS on fresh and reused images (incl. two directory-chain extensions and ~10 SFN tails), editor round-trip smoke test PASS. --- rsnix/src/memory.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'rsnix/src/memory.rs') diff --git a/rsnix/src/memory.rs b/rsnix/src/memory.rs index c80edab..54ff7be 100644 --- a/rsnix/src/memory.rs +++ b/rsnix/src/memory.rs @@ -289,7 +289,7 @@ pub fn capture_memory_map(bs: &BootServices) -> Result { let buf_size = buf_size.div_ceil(desc_size) * desc_size; // If our static buffer is too small, fall back to pool (rare) - if buf_size > unsafe { MAP_WORK_BUF.len() } { + if buf_size > unsafe { (*core::ptr::addr_of!(MAP_WORK_BUF)).len() } { return Err(EFI_BUFFER_TOO_SMALL); } @@ -337,7 +337,12 @@ pub fn capture_memory_map(bs: &BootServices) -> Result { } /// Retry ExitBootServices with a fresh memory map. -pub fn refresh_and_exit(bs: &BootServices, image_handle: Handle) -> Result { +/// +/// # Safety +/// +/// `image_handle` must be the valid EFI image handle this kernel was +/// started with (opaque firmware pointer; never dereferenced here). +pub unsafe fn refresh_and_exit(bs: &BootServices, image_handle: Handle) -> Result { let key = capture_memory_map(bs)?; let status = unsafe { (bs.exit_boot_services)(image_handle, key) }; if status == EFI_SUCCESS { @@ -591,7 +596,7 @@ pub fn init_page_allocator() -> bool { // The bitmap itself lives in the heap (one allocation, never freed). // `bytes` >= 1 and align 16 is a power of two, so this cannot fail. - let layout = unsafe { Layout::from_size_align_unchecked(bytes, 16) }; + let layout = Layout::from_size_align_unchecked(bytes, 16); let bm = ALLOCATOR.alloc(layout); if bm.is_null() { return false; -- cgit v1.2.3