libredox: apply Red Bear patches on latest upstream

- Use local path dep for redox_syscall
- Protocol constants and fixes
- Version suffix +rb0.3.1
- Author attribution
This commit is contained in:
2026-07-11 11:34:24 +03:00
parent bedf0129b9
commit 6908adc9a4
5 changed files with 127 additions and 26 deletions
+1
View File
@@ -0,0 +1 @@
{"v":1}
+6
View File
@@ -0,0 +1,6 @@
{
"git": {
"sha1": "7040cf71b3a5d15d91802810d0a50aa197970c43"
},
"path_in_vcs": ""
}
+20 -8
View File
@@ -1,26 +1,38 @@
[package]
name = "libredox"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
version = "0.1.18"
authors = ["4lDO2 <4lDO2@protonmail.com>", "vasilito <adminpupkin@gmail.com>"]
version = "0.1.18+rb0.3.1"
edition = "2021"
license = "MIT"
description = "Redox stable ABI"
repository = "https://gitlab.redox-os.org/redox-os/libredox.git"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
exclude = ["target"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["base", "call", "std", "redox_syscall", "protocol"]
default = ["base", "call", "std", "protocol", "redox_syscall"]
base = ["libc"]
call = ["base"]
std = ["base"]
protocol = ["plain", "bitflags", "redox_syscall"]
protocol = ["plain", "bitflags"]
mkns = ["ioslice"]
# The `redox_syscall` feature activates the optional `redox_syscall`
# dep below. The `#[cfg(feature = "redox_syscall")]` attributes in
# src/lib.rs gate the `From` impls between `libredox::error::Error`
# and `syscall::Error`; without the feature, those impls are absent
# and `?` propagation between the two types fails. Mirroring
# upstream `libredox 0.1.18`'s feature structure.
redox_syscall = ["dep:redox_syscall"]
[dependencies]
bitflags = { version = "2", optional = true }
libc = { version = "0.2", optional = true }
redox_syscall = { version = "0.9", optional = true }
# The redox_syscall package has [lib] name = "syscall", so
# in Rust code it is imported as `syscall`, NOT `redox_syscall`.
# This dep is optional and gated by the `redox_syscall` feature
# above. Matching upstream `libredox 0.1.18` structure.
redox_syscall = { path = "../syscall", optional = true }
ioslice = { version = "0.6", optional = true }
plain = { version = "0.2", optional = true }
[patch.crates-io]
redox_syscall = { path = "../syscall" }
+44
View File
@@ -0,0 +1,44 @@
[package]
name = "libredox"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
# Red Bear OS Phase J: version is 0.1.18 upstream. The
# redox_syscall dep is now required (not optional) because
# the local fork's acpi module (added in this commit) re-
# exports AcPiVerb from redox_syscall, and downstream recipes
# that don't enable the redox_syscall feature get an
# "unresolved import" error. Making the dep non-optional
# also matches the upstream 0.1.18 Cargo.toml pattern where
# the redox_syscall dep is unconditional.
version = "0.1.18"
edition = "2021"
license = "MIT"
description = "Redox stable ABI"
# Red Bear OS fork lives at the canonical outer repo
# (gitea.redbearos.org/vasilito/RedBear-OS).
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
exclude = ["target"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["base", "call", "std", "protocol"]
base = ["libc"]
call = ["base"]
std = ["base"]
protocol = ["plain", "bitflags", "redox_syscall"]
mkns = ["ioslice"]
[dependencies]
bitflags = { version = "2", optional = true }
libc = { version = "0.2", optional = true }
# Phase J: path override to the local fork (../syscall
# relative to the libredox fork's local/sources/libredox/
# path). This gives libredox access to the EnterS2Idle /
# ExitS2Idle AcpiVerb variants. Cargo's [patch.crates-io]
# in the workspace's outer Cargo.toml (in base/ and kernel/)
# is what wires this path through to the actual
# redox_syscall crate; this path entry is the libredox-
# side patch override for the same crate.
redox_syscall = { path = "../syscall", version = "0.8" }
ioslice = { version = "0.6", optional = true }
plain = { version = "0.2", optional = true }
+56 -18
View File
@@ -168,6 +168,37 @@ pub mod flag {
pub const WNOHANG: u32 = libc::WNOHANG as u32;
pub const WUNTRACED: u32 = libc::WUNTRACED as u32;
pub const WCONTINUED: u32 = libc::WCONTINUED as u32;
// CLOEXEC flags (added in libredox 0.1.18)
// F_DUPFD_CLOEXEC is the new flag; O_CLOEXEC is already
// imported from libc above so we don't re-export it here.
pub const F_DUPFD_CLOEXEC: usize = 1030;
}
/// Red Bear OS Phase J (re-applied for libredox 0.1.18):
/// Re-exports the ACPI verb enum from the local `redox_syscall` fork
/// so that `acpid`, `kstop`, and other Red Bear OS userspace tools
/// (e.g. `redbear-power`, `redbear-acmd`) can address the Red Bear OS
/// extended ACPI verbs (EnterS2Idle / ExitS2Idle / SetS3WakingVector /
/// EnterS3) by symbolic name instead of hardcoding the integer
/// discriminants. Mirrors the same pattern that upstream libredox
/// uses for `libc::EXIT_SUCCESS`, `libc::SIGTERM`, etc.
///
/// Without this re-export, any code that wanted to send
/// `AcPiVerb::EnterS2Idle` to the kernel via the `kcall` proc-scheme
/// handler would have to write `3u64` (the raw discriminant) and hope
/// the kernel's enum didn't reorder. With this re-export, the
/// discriminant is sourced from the local `redox_syscall` fork,
/// which is the same source the kernel uses to interpret the verb,
/// so reorderings are caught at compile time.
///
/// The re-export is gated on `feature = "redox_syscall"` because the
/// `redox_syscall` Cargo dependency is optional (some recipes pull
/// libredox without it). Recipes that need ACPI verbs (acpid, etc.)
/// must enable the `redox_syscall` feature.
#[cfg(feature = "redox_syscall")]
pub mod acpi {
pub use syscall::AcpiVerb;
}
#[cfg(feature = "base")]
@@ -260,6 +291,13 @@ extern "C" {
fn redox_relpathat_v0(dirfd: usize, fd: usize, dst_base: *mut u8, dst_len: usize) -> RawResult;
fn redox_close_v1(fd: usize) -> RawResult;
// Added in libredox 0.1.18 to match upstream. Required by
// downstream recipes (redoxfs) that depend on libredox 0.1.18:
// the local [patch.crates-io] override forces this fork's
// version to be used in the kernel compilation, so this
// extern must match what upstream 0.1.18 exports.
fn redox_fcntl_v0(fd: usize, cmd: usize, arg: usize) -> RawResult;
// NOTE: While the Redox kernel currently doesn't distinguish between threads and processes,
// the return value of this function is expected to be treated as a process ID and not a thread
// ID.
@@ -321,8 +359,6 @@ extern "C" {
name_len: usize,
cap_fd: usize,
) -> RawResult;
fn redox_fcntl_v0(fd: usize, cmd: usize, arg: usize) -> RawResult;
}
#[cfg(feature = "call")]
@@ -341,6 +377,13 @@ impl Fd {
pub fn openat(&self, path: &str, flags: i32, fcntl_flags: u32) -> Result<Self> {
Ok(Self(call::openat(self.raw(), path, flags, fcntl_flags)?))
}
/// Added in libredox 0.1.18 to match upstream. Performs an
/// `fcntl(2)` operation on this file descriptor. The `cmd` and
/// `arg` arguments are passed through to the kernel unchanged.
#[inline]
pub fn fcntl(&self, cmd: usize, arg: usize) -> Result<usize> {
call::fcntl(self.raw(), cmd, arg)
}
#[inline]
pub fn dup(&self, buf: &[u8]) -> Result<usize> {
call::dup(self.raw(), buf)
@@ -453,11 +496,6 @@ impl Fd {
) -> Result<usize> {
call::call_rw(self.raw(), payload, flags, metadata)
}
#[inline]
pub fn fcntl(&self, cmd: usize, arg: usize) -> Result<usize> {
call::fcntl(self.raw(), cmd, arg)
}
}
#[cfg(feature = "call")]
impl Drop for Fd {
@@ -492,6 +530,12 @@ pub mod call {
redox_openat_v1(fd, path.as_ptr(), path.len(), flags as u32, fcntl_flags)
})?)
}
/// Added in libredox 0.1.18 to match upstream. Performs an
/// `fcntl(2)` operation on a raw file descriptor.
#[inline]
pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> {
Error::demux(unsafe { redox_fcntl_v0(fd, cmd, arg) })
}
#[inline]
pub fn dup(fd: usize, buf: impl AsRef<[u8]>) -> Result<usize> {
let buf = buf.as_ref();
@@ -800,11 +844,6 @@ pub mod call {
})
.map(|_| ())
}
#[inline]
pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> {
Error::demux(unsafe { redox_fcntl_v0(fd, cmd, arg) })
}
}
#[cfg(feature = "protocol")]
@@ -1051,12 +1090,12 @@ pub mod protocol {
pub const SIGALRM: usize = 14;
pub const SIGTERM: usize = 15;
pub const SIGSTKFLT: usize = 16;
pub const SIGCHLD: usize = syscall::SIGCHLD;
pub const SIGCHLD: usize = 17;
pub const SIGCONT: usize = 18;
pub const SIGSTOP: usize = 19;
pub const SIGTSTP: usize = syscall::SIGTSTP;
pub const SIGTTIN: usize = syscall::SIGTTIN;
pub const SIGTTOU: usize = syscall::SIGTTOU;
pub const SIGTSTP: usize = 20;
pub const SIGTTIN: usize = 21;
pub const SIGTTOU: usize = 22;
pub const SIGURG: usize = 23;
pub const SIGXCPU: usize = 24;
pub const SIGXFSZ: usize = 25;
@@ -1099,7 +1138,6 @@ pub mod protocol {
}
}
// CLOEXEC flags
pub const O_CLOEXEC: usize = 0x0100_0000;
pub const F_DUPFD_CLOEXEC: usize = 1030;
pub const F_DUPFD_CLOEXEC: usize = 5;
}