mikros: Add FileExt trait to allow getting underline PID and FD of a file
This commit is contained in:
parent
34c61a5d12
commit
202eb774c2
17
library/std/src/os/mikros/fs.rs
Normal file
17
library/std/src/os/mikros/fs.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![stable(feature = "mikros", since = "1.80.0")]
|
||||
|
||||
use crate::sys_common::AsInner;
|
||||
|
||||
#[stable(feature = "mikros", since = "1.80.0")]
|
||||
pub trait FileExt {
|
||||
#[stable(feature = "mikros", since = "1.80.0")]
|
||||
fn get_pid_fd(&self) -> (u64, u64);
|
||||
}
|
||||
|
||||
#[stable(feature = "mikros", since = "1.80.0")]
|
||||
impl FileExt for crate::fs::File {
|
||||
fn get_pid_fd(&self) -> (u64, u64) {
|
||||
let file = self.as_inner();
|
||||
(file.fs_pid, file.fd)
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
pub mod ipc;
|
||||
pub mod loader;
|
||||
pub mod syscalls;
|
||||
pub mod fs;
|
||||
|
||||
/// A prelude for conveniently writing platform-specific code.
|
||||
///
|
||||
|
@ -36,8 +36,8 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
}
|
||||
|
||||
pub struct File {
|
||||
fs_pid: u64,
|
||||
fd: u64,
|
||||
pub(crate) fs_pid: u64,
|
||||
pub(crate) fd: u64,
|
||||
pos: AtomicUsize,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user