base: revert oneshot_async service types, fix local fork deps, migrate remote to RedBear-OS
- Revert initfs/rootfs service types from oneshot_async to blocking Scheme/Notify/Oneshot to fix init ordering races. - Add /scheme/pci retry loop in pcid-spawner. - Bump redox_event to 0.4.8; use local paths for redox-ioctl and redox-rt. - Regenerate Cargo.lock / bootstrap/Cargo.lock with only local forks. - Update submodule origin from redbear-os-base.git to RedBear-OS.git branch submodule/base per single-repo policy.
This commit is contained in:
+10
-10
@@ -26,7 +26,7 @@ impl log::Log for Logger {
|
||||
let line = record.line().unwrap_or(0);
|
||||
let level = record.level();
|
||||
let msg = record.args();
|
||||
let _ = syscall::write(
|
||||
let _ = libredox::call::write(
|
||||
1,
|
||||
alloc::format!("[{file}:{line} {level}] {msg}\n").as_bytes(),
|
||||
);
|
||||
@@ -70,13 +70,13 @@ pub fn main() -> ! {
|
||||
let mut env_bytes = [0_u8; 4096];
|
||||
let mut envs = {
|
||||
let fd = FdGuard::new(
|
||||
syscall::openat(
|
||||
libredox::call::openat(
|
||||
kernel_schemes
|
||||
.get(GlobalSchemes::Sys)
|
||||
.expect("failed to get sys fd")
|
||||
.as_raw_fd(),
|
||||
"env",
|
||||
O_RDONLY | O_CLOEXEC,
|
||||
(O_RDONLY | O_CLOEXEC) as i32,
|
||||
0,
|
||||
)
|
||||
.expect("bootstrap: failed to open env"),
|
||||
@@ -206,7 +206,7 @@ pub fn main() -> ! {
|
||||
|
||||
const CWD: &[u8] = b"/scheme/initfs";
|
||||
let cwd_fd = FdGuard::new(
|
||||
syscall::openat(initns_fd.as_raw_fd(), "/scheme/initfs", O_STAT, 0)
|
||||
libredox::call::openat(initns_fd.as_raw_fd(), "/scheme/initfs", O_STAT as i32, 0)
|
||||
.expect("failed to open cwd fd"),
|
||||
)
|
||||
.to_upper()
|
||||
@@ -225,7 +225,7 @@ pub fn main() -> ! {
|
||||
let path = "/scheme/initfs/bin/init";
|
||||
|
||||
let image_file = FdGuard::new(
|
||||
syscall::openat(extrainfo.ns_fd.unwrap(), path, O_RDONLY | O_CLOEXEC, 0)
|
||||
libredox::call::openat(extrainfo.ns_fd.unwrap(), path, (O_RDONLY | O_CLOEXEC) as i32, 0)
|
||||
.expect("failed to open init"),
|
||||
)
|
||||
.to_upper()
|
||||
@@ -252,10 +252,10 @@ pub fn main() -> ! {
|
||||
// null-terminated. Violating this should therefore give the "format error" ENOEXEC.
|
||||
let interp_cstr = CStr::from_bytes_with_nul(&interp_path).expect("interpreter not valid C str");
|
||||
let interp_file = FdGuard::new(
|
||||
syscall::openat(
|
||||
libredox::call::openat(
|
||||
extrainfo.ns_fd.unwrap(), // initns, not initfs!
|
||||
interp_cstr.to_str().expect("interpreter not UTF-8"),
|
||||
O_RDONLY | O_CLOEXEC,
|
||||
(O_RDONLY | O_CLOEXEC) as i32,
|
||||
0,
|
||||
)
|
||||
.expect("failed to open dynamic linker"),
|
||||
@@ -288,13 +288,13 @@ pub(crate) fn spawn(
|
||||
inner: impl FnOnce(FdGuard, Socket, FdGuard, KernelSchemeMap) -> !,
|
||||
) -> (FdGuard, FdGuard, KernelSchemeMap, FdGuard) {
|
||||
let read = FdGuard::new(
|
||||
syscall::openat(
|
||||
libredox::call::openat(
|
||||
kernel_schemes
|
||||
.get(GlobalSchemes::Pipe)
|
||||
.expect("failed to get pipe fd")
|
||||
.as_raw_fd(),
|
||||
"",
|
||||
O_CLOEXEC,
|
||||
O_CLOEXEC as i32,
|
||||
0,
|
||||
)
|
||||
.expect("failed to open sync read pipe"),
|
||||
@@ -302,7 +302,7 @@ pub(crate) fn spawn(
|
||||
|
||||
// The write pipe will not inherit O_CLOEXEC, but is closed by the daemon later.
|
||||
let write = FdGuard::new(
|
||||
syscall::dup(read.as_raw_fd(), b"write").expect("failed to open sync write pipe"),
|
||||
libredox::call::dup(read.as_raw_fd(), b"write").expect("failed to open sync write pipe"),
|
||||
);
|
||||
|
||||
match fork_impl(&ForkArgs::Init {
|
||||
|
||||
@@ -446,6 +446,22 @@ pub unsafe extern "C" fn redox_write_v1(fd: usize, ptr: *const u8, len: usize) -
|
||||
})) as isize
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn redox_openat_v1(
|
||||
fd: usize,
|
||||
buf: *const u8,
|
||||
path_len: usize,
|
||||
flags: u32,
|
||||
fcntl_flags: u32,
|
||||
) -> isize {
|
||||
let path = unsafe { core::slice::from_raw_parts(buf, path_len) };
|
||||
let path_str = match core::str::from_utf8(path) {
|
||||
Ok(s) => s,
|
||||
Err(_) => return -(syscall::EINVAL as isize),
|
||||
};
|
||||
Error::mux(syscall::openat(fd, path_str, flags as usize, fcntl_flags as usize)) as isize
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe fn redox_dup_v1(fd: usize, buf: *const u8, len: usize) -> isize {
|
||||
Error::mux(syscall::dup(fd, unsafe {
|
||||
@@ -458,6 +474,46 @@ pub extern "C" fn redox_close_v1(fd: usize) -> isize {
|
||||
Error::mux(syscall::close(fd)) as isize
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn redox_fcntl_v0(fd: usize, cmd: usize, arg: usize) -> isize {
|
||||
Error::mux(syscall::fcntl(fd, cmd, arg)) as isize
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn redox_strerror_v1(
|
||||
dst: *mut u8,
|
||||
dst_len: *mut usize,
|
||||
error: u32,
|
||||
) -> isize {
|
||||
let msg = match error {
|
||||
x if x == syscall::EPERM as u32 => "Operation not permitted",
|
||||
x if x == syscall::ENOENT as u32 => "No such file or directory",
|
||||
x if x == syscall::EINTR as u32 => "Interrupted system call",
|
||||
x if x == syscall::EIO as u32 => "I/O error",
|
||||
x if x == syscall::EBADF as u32 => "Bad file descriptor",
|
||||
x if x == syscall::EAGAIN as u32 => "Resource temporarily unavailable",
|
||||
x if x == syscall::ENOMEM as u32 => "Cannot allocate memory",
|
||||
x if x == syscall::EACCES as u32 => "Permission denied",
|
||||
x if x == syscall::EFAULT as u32 => "Bad address",
|
||||
x if x == syscall::EBUSY as u32 => "Device or resource busy",
|
||||
x if x == syscall::EEXIST as u32 => "File exists",
|
||||
x if x == syscall::ENOTDIR as u32 => "Not a directory",
|
||||
x if x == syscall::EISDIR as u32 => "Is a directory",
|
||||
x if x == syscall::EINVAL as u32 => "Invalid argument",
|
||||
x if x == syscall::ENOSYS as u32 => "Function not implemented",
|
||||
x if x == syscall::ENOTEMPTY as u32 => "Directory not empty",
|
||||
_ => "Unknown error",
|
||||
};
|
||||
let msg_bytes = msg.as_bytes();
|
||||
unsafe {
|
||||
let avail = *dst_len;
|
||||
let copy_len = avail.min(msg_bytes.len());
|
||||
core::ptr::copy_nonoverlapping(msg_bytes.as_ptr(), dst, copy_len);
|
||||
*dst_len = copy_len;
|
||||
copy_len as isize
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn redox_sys_call_v0(
|
||||
fd: usize,
|
||||
|
||||
@@ -150,7 +150,7 @@ impl<'sock> NamespaceScheme<'sock> {
|
||||
error!("Permission denied to get scheme creation capability");
|
||||
return Err(Error::new(EACCES));
|
||||
}
|
||||
Ok(syscall::dup(self.scheme_creation_cap.as_raw_fd(), &[])?)
|
||||
Ok(libredox::call::dup(self.scheme_creation_cap.as_raw_fd(), &[])?)
|
||||
}
|
||||
_ => {
|
||||
error!("Unknown special reference: {}", reference);
|
||||
|
||||
@@ -43,7 +43,7 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
|
||||
|
||||
impl Write for Writer {
|
||||
fn write_str(&mut self, s: &str) -> core::fmt::Result {
|
||||
syscall::write(1, s.as_bytes())
|
||||
libredox::call::write(1, s.as_bytes())
|
||||
.map_err(|_| core::fmt::Error)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
@@ -549,7 +549,8 @@ enum WaitpidTarget {
|
||||
struct RawEventQueue(FdGuard);
|
||||
impl RawEventQueue {
|
||||
pub fn new(cap_fd: usize) -> Result<Self> {
|
||||
syscall::openat(cap_fd, "", O_CREAT, 0)
|
||||
libredox::call::openat(cap_fd, "", O_CREAT as i32, 0)
|
||||
.map_err(Into::into)
|
||||
.map(FdGuard::new)
|
||||
.map(Self)
|
||||
}
|
||||
@@ -919,7 +920,7 @@ impl<'a> ProcScheme<'a> {
|
||||
mut op: OpCall,
|
||||
awoken: &mut VecDeque<VirtualId>,
|
||||
) -> Poll<Response> {
|
||||
let id = op.fd;
|
||||
let id = op.fd();
|
||||
let (payload, metadata) = op.payload_and_metadata();
|
||||
match self.handles[id] {
|
||||
Handle::Init => Response::ready_err(EBADF, op),
|
||||
@@ -2542,8 +2543,8 @@ impl<'a> ProcScheme<'a> {
|
||||
|
||||
// Useful for debugging memory leaks.
|
||||
log::trace!("NEXT FD: {}", {
|
||||
let nextfd = syscall::dup(0, &[]).unwrap();
|
||||
let _ = syscall::close(nextfd);
|
||||
let nextfd = libredox::call::dup(0, &[]).unwrap();
|
||||
let _ = libredox::call::close(nextfd);
|
||||
nextfd
|
||||
});
|
||||
log::trace!("{} processes", self.processes.len());
|
||||
|
||||
@@ -48,9 +48,9 @@ pub unsafe extern "C" fn start() -> ! {
|
||||
|
||||
// NOTE: Assuming the debug scheme root fd is always placed at this position
|
||||
let debug_fd = syscall::UPPER_FDTBL_TAG + syscall::data::GlobalSchemes::Debug as usize;
|
||||
let _ = syscall::openat(debug_fd, "", syscall::O_RDONLY, 0); // stdin
|
||||
let _ = syscall::openat(debug_fd, "", syscall::O_WRONLY, 0); // stdout
|
||||
let _ = syscall::openat(debug_fd, "", syscall::O_WRONLY, 0); // stderr
|
||||
let _ = libredox::call::openat(debug_fd, "", syscall::O_RDONLY as i32, 0); // stdin
|
||||
let _ = libredox::call::openat(debug_fd, "", syscall::O_WRONLY as i32, 0); // stdout
|
||||
let _ = libredox::call::openat(debug_fd, "", syscall::O_WRONLY as i32, 0); // stderr
|
||||
|
||||
unsafe {
|
||||
let _ = syscall::mprotect(4096, 4096, MapFlags::PROT_READ | MapFlags::MAP_PRIVATE)
|
||||
|
||||
Reference in New Issue
Block a user