Skip to content

Commit 8d46051

Browse files
committed
feat(os::safaos::io): create_vtty and move stuff
1 parent d1c92ee commit 8d46051

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

library/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ dependencies = [
320320
[[package]]
321321
name = "safa-abi"
322322
version = "0.4.0"
323-
source = "git+https://github.com/SafaOS/SafaOS?branch=GUI#72525a91b4b3c13127aff04662c567555920df96"
323+
source = "git+https://github.com/SafaOS/SafaOS?branch=GUI#b4d02bf81d2db05cd4a06c050052f064a2926dda"
324324
dependencies = [
325325
"compiler_builtins",
326326
"rustc-std-workspace-alloc",
@@ -330,7 +330,7 @@ dependencies = [
330330
[[package]]
331331
name = "safa-api"
332332
version = "0.4.3"
333-
source = "git+https://github.com/SafaOS/safa-api#4bfba2718e7cdd79347609486560c48823df3d85"
333+
source = "git+https://github.com/SafaOS/safa-api#5e18738e30dc8231daa504927fe037830a7f767e"
334334
dependencies = [
335335
"compiler_builtins",
336336
"rustc-std-workspace-alloc",

library/std/src/os/safaos/io.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use safa_api::syscalls;
2+
3+
use crate::fs::File;
4+
5+
use super::{AsRawResource, FromRawResource};
6+
7+
#[stable(feature = "rust1", since = "1.0.0")]
8+
pub trait IoUtils {
9+
#[stable(feature = "rust1", since = "1.0.0")]
10+
/// Sends command `command` with argument `arg` to the resource `self`
11+
fn send_command(&self, command: u16, arg: u64) -> crate::io::Result<()>;
12+
}
13+
14+
#[stable(feature = "rust1", since = "1.0.0")]
15+
impl IoUtils for File {
16+
fn send_command(&self, command: u16, arg: u64) -> crate::io::Result<()> {
17+
let ri = self.as_raw_resource();
18+
syscalls::io::io_command(ri, command, arg).map_err(|e| e.into())
19+
}
20+
}
21+
22+
/// Creates a new VTTY pair of (mother, child) file descriptors.
23+
#[stable(feature = "io_create_vtty", since = "1.75.0")]
24+
pub fn create_vtty() -> crate::io::Result<(File, File)> {
25+
let (mother, child) = syscalls::io::vtty_alloc()?;
26+
unsafe { Ok((File::from_raw_resource(mother), File::from_raw_resource(child))) }
27+
}

library/std/src/os/safaos/mod.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![stable(feature = "rust1", since = "1.0.0")]
2+
#[stable(feature = "rust1", since = "1.0.0")]
3+
pub mod io;
4+
25
#[unstable(feature = "rustc_private", issue = "27812")]
36
pub use safa_api as api;
47

@@ -52,18 +55,3 @@ impl FromRawResource for File {
5255
FromInner::from_inner(inner)
5356
}
5457
}
55-
56-
#[stable(feature = "rust1", since = "1.0.0")]
57-
pub trait IoUtils {
58-
#[stable(feature = "rust1", since = "1.0.0")]
59-
/// Sends command `command` with argument `arg` to the resource `self`
60-
fn send_command(&self, command: u16, arg: u64) -> crate::io::Result<()>;
61-
}
62-
63-
#[stable(feature = "rust1", since = "1.0.0")]
64-
impl IoUtils for File {
65-
fn send_command(&self, command: u16, arg: u64) -> crate::io::Result<()> {
66-
let ri = self.as_raw_resource();
67-
syscalls::io::io_command(ri, command, arg).map_err(|e| e.into())
68-
}
69-
}

0 commit comments

Comments
 (0)