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:
+56
-18
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user