absorb: 27 orphaned relibc patches re-applied (Phase 1.0A)
Per local/docs/PATCH-PRESERVATION-AUDIT-2026-07-12.md the relibc
fork was carrying only 34 of 90 patches in local/patches/relibc/.
The other 56 patches' content was silently missing from the fork.
This commit re-applies 27 patches that genuinely still apply
cleanly. Recovery covers:
- eventfd implementation (sys/eventfd.h + eventfd.rs)
- signalfd implementation (sys/signalfd.h + signalfd.rs)
- timerfd implementation (sys/timerfd.h + timerfd.rs)
- bits/eventfd.h header
- spawn() function: cbindgen + stdint fix
- P3-timerfd-cbindgen-fix
- cbindgen language=C fixes for sys/{timerfd,semaphore}
- stdint include chain fixes
- strtold implementation
- dns aaaa getaddrinfo ipv6
- various stack/threading/header threading fixes
- dup3 syscalls
- waitid implementation
- bits/timespec reverse_from
- open_memstream integration
24 files changed.
This commit is contained in:
@@ -287,7 +287,20 @@ pub extern "C" fn dup2(fildes: c_int, fildes2: c_int) -> c_int {
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/dup.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn dup3(fildes: c_int, fildes2: c_int, flag: c_int) -> c_int {
|
||||
unimplemented!();
|
||||
// dup3 requires fildes != fildes2 (unlike dup2 which is a no-op in that case)
|
||||
if fildes == fildes2 {
|
||||
ERRNO.set(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
match Sys::dup2(fildes, fildes2) {
|
||||
Ok(newfd) => {
|
||||
if flag & fcntl::O_CLOEXEC != 0 {
|
||||
let _ = Sys::fcntl(newfd, fcntl::F_SETFD, fcntl::FD_CLOEXEC as c_ulonglong);
|
||||
}
|
||||
newfd
|
||||
}
|
||||
Err(Errno(e)) => { ERRNO.set(e); -1 }
|
||||
}
|
||||
}
|
||||
|
||||
// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/encrypt.html>.
|
||||
@@ -560,8 +573,39 @@ pub extern "C" fn getegid() -> gid_t {
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/getentropy.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn getentropy(buffer: *mut c_void, length: size_t) -> c_int {
|
||||
unimplemented!();
|
||||
pub unsafe extern "C" fn getentropy(buffer: *mut c_void, length: size_t) -> c_int {
|
||||
// POSIX limits getentropy to 256 bytes per call
|
||||
const GETENTROPY_MAX: size_t = 256;
|
||||
|
||||
if length > GETENTROPY_MAX {
|
||||
ERRNO.set(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
let path = unsafe { CStr::from_ptr(c"/scheme/rand".as_ptr().cast()) };
|
||||
let fd = match Sys::open(path, fcntl::O_RDONLY, 0) {
|
||||
Ok(fd) => fd,
|
||||
Err(Errno(e)) => {
|
||||
ERRNO.set(e);
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
let buf = unsafe { slice::from_raw_parts_mut(buffer.cast::<u8>(), length) };
|
||||
let mut filled = 0usize;
|
||||
while filled < length {
|
||||
match Sys::read(fd, &mut buf[filled..]) {
|
||||
Ok(0) => break,
|
||||
Ok(n) => filled += n,
|
||||
Err(Errno(e)) => {
|
||||
let _ = Sys::close(fd);
|
||||
ERRNO.set(e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = Sys::close(fd);
|
||||
if filled < length { ERRNO.set(errno::EIO); -1 } else { 0 }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/geteuid.html>.
|
||||
@@ -1321,7 +1365,7 @@ pub extern "C" fn usleep(useconds: useconds_t) -> c_int {
|
||||
#[deprecated]
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn vfork() -> pid_t {
|
||||
unimplemented!();
|
||||
unsafe { fork() }
|
||||
}
|
||||
|
||||
unsafe fn with_argv(
|
||||
|
||||
Reference in New Issue
Block a user