From 7655b09d334e1bc5c20c55bcc427e1988236855d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 20 May 2025 20:34:59 +0200 Subject: [PATCH 1/2] Add initfs to the main workspace --- Cargo.lock | 177 ++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 3 + bootstrap/Cargo.lock | 1 - bootstrap/Cargo.toml | 2 +- initfs/Cargo.toml | 6 -- 5 files changed, 177 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7cbfc4fb9..7333557cbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,11 +82,33 @@ version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +[[package]] +name = "archive-common" +version = "0.1.0" +dependencies = [ + "anyhow", + "log", + "pathdiff", + "plain", + "redox-initfs", +] + [[package]] name = "arg_parser" version = "0.1.0" source = "git+https://gitlab.redox-os.org/redox-os/arg-parser.git#1c434b55f3e1a0375ebcca85b3e88db7378e82fa" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + [[package]] name = "audiod" version = "0.1.0" @@ -312,6 +334,19 @@ dependencies = [ "quick-error", ] +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -333,6 +368,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + [[package]] name = "hash32" version = "0.3.1" @@ -358,6 +404,21 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" + [[package]] name = "iana-time-zone" version = "0.1.63" @@ -566,6 +627,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "pbr" version = "1.1.1" @@ -583,6 +650,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -662,6 +735,17 @@ dependencies = [ "slab", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -669,7 +753,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", ] [[package]] @@ -678,13 +772,22 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "randd" version = "0.1.0" dependencies = [ "libredox", - "rand_chacha", - "rand_core", + "rand_chacha 0.2.2", + "rand_core 0.5.1", "raw-cpuid", "redox-daemon", "redox-scheme 0.2.4", @@ -711,6 +814,31 @@ dependencies = [ "libredox", ] +[[package]] +name = "redox-initfs" +version = "0.2.0" +dependencies = [ + "anyhow", + "archive-common", + "env_logger", + "log", + "plain", +] + +[[package]] +name = "redox-initfs-tools" +version = "0.2.0" +dependencies = [ + "anyhow", + "archive-common", + "clap", + "env_logger", + "log", + "plain", + "redox-initfs", + "twox-hash", +] + [[package]] name = "redox-log" version = "0.1.4" @@ -894,6 +1022,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.11.1" @@ -911,6 +1045,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "termion" version = "4.0.5" @@ -950,7 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", - "wasi", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi", ] @@ -969,6 +1112,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if 1.0.0", + "rand", + "static_assertions", +] + [[package]] name = "typenum" version = "1.18.0" @@ -1019,6 +1173,12 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -1093,6 +1253,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 0a5450ab2b..f1f021eb99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ resolver = "2" members = [ "audiod", "init", + "initfs", + "initfs/archive-common", + "initfs/tools", "ipcd", "logd", "netstack", diff --git a/bootstrap/Cargo.lock b/bootstrap/Cargo.lock index 7fcc3f58f0..75cb245758 100644 --- a/bootstrap/Cargo.lock +++ b/bootstrap/Cargo.lock @@ -137,7 +137,6 @@ dependencies = [ [[package]] name = "redox-initfs" version = "0.2.0" -source = "git+https://gitlab.redox-os.org/redox-os/redox-initfs.git#d0802237d7894881df7ddd338dfc64220d0646ff" dependencies = [ "plain", ] diff --git a/bootstrap/Cargo.toml b/bootstrap/Cargo.toml index b41643737a..5957b8b7cb 100644 --- a/bootstrap/Cargo.toml +++ b/bootstrap/Cargo.toml @@ -17,7 +17,7 @@ hashbrown = { version = "0.15", default-features = false, features = [ linked_list_allocator = "0.10" log = { version = "0.4", default-features = false } plain = "0.2" -redox-initfs = { git = "https://gitlab.redox-os.org/redox-os/redox-initfs.git", default-features = false } +redox-initfs = { path = "../initfs", default-features = false } redox_syscall = { version = "0.5.4", default-features = false } redox-scheme = { version = "0.6", default-features = false } redox-rt = { git = "https://gitlab.redox-os.org/redox-os/relibc.git", default-features = false } diff --git a/initfs/Cargo.toml b/initfs/Cargo.toml index 3c944a2d54..250ddd3bd2 100644 --- a/initfs/Cargo.toml +++ b/initfs/Cargo.toml @@ -21,9 +21,3 @@ anyhow = "1" archive-common = {path = "archive-common"} env_logger = "0.8" log = "0.4" - -[workspace] -members = [ - "archive-common", - "tools", -] From a31bc0301e1384ad506a15f4f79c2bcba4cc1fc6 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 20 May 2025 21:08:49 +0200 Subject: [PATCH 2/2] Fix a couple of procmgr warnings --- bootstrap/src/procmgr.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/bootstrap/src/procmgr.rs b/bootstrap/src/procmgr.rs index b73c91a5ed..497d9d3c20 100644 --- a/bootstrap/src/procmgr.rs +++ b/bootstrap/src/procmgr.rs @@ -1,14 +1,12 @@ use core::cell::RefCell; use core::cmp; -use core::hash::BuildHasherDefault; use core::mem::size_of; use core::num::{NonZeroU8, NonZeroUsize}; use core::ops::Deref; use core::ptr::NonNull; use core::str::FromStr; use core::sync::atomic::Ordering; -use core::task::Poll::*; -use core::task::{Context, Poll}; +use core::task::Poll::{self, *}; use alloc::collections::btree_map::BTreeMap; use alloc::collections::VecDeque; @@ -35,8 +33,8 @@ use syscall::schemev2::NewFdFlags; use syscall::{ sig_bit, ContextStatus, ContextVerb, CtxtStsBuf, Error, Event, EventFlags, FobtainFdFlags, MapFlags, ProcSchemeAttrs, Result, SenderInfo, SetSighandlerData, SigProcControl, Sigcontrol, - EACCES, EAGAIN, EBADF, EBADFD, ECHILD, EEXIST, EINTR, EINVAL, EIO, ENOENT, ENOSYS, EOPNOTSUPP, - EOWNERDEAD, EPERM, ERESTART, ESRCH, EWOULDBLOCK, O_CLOEXEC, O_CREAT, PAGE_SIZE, + EACCES, EAGAIN, EBADF, EBADFD, ECHILD, EEXIST, EINTR, EINVAL, ENOENT, ENOSYS, EOPNOTSUPP, + EOWNERDEAD, EPERM, ERESTART, ESRCH, EWOULDBLOCK, O_CREAT, PAGE_SIZE, }; #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -1204,7 +1202,7 @@ impl<'a> ProcScheme<'a> { &mut self, pid: ProcessId, status: u16, - mut state: VacantEntry, + state: VacantEntry, awoken: &mut VecDeque, tag: Option, ) -> Poll { @@ -1263,7 +1261,7 @@ impl<'a> ProcScheme<'a> { // terminate all threads (possibly including the caller, resulting in EINTR and a // to-be-ignored cancellation request to this scheme). for thread in &process.threads { - let mut thread = thread.borrow_mut(); + let thread = thread.borrow_mut(); // TODO: cancel all threads anyway on error? if let Err(err) = syscall::write(*thread.status_hndl, &usize::MAX.to_ne_bytes()) { if let Some(tag) = tag { @@ -1321,7 +1319,7 @@ impl<'a> ProcScheme<'a> { None } }; - let mut grim_reaper = + let grim_reaper = |w_pid: ProcessId, status: WaitpidStatus, scheme: &mut ProcScheme| match status { WaitpidStatus::Continued => { if flags.contains(WaitFlags::WCONTINUED) { @@ -1373,7 +1371,7 @@ impl<'a> ProcScheme<'a> { return Ready(Err(Error::new(EINVAL))); } let target_proc_rc = self.processes.get(&pid).ok_or(Error::new(ECHILD))?; - let mut target_proc = target_proc_rc.borrow_mut(); + let target_proc = target_proc_rc.borrow_mut(); if target_proc.ppid != this_pid { return Ready(Err(Error::new(ECHILD))); @@ -1838,7 +1836,7 @@ impl<'a> ProcScheme<'a> { awoken: &mut VecDeque, ) -> Result<()> { log::trace!("KILL(from {caller_pid:?}) TARGET {target:?} {signal} {mode:?}"); - let mut num_succeeded = 0; + let num_succeeded = 0; // if this is set and we would otherwise have succeeded, return EINTR so it can check its // own mask @@ -2011,7 +2009,7 @@ impl<'a> ProcScheme<'a> { // TODO: which threads should become Runnable? for thread_rc in target_proc.threads.iter() { - let mut thread = thread_rc.borrow_mut(); + let thread = thread_rc.borrow_mut(); if let Some(ref tctl) = thread.sig_ctrl { tctl.word[0].fetch_and( !(sig_bit(SIGSTOP) @@ -2337,7 +2335,7 @@ impl<'a> ProcScheme<'a> { u32::from_ne_bytes(bytes) }; log::trace!("SIGDEQ {pid:?} idx {sig_idx}"); - let mut dst = payload + let dst = payload .get_mut(..size_of::()) .ok_or(Error::new(EINVAL))?; if sig_idx >= 32 {