(fd_table: &mut FlattenObjects<FileDescriptor, AX_FILE_LIMIT>)
| 221 | } |
| 222 | |
| 223 | pub fn add_stdio(fd_table: &mut FlattenObjects<FileDescriptor, AX_FILE_LIMIT>) -> AxResult<()> { |
| 224 | assert_eq!(fd_table.count(), 0); |
| 225 | let cx = FS_CONTEXT.lock(); |
| 226 | let open = |options: &mut OpenOptions| { |
| 227 | AxResult::Ok(Arc::new(File::new( |
| 228 | options.open(&cx, "/dev/console")?.into_file()?, |
| 229 | ))) |
| 230 | }; |
| 231 | |
| 232 | let tty_in = open(OpenOptions::new().read(true).write(false))?; |
| 233 | let tty_out = open(OpenOptions::new().read(false).write(true))?; |
| 234 | fd_table |
| 235 | .add(FileDescriptor { |
| 236 | inner: tty_in, |
| 237 | cloexec: false, |
| 238 | }) |
| 239 | .map_err(|_| AxError::TooManyOpenFiles)?; |
| 240 | fd_table |
| 241 | .add(FileDescriptor { |
| 242 | inner: tty_out.clone(), |
| 243 | cloexec: false, |
| 244 | }) |
| 245 | .map_err(|_| AxError::TooManyOpenFiles)?; |
| 246 | fd_table |
| 247 | .add(FileDescriptor { |
| 248 | inner: tty_out, |
| 249 | cloexec: false, |
| 250 | }) |
| 251 | .map_err(|_| AxError::TooManyOpenFiles)?; |
| 252 | |
| 253 | Ok(()) |
| 254 | } |
no test coverage detected