alnyan/yggdrasil: fix start_terminal_session()

This commit is contained in:
2024-01-08 18:41:17 +02:00
parent 9aca77a99d
commit 5c222c6e01
2 changed files with 23 additions and 11 deletions
+15 -11
View File
@@ -1,12 +1,12 @@
#![unstable(feature = "yggdrasil_os", issue = "none")] #![unstable(feature = "yggdrasil_os", issue = "none")]
use yggdrasil_rt::io::{device::DeviceRequest, terminal as rt_terminal}; use yggdrasil_rt::io::{device::DeviceRequest, terminal as rt_terminal, FileMode, OpenOptions};
use yggdrasil_rt::sys as syscall; use yggdrasil_rt::sys as syscall;
use crate::fs::File; use crate::fs::File;
use crate::io; use crate::io;
use crate::mem::MaybeUninit; use crate::mem::MaybeUninit;
use crate::os::fd::{AsRawFd, FromRawFd}; use crate::os::fd::{AsRawFd, FromRawFd, RawFd};
use crate::path::Path; use crate::path::Path;
use crate::sys::cvt_io; use crate::sys::cvt_io;
@@ -55,19 +55,23 @@ pub unsafe fn update_terminal_options<F: AsRawFd, M: Fn(TerminalOptions) -> Term
} }
#[unstable(feature = "yggdrasil_os", issue = "none")] #[unstable(feature = "yggdrasil_os", issue = "none")]
pub unsafe fn start_terminal_session<P: AsRef<Path>>(_terminal: P) -> io::Result<()> { pub unsafe fn start_terminal_session<P: AsRef<Path>>(terminal: P) -> io::Result<()> {
todo!() let terminal = terminal.as_ref().to_str().unwrap();
// let terminal = terminal.as_ref().to_str().unwrap();
// cvt_io(syscall::start_session())?; cvt_io(syscall::start_session())?;
// // TODO implement open flags to explicitly set stdin/stdout/stderr let stdin_fd = cvt_io(syscall::open(None, terminal, OpenOptions::READ, FileMode::empty()))?;
let stdout_stderr_fd =
cvt_io(syscall::open(None, terminal, OpenOptions::WRITE, FileMode::empty()))?;
// cvt_io(syscall::open(None, terminal, OpenOptions::READ, FileMode::empty()))?; cvt_io(syscall::clone_fd(stdin_fd, Some(RawFd::STDIN)))?;
// cvt_io(syscall::open(None, terminal, OpenOptions::WRITE, FileMode::empty()))?; cvt_io(syscall::clone_fd(stdout_stderr_fd, Some(RawFd::STDOUT)))?;
// cvt_io(syscall::open(None, terminal, OpenOptions::WRITE, FileMode::empty()))?; cvt_io(syscall::clone_fd(stdout_stderr_fd, Some(RawFd::STDERR)))?;
// Ok(()) cvt_io(syscall::close(stdin_fd))?;
cvt_io(syscall::close(stdout_stderr_fd))?;
Ok(())
} }
#[unstable(feature = "yggdrasil_os", issue = "none")] #[unstable(feature = "yggdrasil_os", issue = "none")]
+8
View File
@@ -30,3 +30,11 @@ pub mod signal {
unsafe { crate::sys::signal::set_signal_handler(signal, handler) } unsafe { crate::sys::signal::set_signal_handler(signal, handler) }
} }
} }
#[unstable(feature = "yggdrasil_libc", issue = "none")]
pub mod libc_runtime {
#[unstable(feature = "yggdrasil_libc", issue = "none")]
pub unsafe fn start(_arg: usize) -> ! {
loop {}
}
}