diff --git a/Cargo.lock b/Cargo.lock index 51218495f4ea6..129f2927a9b80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,9 +83,9 @@ checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9" [[package]] name = "amjad_os_kernel_user_link" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d1291ea9cf6043bfa74865f170b13a220ae79c0d253d1b9ad57e90be137247" +checksum = "17549aafd3a6df6860b12329aff74941c7669483d0adaaf634f5e6aebff0639e" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "amjad_os_user_std" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e98406c58607f4f54f9ec8e5ffbf7570daba78c343ac640b27f094d62fe3f7" +checksum = "d84fa958dc7be5b9c3a3f213869e53dd18bf8f4abee33f4bb620d94070226ba1" dependencies = [ "amjad_os_kernel_user_link", "compiler_builtins", diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 190487b3f13ef..45f8e82fd8227 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -59,7 +59,7 @@ r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std']} [target.'cfg(target_os = "amjad_os")'.dependencies] # This is from `https://github.com/Amjad50/OS`, i.e. it must be run from that context -user_std = { version = "0.2.0", package = "amjad_os_user_std", features = ['rustc-dep-of-std'] } +user_std = { version = "0.2.2", package = "amjad_os_user_std", features = ['rustc-dep-of-std'] } [features] backtrace = [ diff --git a/library/std/src/sys/amjad_os/fd.rs b/library/std/src/sys/amjad_os/fd.rs index eaca62a85cd46..78b5daa7cbc86 100644 --- a/library/std/src/sys/amjad_os/fd.rs +++ b/library/std/src/sys/amjad_os/fd.rs @@ -7,8 +7,8 @@ use crate::{ os::amjad_os::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}, sys_common::{AsInner, FromInner, IntoInner}, }; -// use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -// use crate::sys_common::{AsInner, FromInner, IntoInner}; + +use user_std::io::FileMeta; use super::syscall_to_io_error; @@ -209,8 +209,11 @@ impl FileDesc { }; unsafe { - user_std::io::syscall_blocking_mode(self.as_raw_fd(), blocking_mode) - .map_err(syscall_to_io_error)? + user_std::io::syscall_set_file_meta( + self.as_raw_fd(), + FileMeta::BlockingMode(blocking_mode), + ) + .map_err(syscall_to_io_error)? } Ok(()) diff --git a/library/std/src/sys/amjad_os/io.rs b/library/std/src/sys/amjad_os/io.rs index 6372fca74e0d7..dbfbbeecefd1a 100644 --- a/library/std/src/sys/amjad_os/io.rs +++ b/library/std/src/sys/amjad_os/io.rs @@ -1,5 +1,9 @@ use crate::mem; +use crate::os::amjad_os::io::{AsFd, AsRawFd}; +use crate::sys::amjad_os::syscall_to_io_error; +use user_std::io::FileMeta; + #[derive(Copy, Clone)] pub struct IoSlice<'a>(&'a [u8]); @@ -46,6 +50,16 @@ impl<'a> IoSliceMut<'a> { } } -pub fn is_terminal(_: &T) -> bool { - false +pub fn is_terminal(file: &impl AsFd) -> bool { + let mut meta = FileMeta::IsTerminal(false); + unsafe { + user_std::io::syscall_get_file_meta(file.as_fd().as_raw_fd(), &mut meta) + .map_err(syscall_to_io_error) + .expect("syscall_get_file_meta failed"); + } + + match meta { + FileMeta::IsTerminal(is_terminal) => is_terminal, + _ => unreachable!(), + } }