From d86bcb24afb52acd60e9cf99d1f967c7356a1d30 Mon Sep 17 00:00:00 2001 From: vasilito Date: Thu, 18 Jun 2026 10:06:12 +0300 Subject: [PATCH] fix(base): add P0-daemon-schemedaemon-option-unwrap.patch The base build was failing with: error[E0277]: expected a `FnOnce(i32)` closure --> daemon/src/lib.rs:67:61 error[E0308]: mismatched types --> daemon/src/lib.rs:119:63 arguments to this function are incorrect because P0-daemon-fix-init-notify-unwrap.patch changed `unsafe fn get_fd(var: &str)` to return `Option` instead of `RawFd`, but the upstream daemon code in SchemeDaemon::new still treated the return value as `RawFd` (not `Option`). This patch updates the SchemeDaemon code to handle the Option: - Change `write_pipe` field to `Option` - Use `.map(io::PipeWriter::from_raw_fd)` in new() - Handle None case in ready_with_fd (return Ok early) This matches the Daemon struct above and the Red Bear base fork at local/sources/base. --- ...P0-daemon-schemedaemon-option-unwrap.patch | 33 +++++++++++++++++++ recipes/core/base/recipe.toml | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 local/patches/base/P0-daemon-schemedaemon-option-unwrap.patch diff --git a/local/patches/base/P0-daemon-schemedaemon-option-unwrap.patch b/local/patches/base/P0-daemon-schemedaemon-option-unwrap.patch new file mode 100644 index 0000000000..6b9a21d9c0 --- /dev/null +++ b/local/patches/base/P0-daemon-schemedaemon-option-unwrap.patch @@ -0,0 +1,33 @@ +diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs +index 9f507221..38752abc 100644 +--- a/daemon/src/lib.rs ++++ b/daemon/src/lib.rs +@@ -83,21 +83,25 @@ impl Daemon { + /// A long running background process that handles requests using schemes. + #[must_use = "SchemeDaemon::ready must be called"] + pub struct SchemeDaemon { +- write_pipe: PipeWriter, ++ write_pipe: Option, + } + + impl SchemeDaemon { + /// Create a new daemon for use with schemes. + pub fn new(f: impl FnOnce(SchemeDaemon) -> !) -> ! { +- let write_pipe = unsafe { io::PipeWriter::from_raw_fd(get_fd("INIT_NOTIFY")) }; ++ let write_pipe = unsafe { get_fd("INIT_NOTIFY").map(io::PipeWriter::from_raw_fd) }; + + f(SchemeDaemon { write_pipe }) + } + + /// Notify the process that the scheme daemon is ready to accept requests. + pub fn ready_with_fd(self, cap_fd: Fd) -> syscall::Result<()> { ++ let write_pipe = match self.write_pipe { ++ Some(pipe) => pipe, ++ None => return Ok(()), ++ }; + syscall::call_wo( +- self.write_pipe.as_raw_fd() as usize, ++ write_pipe.as_raw_fd() as usize, + &cap_fd.into_raw().to_ne_bytes(), + syscall::CallFlags::FD, + &[], diff --git a/recipes/core/base/recipe.toml b/recipes/core/base/recipe.toml index b11adee96f..749252c4c3 100644 --- a/recipes/core/base/recipe.toml +++ b/recipes/core/base/recipe.toml @@ -2,7 +2,7 @@ git = "https://gitlab.redox-os.org/redox-os/base.git" rev = "463f76b9608a896e6f6c9f63457f57f6409873c7" patches = [ - "P0-daemon-fix-init-notify-unwrap.patch", + "P0-daemon-schemedaemon-option-unwrap.patch", "P0-redox-scheme-bump-0.11.1.patch", "P0-workspace-add-bootstrap.patch", "P0-init-continuous-scheduling.patch",