Add unstable interface for getting current thread fd.
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
use core::mem::size_of;
|
||||
|
||||
use syscall::{Result, O_CLOEXEC};
|
||||
use syscall::{Error, Result, ESRCH, O_CLOEXEC};
|
||||
|
||||
use crate::{arch::*, proc::*, signal::tmp_disable_signals, RtTcb};
|
||||
use crate::{arch::*, proc::*, signal::tmp_disable_signals, static_proc_info, RtTcb};
|
||||
|
||||
/// Spawns a new context sharing the same address space as the current one (i.e. a new thread).
|
||||
pub unsafe fn rlct_clone_impl(stack: *mut usize) -> Result<FdGuard> {
|
||||
// FIXME
|
||||
let cur_proc_fd = static_proc_info()
|
||||
.proc_fd
|
||||
.as_ref()
|
||||
.ok_or(Error::new(ESRCH))?;
|
||||
|
||||
let cur_thr_fd = RtTcb::current().thread_fd();
|
||||
let new_thr_fd = FdGuard::new(syscall::open(
|
||||
"/scheme/thisproc/new-thread/open_via_dup",
|
||||
O_CLOEXEC,
|
||||
)?);
|
||||
let new_thr_fd = FdGuard::new(syscall::dup(**cur_proc_fd, b"new-thread")?);
|
||||
|
||||
copy_str(**cur_thr_fd, *new_thr_fd, "name")?;
|
||||
|
||||
|
||||
@@ -363,3 +363,9 @@ pub unsafe extern "C" fn redox_mkns_v1(
|
||||
syscall::mkns(core::slice::from_raw_parts(names.cast(), num_names))
|
||||
})())
|
||||
}
|
||||
|
||||
// ABI-UNSTABLE
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn redox_cur_thrfd_v0() -> usize {
|
||||
**redox_rt::RtTcb::current().thread_fd()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user