summaryrefslogtreecommitdiffstats
path: root/rsnix/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 16:43:04 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 16:43:04 +0200
commit43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2 (patch)
tree3fe86cc049f154dc33202b6573e091d6cace7305 /rsnix/src
parentvfs: everything is a file — dirs, ramfs, character devices (diff)
downloadrs-dos-43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2.tar.gz
rs-dos-43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2.zip
shell: ^C cancels the line / aborts streams, ^D = EOF → poweroff
- ps2: Ctrl+C and Ctrl+D are now KeyEvents (ctrl modifier + c/d map); other Ctrl+key combos are swallowed - shell read_line: ^C clears the line and echoes '^C' (bash-style), ^D on an empty line echoes '^D' and shuts down (EOF), ^D with text on the line is ignored - cat/hexdump stream incrementally (was: build whole string then print) and check for ^C between chunks, so a running dump can be aborted - verified in QEMU: line cancel, standalone interrupt, ^C aborts an infinite 'cat /dev/zero' stream, ^D powers off
Diffstat (limited to '')
-rw-r--r--rsnix/src/fs.rs32
-rw-r--r--rsnix/src/ps2.rs11
2 files changed, 33 insertions, 10 deletions
diff --git a/rsnix/src/fs.rs b/rsnix/src/fs.rs
index 56820bb..95a84bf 100644
--- a/rsnix/src/fs.rs
+++ b/rsnix/src/fs.rs
@@ -15,14 +15,14 @@
15 15
16extern crate alloc; 16extern crate alloc;
17 17
18use alloc::boxed::Box;
19use alloc::string::String;
20use alloc::vec::Vec;
21use crate::gop; 18use crate::gop;
22use crate::memory; 19use crate::memory;
23use crate::pci; 20use crate::pci;
24use crate::rtc; 21use crate::rtc;
25use crate::serial; 22use crate::serial;
23use alloc::boxed::Box;
24use alloc::string::String;
25use alloc::vec::Vec;
26 26
27/// /dev/mem covers the low physical-memory window (identity-mapped RAM). 27/// /dev/mem covers the low physical-memory window (identity-mapped RAM).
28pub const MEM_WINDOW: u64 = 64 * 1024; 28pub const MEM_WINDOW: u64 = 64 * 1024;
@@ -96,9 +96,24 @@ pub fn init() -> (usize, usize) {
96 let _tmp = add("tmp", Some(root), FileType::Dir, NodeData::Dir(Vec::new())); 96 let _tmp = add("tmp", Some(root), FileType::Dir, NodeData::Dir(Vec::new()));
97 let etc = add("etc", Some(root), FileType::Dir, NodeData::Dir(Vec::new())); 97 let etc = add("etc", Some(root), FileType::Dir, NodeData::Dir(Vec::new()));
98 98
99 add("mem", Some(dev), FileType::Char, NodeData::Char(CharDevice::Mem)); 99 add(
100 add("rtc", Some(dev), FileType::Char, NodeData::Char(CharDevice::Rtc)); 100 "mem",
101 add("pci", Some(dev), FileType::Char, NodeData::Char(CharDevice::Pci)); 101 Some(dev),
102 FileType::Char,
103 NodeData::Char(CharDevice::Mem),
104 );
105 add(
106 "rtc",
107 Some(dev),
108 FileType::Char,
109 NodeData::Char(CharDevice::Rtc),
110 );
111 add(
112 "pci",
113 Some(dev),
114 FileType::Char,
115 NodeData::Char(CharDevice::Pci),
116 );
102 add( 117 add(
103 "version", 118 "version",
104 Some(dev), 119 Some(dev),
@@ -146,10 +161,7 @@ pub fn init() -> (usize, usize) {
146 ), 161 ),
147 ); 162 );
148 163
149 let dirs = nodes() 164 let dirs = nodes().iter().filter(|n| n.kind == FileType::Dir).count();
150 .iter()
151 .filter(|n| n.kind == FileType::Dir)
152 .count();
153 let files = nodes().len() - dirs; 165 let files = nodes().len() - dirs;
154 (dirs, files) 166 (dirs, files)
155} 167}
diff --git a/rsnix/src/ps2.rs b/rsnix/src/ps2.rs
index 477d146..1b10b3b 100644
--- a/rsnix/src/ps2.rs
+++ b/rsnix/src/ps2.rs
@@ -22,6 +22,8 @@ pub enum KeyEvent {
22 Backspace, 22 Backspace,
23 Tab, 23 Tab,
24 Escape, 24 Escape,
25 CtrlC,
26 CtrlD,
25 ArrowUp, 27 ArrowUp,
26 ArrowDown, 28 ArrowDown,
27 ArrowLeft, 29 ArrowLeft,
@@ -304,6 +306,15 @@ fn process_byte(byte: u8) -> Option<KeyEvent> {
304 ch.to_ascii_uppercase() 306 ch.to_ascii_uppercase()
305 }; 307 };
306 } 308 }
309 // Ctrl+letter — the shell uses ^C (interrupt) and ^D (EOF).
310 let ctrl = state.modifiers & (MOD_LCTRL | MOD_RCTRL) != 0;
311 if ctrl {
312 return match ch.to_ascii_lowercase() {
313 b'c' => Some(KeyEvent::CtrlC),
314 b'd' => Some(KeyEvent::CtrlD),
315 _ => None, // swallow other Ctrl+key combinations
316 };
317 }
307 if ch != 0 { 318 if ch != 0 {
308 Some(KeyEvent::Char(ch as char)) 319 Some(KeyEvent::Char(ch as char))
309 } else { 320 } else {