diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-01 18:25:55 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-01 18:25:55 +0200 |
| commit | 1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5 (patch) | |
| tree | f28246586e387293d0c8beaf6b445210aaab8c48 /rsdos | |
| parent | klog/tty/pager: no more truncated lines — full lines flow, terminal wraps (diff) | |
| download | rs-dos-1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5.tar.gz rs-dos-1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5.zip | |
fix pi-lens warnings: unwraps, shell SC2046, dup code (fmtbuf/scripts/hexdump/cat/ahci/pci)
- memory.rs: self-test Layout::from_size_align no longer panics — the
test fails cleanly on an invalid layout
- fat.rs: v() no longer unwraps the active-volume slot — invariant
violation logs + halts instead of panicking mid-disk-io
- strbuf: shared FmtBuf replaces the duplicated PanicBuf/FmtBuf
(main.rs + sched.rs)
- test-disk.sh: SC2046 — conditional --fresh arg no longer relies on
word splitting
- scripts: boot.sh/boot-image.sh share lib-boot-args.sh (dup args loop)
- shell: cat/hexdump stdin pairs unified with Option<&str> marker;
hexdump format_row folded into format_partial
- ahci: read/write_sectors unified behind dma_sectors
- pci: config_read/write share config_addr
Diffstat (limited to '')
| -rw-r--r-- | rsdos/src/main.rs | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index 7ca031c..700dcc7 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs | |||
| @@ -9,20 +9,9 @@ use rsnix::uefi::*; | |||
| 9 | // Panic handler | 9 | // Panic handler |
| 10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
| 11 | 11 | ||
| 12 | /// Small fmt::Write over a byte slice (no allocation, bounded). | 12 | // --------------------------------------------------------------------------- |
| 13 | struct PanicBuf<'a> { | 13 | // Panic handler |
| 14 | b: &'a mut [u8], | 14 | // --------------------------------------------------------------------------- |
| 15 | n: usize, | ||
| 16 | } | ||
| 17 | |||
| 18 | impl core::fmt::Write for PanicBuf<'_> { | ||
| 19 | fn write_str(&mut self, s: &str) -> core::fmt::Result { | ||
| 20 | let m = s.len().min(self.b.len() - self.n); | ||
| 21 | self.b[self.n..self.n + m].copy_from_slice(&s.as_bytes()[..m]); | ||
| 22 | self.n += m; | ||
| 23 | Ok(()) | ||
| 24 | } | ||
| 25 | } | ||
| 26 | 15 | ||
| 27 | #[panic_handler] | 16 | #[panic_handler] |
| 28 | fn panic(info: &PanicInfo) -> ! { | 17 | fn panic(info: &PanicInfo) -> ! { |
| @@ -35,12 +24,12 @@ fn panic(info: &PanicInfo) -> ! { | |||
| 35 | if rsnix::sched::is_ready() && !rsnix::sched::in_isr() && rsnix::sched::current() >= 2 { | 24 | if rsnix::sched::is_ready() && !rsnix::sched::in_isr() && rsnix::sched::current() >= 2 { |
| 36 | let mut buf = [0u8; 192]; | 25 | let mut buf = [0u8; 192]; |
| 37 | let n = { | 26 | let n = { |
| 38 | let mut w = PanicBuf { b: &mut buf, n: 0 }; | 27 | let mut w = rsnix::strbuf::FmtBuf::new(&mut buf); |
| 39 | let _ = write!(&mut w, "{}", info.message()); | 28 | let _ = write!(&mut w, "{}", info.message()); |
| 40 | if let Some(loc) = info.location() { | 29 | if let Some(loc) = info.location() { |
| 41 | let _ = write!(&mut w, " at {}:{}", loc.file(), loc.line()); | 30 | let _ = write!(&mut w, " at {}:{}", loc.file(), loc.line()); |
| 42 | } | 31 | } |
| 43 | w.n | 32 | w.len() |
| 44 | }; | 33 | }; |
| 45 | let msg = core::str::from_utf8(&buf[..n]).unwrap_or("task panic"); | 34 | let msg = core::str::from_utf8(&buf[..n]).unwrap_or("task panic"); |
| 46 | rsnix::sched::abort_current(msg); | 35 | rsnix::sched::abort_current(msg); |
