MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / add_stdio

Function add_stdio

api/src/file/mod.rs:223–254  ·  view source on GitHub ↗
(fd_table: &mut FlattenObjects<FileDescriptor, AX_FILE_LIMIT>)

Source from the content-addressed store, hash-verified

221}
222
223pub 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}

Callers 1

run_initprocFunction · 0.85

Calls 4

into_fileMethod · 0.80
writeMethod · 0.45
readMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected