Initialize the device file system in /dev
()
| 158 | |
| 159 | // Initialize the device file system in /dev |
| 160 | pub 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 |
| 196 | pub fn get_inode(path: &str) -> Option<Inode> { |
no test coverage detected