Files
RedBear-OS/local/recipes/shells/brush/patches/libc-0.2-redox.patch
T
vasilito 9c97cefc57 recipes: adopt brush shell into local/recipes with Redox port patches
Port the brush shell (reubeno/brush) to Redox and adopt the recipe as a
Red Bear local recipe under local/recipes/shells/brush, with the standard
recipes/shells/brush -> ../../local/recipes/shells/brush overlay symlink so
it takes priority over any upstream WIP copy (per local/AGENTS.md "Local
recipe priority vs upstream WIP"). Removes the old recipes/wip/shells/brush.

The dependency tree did not build for Redox: nix 0.31 only partially
cfg-enables Redox and the libc crate's Redox module omits POSIX symbols that
relibc provides. Fixes are reviewable unified diffs under
local/recipes/shells/brush/patches/:

  nix-0.31-redox.patch   cfg-enable resource/Id/waitid/from_siginfo, rlimit
                         import + repr(i32), SaFlags width casts, pty.
  libc-0.2-redox.patch   add idtype_t, P_*/CLD_*, rusage, getrusage/waitid/
                         forkpty externs, siginfo child accessors.
  brush-umask-redox.patch  mode_t is signed on Redox; cast, not u32::from.

The recipe runs `cargo fetch` to materialise registry sources before
patching (they are only unpacked during the build), resolves the right
crate version from Cargo.lock (brush pulls both nix 0.26 and 0.31), and
applies each patch idempotently, failing loudly on version drift. The
binary target is named `brush` (not `brush-shell`), so install it
explicitly. Verified: cooks from a pristine cargo cache using only the
patch files. brush is shipped in redbear-mini as a package for in-image
validation; the login shell stays zsh until brush is runtime-proven.
2026-07-16 23:23:37 +09:00

90 lines
2.8 KiB
Diff

--- a/src/unix/redox/mod.rs
+++ b/src/unix/redox/mod.rs
@@ -1289,6 +1289,12 @@
termp: *const termios,
winp: *const crate::winsize,
) -> c_int;
+ pub fn forkpty(
+ amaster: *mut c_int,
+ name: *mut c_char,
+ termp: *const termios,
+ winp: *const crate::winsize,
+ ) -> c_int;
// pwd.h
pub fn getpwent() -> *mut passwd;
@@ -1385,6 +1391,13 @@
pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
+ pub fn getrusage(resource: c_int, usage: *mut crate::rusage) -> c_int;
+ pub fn waitid(
+ idtype: crate::idtype_t,
+ id: crate::id_t,
+ infop: *mut siginfo_t,
+ options: c_int,
+ ) -> c_int;
// sys/socket.h
pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar;
@@ -1431,3 +1444,59 @@
// utmp.h
pub fn login_tty(fd: c_int) -> c_int;
}
+
+// REDBEAR_REDOX_WAITID: symbols relibc provides but the libc crate omits.
+pub type idtype_t = c_uint;
+
+// waitid idtype_t values.
+pub const P_ALL: idtype_t = 0;
+pub const P_PID: idtype_t = 1;
+pub const P_PGID: idtype_t = 2;
+
+// siginfo_t.si_code values (child status change).
+pub const CLD_EXITED: c_int = 1;
+pub const CLD_KILLED: c_int = 2;
+pub const CLD_DUMPED: c_int = 3;
+pub const CLD_TRAPPED: c_int = 4;
+pub const CLD_STOPPED: c_int = 5;
+pub const CLD_CONTINUED: c_int = 6;
+
+s! {
+ pub struct rusage {
+ pub ru_utime: crate::timeval,
+ pub ru_stime: crate::timeval,
+ pub ru_maxrss: c_long,
+ pub ru_ixrss: c_long,
+ pub ru_idrss: c_long,
+ pub ru_isrss: c_long,
+ pub ru_minflt: c_long,
+ pub ru_majflt: c_long,
+ pub ru_nswap: c_long,
+ pub ru_inblock: c_long,
+ pub ru_oublock: c_long,
+ pub ru_msgsnd: c_long,
+ pub ru_msgrcv: c_long,
+ pub ru_nsignals: c_long,
+ pub ru_nvcsw: c_long,
+ pub ru_nivcsw: c_long,
+ }
+}
+
+impl siginfo_t {
+ // relibc's siginfo layout places these fields after the leading
+ // si_signo/si_errno/si_code triple: si_pid at c_int index 3 (byte 12),
+ // si_uid at index 4 (byte 16), si_status at index 8 (byte 32). Read them
+ // out of the padding region to match.
+ pub unsafe fn si_pid(&self) -> crate::pid_t {
+ let p = self as *const siginfo_t as *const c_int;
+ unsafe { *p.offset(3) }
+ }
+ pub unsafe fn si_uid(&self) -> crate::uid_t {
+ let p = self as *const siginfo_t as *const c_int;
+ unsafe { *p.offset(4) as crate::uid_t }
+ }
+ pub unsafe fn si_status(&self) -> c_int {
+ let p = self as *const siginfo_t as *const c_int;
+ unsafe { *p.offset(8) }
+ }
+}