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<RawFd>` instead of `RawFd`,
but the upstream daemon code in SchemeDaemon::new still treated the
return value as `RawFd` (not `Option<RawFd>`).

This patch updates the SchemeDaemon code to handle the Option<RawFd>:
- Change `write_pipe` field to `Option<PipeWriter>`
- 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.
This commit is contained in:
2026-06-18 10:06:12 +03:00
parent f819d0f64a
commit d86bcb24af
2 changed files with 34 additions and 1 deletions
@@ -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<PipeWriter>,
}
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,
&[],
+1 -1
View File
@@ -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",