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. --- rsdos/Cargo.toml | 3 +++ rsdos/src/main.rs | 26 ++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'rsdos') diff --git a/rsdos/Cargo.toml b/rsdos/Cargo.toml index 5bf83fe..d09bd70 100644 --- a/rsdos/Cargo.toml +++ b/rsdos/Cargo.toml @@ -3,6 +3,9 @@ name = "rsdos" version.workspace = true edition.workspace = true +[lints] +workspace = true + [dependencies] rsnix = { path = "../rsnix" } shell = { path = "../shell" } diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index e6b7d2a..2ba5d32 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs @@ -1,6 +1,6 @@ #![no_std] #![no_main] -#![allow(static_mut_refs, unsafe_code)] +#![allow(unsafe_code)] use core::panic::PanicInfo; use rsnix::uefi::*; @@ -31,8 +31,15 @@ fn panic(info: &PanicInfo) -> ! { // --------------------------------------------------------------------------- // EFI entry point // --------------------------------------------------------------------------- +/// EFI entry point. +/// +/// # Safety +/// +/// The firmware hands us raw pointers (image handle, system table) that +/// must remain valid for the lifetime of the call — a contract guaranteed +/// by the UEFI loader. #[no_mangle] -pub extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut SystemTable) -> ! { +pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut SystemTable) -> ! { let st = unsafe { &mut *system_table }; let bs = unsafe { &mut *st.boot_services }; let con_out = unsafe { &mut *st.con_out }; @@ -83,22 +90,13 @@ pub extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut SystemT rsnix::serial_println!("gop: not found (0x{:x})", gop_result); } rsnix::vt::init(); - rsnix::serial_println!( - "vt: terminal ready ({}x{})", - { - let (rows, cols) = rsnix::vt::size(); - rows - }, - { - let (rows, cols) = rsnix::vt::size(); - cols - } - ); + let (rows, cols) = rsnix::vt::size(); + rsnix::serial_println!("vt: terminal ready ({}x{})", rows, cols); // ExitBootServices — we now own the machine if unsafe { (bs.exit_boot_services)(image_handle, map_key) } != EFI_SUCCESS { rsnix::serial_println!("WARN: ExitBootServices failed, retrying..."); - match rsnix::memory::refresh_and_exit(bs, image_handle) { + match unsafe { rsnix::memory::refresh_and_exit(bs, image_handle) } { Ok(_) => {} Err(e) => { rsnix::serial_println!("FATAL: cannot ExitBootServices (0x{:x})", e); -- cgit v1.2.3