diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 16:43:04 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 16:43:04 +0200 |
| commit | 43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2 (patch) | |
| tree | 3fe86cc049f154dc33202b6573e091d6cace7305 /rsnix/src/fs.rs | |
| parent | vfs: everything is a file — dirs, ramfs, character devices (diff) | |
| download | rs-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 'rsnix/src/fs.rs')
| -rw-r--r-- | rsnix/src/fs.rs | 32 |
1 files changed, 22 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 | ||
| 16 | extern crate alloc; | 16 | extern crate alloc; |
| 17 | 17 | ||
| 18 | use alloc::boxed::Box; | ||
| 19 | use alloc::string::String; | ||
| 20 | use alloc::vec::Vec; | ||
| 21 | use crate::gop; | 18 | use crate::gop; |
| 22 | use crate::memory; | 19 | use crate::memory; |
| 23 | use crate::pci; | 20 | use crate::pci; |
| 24 | use crate::rtc; | 21 | use crate::rtc; |
| 25 | use crate::serial; | 22 | use crate::serial; |
| 23 | use alloc::boxed::Box; | ||
| 24 | use alloc::string::String; | ||
| 25 | use 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). |
| 28 | pub const MEM_WINDOW: u64 = 64 * 1024; | 28 | pub 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 | } |
