Remove all uses of the legacy scheme syntax"
This commit is contained in:
+1
-1
@@ -63,7 +63,7 @@ impl RtTcb {
|
||||
unsafe {
|
||||
if (&*self.thr_fd.get()).is_none() {
|
||||
self.thr_fd.get().write(Some(FdGuard::new(
|
||||
syscall::open("thisproc:current/open_via_dup", O_CLOEXEC).unwrap(),
|
||||
syscall::open("/scheme/thisproc/current/open_via_dup", O_CLOEXEC).unwrap(),
|
||||
)));
|
||||
}
|
||||
(&*self.thr_fd.get()).as_ref().unwrap()
|
||||
|
||||
@@ -733,7 +733,7 @@ pub fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
|
||||
let (cur_filetable_fd, new_pid_fd, new_pid);
|
||||
|
||||
{
|
||||
let cur_pid_fd = FdGuard::new(syscall::open("thisproc:current/open_via_dup", O_CLOEXEC)?);
|
||||
let cur_pid_fd = FdGuard::new(syscall::open("/scheme/thisproc/current/open_via_dup", O_CLOEXEC)?);
|
||||
(new_pid_fd, new_pid) = new_child_process()?;
|
||||
|
||||
copy_str(*cur_pid_fd, *new_pid_fd, "name")?;
|
||||
@@ -861,7 +861,7 @@ pub fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
|
||||
|
||||
pub fn new_child_process() -> Result<(FdGuard, usize)> {
|
||||
// Create a new context (fields such as uid/gid will be inherited from the current context).
|
||||
let fd = FdGuard::new(syscall::open("thisproc:new/open_via_dup", O_CLOEXEC)?);
|
||||
let fd = FdGuard::new(syscall::open("/scheme/thisproc/new/open_via_dup", O_CLOEXEC)?);
|
||||
|
||||
// Extract pid.
|
||||
let mut buffer = [0_u8; 64];
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::{arch::*, proc::*, RtTcb};
|
||||
pub unsafe fn rlct_clone_impl(stack: *mut usize) -> Result<FdGuard> {
|
||||
let cur_thr_fd = RtTcb::current().thread_fd();
|
||||
let new_thr_fd = FdGuard::new(syscall::open(
|
||||
"thisproc:new-thread/open_via_dup",
|
||||
"/scheme/thisproc/new-thread/open_via_dup",
|
||||
O_CLOEXEC,
|
||||
)?);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
|
||||
let master = fcntl::open(c_str!("pty:").as_ptr(), fcntl::O_RDWR, 0);
|
||||
let master = fcntl::open(c_str!("/scheme/pty").as_ptr(), fcntl::O_RDWR, 0);
|
||||
if master < 0 {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ pub unsafe extern "C" fn posix_memalign(
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn posix_openpt(flags: c_int) -> c_int {
|
||||
#[cfg(target_os = "redox")]
|
||||
let r = open((b"pty:\0" as *const u8).cast(), O_CREAT);
|
||||
let r = open((b"/scheme/pty\0" as *const u8).cast(), O_CREAT);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let r = open((b"/dev/ptmx\0" as *const u8).cast(), flags);
|
||||
|
||||
@@ -111,7 +111,7 @@ pub unsafe extern "C" fn madvise(addr: *mut c_void, len: size_t, flags: c_int) -
|
||||
static SHM_PATH: &'static [u8] = b"/dev/shm/";
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
static SHM_PATH: &'static [u8] = b"shm:";
|
||||
static SHM_PATH: &'static [u8] = b"/scheme/shm/";
|
||||
|
||||
unsafe fn shm_path(name: *const c_char) -> CString {
|
||||
let name_c = CStr::from_ptr(name);
|
||||
|
||||
+2
-2
@@ -126,7 +126,7 @@ pub unsafe fn init(sp: &'static Stack) {
|
||||
let mut env = syscall::EnvRegisters::default();
|
||||
|
||||
let file = syscall::open(
|
||||
"thisproc:current/regs/env",
|
||||
"/scheme/thisproc/current/regs/env",
|
||||
syscall::O_CLOEXEC | syscall::O_RDONLY,
|
||||
)
|
||||
.expect_notls("failed to open handle for process registers");
|
||||
@@ -142,7 +142,7 @@ pub unsafe fn init(sp: &'static Stack) {
|
||||
let mut env = syscall::EnvRegisters::default();
|
||||
|
||||
let file = syscall::open(
|
||||
"thisproc:current/regs/env",
|
||||
"/scheme/thisproc/current/regs/env",
|
||||
syscall::O_CLOEXEC | syscall::O_RDONLY,
|
||||
)
|
||||
.expect_notls("failed to open handle for process registers");
|
||||
|
||||
@@ -53,7 +53,7 @@ fn event_flags_to_epoll(flags: syscall::EventFlags) -> c_uint {
|
||||
|
||||
impl PalEpoll for Sys {
|
||||
fn epoll_create1(flags: c_int) -> c_int {
|
||||
Sys::open(c_str!("event:"), O_RDWR | flags, 0)
|
||||
Sys::open(c_str!("/scheme/event"), O_RDWR | flags, 0)
|
||||
}
|
||||
|
||||
fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut epoll_event) -> c_int {
|
||||
@@ -118,7 +118,7 @@ impl PalEpoll for Sys {
|
||||
}
|
||||
|
||||
let timer_opt = if timeout != -1 {
|
||||
match File::open(c_str!("time:4"), O_RDWR) {
|
||||
match File::open(c_str!("/scheme/time/4"), O_RDWR) {
|
||||
Err(_) => return -1,
|
||||
Ok(mut timer) => {
|
||||
if Sys::write(
|
||||
|
||||
@@ -17,7 +17,7 @@ pub unsafe extern "C" fn redox_event_queue_create_v1(flags: u32) -> RawResult {
|
||||
if flags != 0 {
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
Ok(super::libredox::open("event:", O_CLOEXEC | O_CREAT | O_RDWR, 0o700)? as usize)
|
||||
Ok(super::libredox::open("/scheme/event", O_CLOEXEC | O_CREAT | O_RDWR, 0o700)? as usize)
|
||||
})())
|
||||
}
|
||||
#[no_mangle]
|
||||
|
||||
@@ -22,7 +22,7 @@ fn fexec_impl(
|
||||
extrainfo: &ExtraInfo,
|
||||
interp_override: Option<InterpOverride>,
|
||||
) -> Result<usize> {
|
||||
let memory = FdGuard::new(syscall::open("memory:", 0)?);
|
||||
let memory = FdGuard::new(syscall::open("/scheme/memory", 0)?);
|
||||
|
||||
let addrspace_selection_fd = match redox_rt::proc::fexec_impl(
|
||||
exec_file,
|
||||
@@ -252,7 +252,7 @@ pub fn execve(
|
||||
// scenarios. While execve() is undefined according to POSIX if there exist sibling
|
||||
// threads, it could still be allowed by keeping certain file descriptors and instead
|
||||
// set the active file table.
|
||||
let files_fd = File::new(syscall::open("thisproc:current/filetable", O_RDONLY)? as c_int);
|
||||
let files_fd = File::new(syscall::open("/scheme/thisproc/current/filetable", O_RDONLY)? as c_int);
|
||||
for line in BufReader::new(files_fd).lines() {
|
||||
let line = match line {
|
||||
Ok(l) => l,
|
||||
@@ -271,14 +271,14 @@ pub fn execve(
|
||||
}
|
||||
}
|
||||
|
||||
let this_context_fd = FdGuard::new(syscall::open("thisproc:current/open_via_dup", 0)?);
|
||||
let this_context_fd = FdGuard::new(syscall::open("/scheme/thisproc/current/open_via_dup", 0)?);
|
||||
// TODO: Convert image_file to FdGuard earlier?
|
||||
let exec_fd_guard = FdGuard::new(image_file.fd as usize);
|
||||
core::mem::forget(image_file);
|
||||
|
||||
if !is_interpreted && wants_setugid {
|
||||
// We are now going to invoke `escalate:` rather than loading the program ourselves.
|
||||
let escalate_fd = FdGuard::new(syscall::open("escalate:", O_WRONLY)?);
|
||||
let escalate_fd = FdGuard::new(syscall::open("/scheme/escalate", O_WRONLY)?);
|
||||
|
||||
// First, send the context handle of this process to escalated.
|
||||
send_fd_guard(*escalate_fd, this_context_fd)?;
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn pipe2(fds: &mut [c_int], flags: usize) -> syscall::error::Result<()> {
|
||||
let fds =
|
||||
<&mut [c_int; 2]>::try_from(fds).expect("expected Pal pipe2 to have validated pipe2 array");
|
||||
|
||||
let mut read_fd = FdGuard::new(syscall::open("pipe:", flags)?);
|
||||
let mut read_fd = FdGuard::new(syscall::open("/scheme/pipe", flags)?);
|
||||
let mut write_fd = FdGuard::new(syscall::dup(*read_fd, b"write")?);
|
||||
syscall::fcntl(*write_fd, F_SETFL, flags)?;
|
||||
syscall::fcntl(*write_fd, F_SETFD, flags)?;
|
||||
|
||||
@@ -491,9 +491,9 @@ impl Pal for Sys {
|
||||
|
||||
let path = if flags & sys_random::GRND_RANDOM != 0 {
|
||||
//TODO: /dev/random equivalent
|
||||
"rand:"
|
||||
"/scheme/rand"
|
||||
} else {
|
||||
"rand:"
|
||||
"/scheme/rand"
|
||||
};
|
||||
|
||||
let mut open_flags = syscall::O_RDONLY | syscall::O_CLOEXEC;
|
||||
@@ -539,9 +539,9 @@ impl Pal for Sys {
|
||||
fn getsid(pid: pid_t) -> pid_t {
|
||||
let mut buf = [0; mem::size_of::<usize>()];
|
||||
let path = if pid == 0 {
|
||||
format!("thisproc:current/session_id")
|
||||
format!("/scheme/thisproc/current/session_id")
|
||||
} else {
|
||||
format!("proc:{}/session_id", pid)
|
||||
format!("/scheme/proc/{}/session_id", pid)
|
||||
};
|
||||
let path_c = CString::new(path).unwrap();
|
||||
match File::open(CStr::borrow(&path_c), fcntl::O_RDONLY | fcntl::O_CLOEXEC) {
|
||||
@@ -920,7 +920,7 @@ impl Pal for Sys {
|
||||
return -1;
|
||||
}
|
||||
match File::open(
|
||||
c_str!("thisproc:current/session_id"),
|
||||
c_str!("/scheme/thisproc/current/session_id"),
|
||||
fcntl::O_WRONLY | fcntl::O_CLOEXEC,
|
||||
) {
|
||||
Ok(mut file) => match file.write(&usize::to_ne_bytes(session_id.try_into().unwrap())) {
|
||||
@@ -1001,7 +1001,7 @@ impl Pal for Sys {
|
||||
Err(_) => return Err(EIO),
|
||||
}
|
||||
|
||||
let file_path = c_str!("sys:uname");
|
||||
let file_path = c_str!("/scheme/sys/uname");
|
||||
let mut file = match File::open(file_path, fcntl::O_RDONLY | fcntl::O_CLOEXEC) {
|
||||
Ok(ok) => ok,
|
||||
Err(_) => return Err(EIO),
|
||||
|
||||
@@ -57,7 +57,7 @@ pub fn is_traceme(pid: pid_t) -> bool {
|
||||
return false;
|
||||
}
|
||||
File::open(
|
||||
CStr::borrow(&CString::new(format!("chan:ptrace-relibc/{}/traceme", pid)).unwrap()),
|
||||
CStr::borrow(&CString::new(format!("/scheme/chan/ptrace-relibc/{}/traceme", pid)).unwrap()),
|
||||
fcntl::O_PATH,
|
||||
)
|
||||
.is_ok()
|
||||
@@ -74,19 +74,19 @@ pub fn get_session(
|
||||
Ok(entry.insert(Session {
|
||||
first: true,
|
||||
tracer: File::open(
|
||||
CStr::borrow(&CString::new(format!("proc:{}/trace", pid)).unwrap()),
|
||||
CStr::borrow(&CString::new(format!("/scheme/proc/{}/trace", pid)).unwrap()),
|
||||
NEW_FLAGS,
|
||||
)?,
|
||||
mem: File::open(
|
||||
CStr::borrow(&CString::new(format!("proc:{}/mem", pid)).unwrap()),
|
||||
CStr::borrow(&CString::new(format!("/scheme/proc/{}/mem", pid)).unwrap()),
|
||||
NEW_FLAGS,
|
||||
)?,
|
||||
regs: File::open(
|
||||
CStr::borrow(&CString::new(format!("proc:{}/regs/int", pid)).unwrap()),
|
||||
CStr::borrow(&CString::new(format!("/scheme/proc/{}/regs/int", pid)).unwrap()),
|
||||
NEW_FLAGS,
|
||||
)?,
|
||||
fpregs: File::open(
|
||||
CStr::borrow(&CString::new(format!("proc:{}/regs/float", pid)).unwrap()),
|
||||
CStr::borrow(&CString::new(format!("/scheme/proc/{}/regs/float", pid)).unwrap()),
|
||||
NEW_FLAGS,
|
||||
)?,
|
||||
}))
|
||||
@@ -134,7 +134,7 @@ fn inner_ptrace(
|
||||
// Mark this child as traced, parent will check for this marker file
|
||||
let pid = Sys::getpid();
|
||||
mem::forget(File::open(
|
||||
CStr::borrow(&CString::new(format!("chan:ptrace-relibc/{}/traceme", pid)).unwrap()),
|
||||
CStr::borrow(&CString::new(format!("/scheme/chan/ptrace-relibc/{}/traceme", pid)).unwrap()),
|
||||
fcntl::O_CREAT | fcntl::O_PATH | fcntl::O_EXCL,
|
||||
)?);
|
||||
return Ok(0);
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::{
|
||||
impl PalSignal for Sys {
|
||||
unsafe fn getitimer(which: c_int, out: *mut itimerval) -> c_int {
|
||||
let path = match which {
|
||||
ITIMER_REAL => "itimer:1",
|
||||
ITIMER_REAL => "/scheme/itimer/1",
|
||||
_ => {
|
||||
ERRNO.set(EINVAL);
|
||||
return -1;
|
||||
@@ -67,7 +67,7 @@ impl PalSignal for Sys {
|
||||
|
||||
unsafe fn setitimer(which: c_int, new: *const itimerval, old: *mut itimerval) -> c_int {
|
||||
let path = match which {
|
||||
ITIMER_REAL => "itimer:1",
|
||||
ITIMER_REAL => "/scheme/itimer/1",
|
||||
_ => {
|
||||
ERRNO.set(EINVAL);
|
||||
return -1;
|
||||
|
||||
@@ -183,8 +183,12 @@ unsafe fn inner_get_name(
|
||||
|
||||
if buf.starts_with(b"tcp:") || buf.starts_with(b"udp:") {
|
||||
inner_af_inet(local, &buf[4..], address, address_len);
|
||||
} else if buf.starts_with(b"/scheme/tcp/") || buf.starts_with(b"/scheme/udp/") {
|
||||
inner_af_inet(local, &buf[12..], address, address_len);
|
||||
} else if buf.starts_with(b"chan:") {
|
||||
inner_af_unix(&buf[5..], address, address_len);
|
||||
} else if buf.starts_with(b"/scheme/chan/") {
|
||||
inner_af_unix(&buf[13..], address, address_len);
|
||||
} else {
|
||||
// Socket doesn't belong to any scheme
|
||||
panic!(
|
||||
@@ -432,9 +436,9 @@ impl PalSocket for Sys {
|
||||
// The tcp: and udp: schemes allow using no path,
|
||||
// and later specifying one using `dup`.
|
||||
match (domain, kind) {
|
||||
(AF_INET, SOCK_STREAM) => e(syscall::open("tcp:", flags)) as c_int,
|
||||
(AF_INET, SOCK_DGRAM) => e(syscall::open("udp:", flags)) as c_int,
|
||||
(AF_UNIX, SOCK_STREAM) => e(syscall::open("chan:", flags | O_CREAT)) as c_int,
|
||||
(AF_INET, SOCK_STREAM) => e(syscall::open("/scheme/tcp", flags)) as c_int,
|
||||
(AF_INET, SOCK_DGRAM) => e(syscall::open("/scheme/udp", flags)) as c_int,
|
||||
(AF_UNIX, SOCK_STREAM) => e(syscall::open("/scheme/chan", flags | O_CREAT)) as c_int,
|
||||
_ => {
|
||||
ERRNO.set(syscall::EPROTONOSUPPORT);
|
||||
-1
|
||||
@@ -447,7 +451,7 @@ impl PalSocket for Sys {
|
||||
|
||||
match (domain, kind) {
|
||||
(AF_UNIX, SOCK_STREAM) => {
|
||||
let listener = e(syscall::open("chan:", flags | O_CREAT));
|
||||
let listener = e(syscall::open("/scheme/chan", flags | O_CREAT));
|
||||
if listener == !0 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user