MCPcopy Create free account
hub / github.com/IntegralPilot/wasm_os / init_dev

Function init_dev

src/inode.rs:160–193  ·  view source on GitHub ↗

Initialize the device file system in /dev

()

Source from the content-addressed store, hash-verified

158
159// Initialize the device file system in /dev
160pub fn init_dev() {
161 let dev = Inode::Directory(Directory {
162 name: String::from("dev"),
163 children: vec![
164 Inode::InputReciever(InputReciever {
165 name: String::from("stdout"),
166 on_input: |data| {
167 for byte in data {
168 print!("{}", String::from_utf8_lossy(&[byte]));
169 }
170 reset_allowed_backspaces();
171 },
172 }),
173 Inode::InputReciever(InputReciever {
174 name: String::from("serial0"),
175 on_input: |data| {
176 crate::serial_print!("{}", String::from_utf8_lossy(&data));
177 },
178 }),
179 Inode::Outputter(Outputter {
180 name: String::from("stdin"),
181 on_output: || {
182 let byte = get_current_byte_in_stdin();
183 vec![byte as u8]
184 },
185 }),
186 ],
187 });
188
189 let mut inode_tree = INODE_TREE.lock();
190 if let Inode::Directory(ref mut directory) = *inode_tree {
191 directory.children.push(dev);
192 }
193}
194
195// Retrieve an inode by path
196pub fn get_inode(path: &str) -> Option<Inode> {

Callers 1

kernel_mainFunction · 0.85

Calls 2

DirectoryClass · 0.85
lockMethod · 0.80

Tested by

no test coverage detected