diff --git a/redox-rt/src/lib.rs b/redox-rt/src/lib.rs index cb14dd398a38ee0c3cd98bc6bb4b846c02ea558b..9aa0d90b360766655fb5ff32106203c36f87aad1 100644 --- a/redox-rt/src/lib.rs +++ b/redox-rt/src/lib.rs @@ -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() diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index c4aea31fd970256e1cd759df6156cd0bab82aae3..cb84a0688d73b3d480b4d7843cdd76bb07c58fca 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -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]; diff --git a/redox-rt/src/thread.rs b/redox-rt/src/thread.rs index 0a36951176f031d8cf06455bcc624f295d5f00f3..664588ab7768fef65fe73a4d162afc83e5f1e747 100644 --- a/redox-rt/src/thread.rs +++ b/redox-rt/src/thread.rs @@ -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, )?); diff --git a/src/header/pty/redox.rs b/src/header/pty/redox.rs index 22f299fafd98f07248ac896162ceeaaf2e15eedf..160889fdb7d261fb44b36a70a865d81cf14f5ea0 100644 --- a/src/header/pty/redox.rs +++ b/src/header/pty/redox.rs @@ -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(()); } diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index fc65fba06ae780f9e213b6f26acd2cab227cf944..25255a8487e4da24d9e8cc5d80b9eeb309fca587 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -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); diff --git a/src/header/sys_mman/mod.rs b/src/header/sys_mman/mod.rs index 3c91c2ac3ccd76b7a964219d38c17ecb184bb8be..29f639a7a44ce6ea02bf5ff501d31f1d6ae225d3 100644 --- a/src/header/sys_mman/mod.rs +++ b/src/header/sys_mman/mod.rs @@ -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); diff --git a/src/ld_so/mod.rs b/src/ld_so/mod.rs index db559cb886b0998f750e17b051bba5ca510c4dc3..638bdb6e7fd68bb407fce5b42678c76c2cf18058 100644 --- a/src/ld_so/mod.rs +++ b/src/ld_so/mod.rs @@ -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"); diff --git a/src/platform/redox/epoll.rs b/src/platform/redox/epoll.rs index 87fd12801831dc5c6cb9a0edcd2431f619dfbc0b..60eaca05a6b3ef802195035c41a08ef9101f735a 100644 --- a/src/platform/redox/epoll.rs +++ b/src/platform/redox/epoll.rs @@ -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( diff --git a/src/platform/redox/event.rs b/src/platform/redox/event.rs index e685a97e66cdbd9188fa243227916486e58ae94c..8789b2a1deb76c4f513bbc405c950ac5a08c3e82 100644 --- a/src/platform/redox/event.rs +++ b/src/platform/redox/event.rs @@ -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] diff --git a/src/platform/redox/exec.rs b/src/platform/redox/exec.rs index 5dda2e77c167f6d5a868f2a6730ce9c86f09f9fb..81ac0de70f9ec5cfd1547aad0c8d2aa66fb3be4d 100644 --- a/src/platform/redox/exec.rs +++ b/src/platform/redox/exec.rs @@ -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)?; diff --git a/src/platform/redox/extra.rs b/src/platform/redox/extra.rs index 3c96933cddb71c456c94c146fedc7c908123dcdb..235ca09dcf618429656ecf37460efdeb688edf8c 100644 --- a/src/platform/redox/extra.rs +++ b/src/platform/redox/extra.rs @@ -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)?; diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index f27e9d59896f3de542f3fb51179a37e2b59c489d..8916d1702b8e66c424863f65a72c40d9c0e3eeea 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -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), diff --git a/src/platform/redox/ptrace.rs b/src/platform/redox/ptrace.rs index 14ed6d0ba6a07a4b54bff059c7aca892af73c8e7..a5c4f84b8819e2bfff51940dfc7c9a14fe5fcc47 100644 --- a/src/platform/redox/ptrace.rs +++ b/src/platform/redox/ptrace.rs @@ -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); diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index e359c54064a38056c75a05488584e5ee351f2cd3..5910f3e2beb1e0e0b66f689ab2f50ae50a4db97a 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -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; diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index 9c860537cd681518413e0aec1838f9dfb8880f60..54798b4d6cd93e85f9db38d25416724f41623f69 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -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; }