mikros: Add FileExt trait to allow getting underline PID and FD of a file

This commit is contained in:
pjht 2024-09-20 14:34:39 -05:00
parent 34c61a5d12
commit 202eb774c2
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A
3 changed files with 20 additions and 2 deletions

View 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)
}
}

View File

@ -7,6 +7,7 @@
pub mod ipc;
pub mod loader;
pub mod syscalls;
pub mod fs;
/// A prelude for conveniently writing platform-specific code.
///

View File

@ -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,
}