Commit Graph

5020 Commits

Author SHA1 Message Date
Red Bear OS f46e2a31a7 fix: import upstream relibc fdtbl sync fix 2026-07-14 22:26:47 +09:00
Red Bear OS a0b7e0ab64 fix(spawn): install bootstrap fds in child file table
The copied child table did not reliably retain the thread and process descriptors at the numbers exported through auxv. Explicitly clone both descriptors into the selected child table before loading the image, and remove the ineffective parent-handle leak.
2026-07-14 18:55:06 +09:00
Red Bear OS 7a8c7564ba fix(spawn): leak child thread fd to prevent race with dynamic linker
posix_spawn creates a new context and returns its thread fd to the
parent. The kernel currently does not keep a self-reference to the child
context's thread fd, so when the parent closes its handle, the child's
thread object may be destroyed before the dynamic linker reads
AT_REDOX_THR_FD from auxv and opens regs/env. Leak the parent handle
until the kernel is fixed to retain a reference per context.
2026-07-14 16:37:24 +09:00
Red Bear OS 7dee54808a fix(redox-rt): close O_CLOEXEC fds individually in fexec_impl
The kernel proc scheme returns EBADF for writes to Filetable/NewFiletable
handles, so the bulk FileTableVerb::Close call was silently failing. Close
each O_CLOEXEC fd with SYS_CLOSE instead, which updates both the kernel file
table and the userspace FILETABLE. This unblocks Command::spawn() parents
waiting on the CLOEXEC sync pipe.
2026-07-14 13:57:49 +09:00
Red Bear OS aeabac730b fix(open): use FILETABLE-aware openat_into_posix to keep fd tables in sync 2026-07-14 08:30:50 +09:00
Red Bear OS d2648af84a fix(pipe2): use FILETABLE-aware open/dup to keep kernel/userspace fd tables in sync 2026-07-14 08:01:33 +09:00
Red Bear OS 10023d5715 diag: cast errno to usize 2026-07-13 23:36:23 +03:00
Red Bear OS a11a5a9387 diag: fix format_errno call path 2026-07-13 23:34:39 +03:00
Red Bear OS 0d52729be0 diag: include path and errno in open() diagnostic 2026-07-13 23:33:21 +03:00
Red Bear OS 1c3b19e5f6 diag: fix no_std diagnostic in open() 2026-07-13 23:17:33 +03:00
Red Bear OS e1dc2780b0 diag: add open() diagnostic for scheme-creation-cap and pipe paths 2026-07-13 23:16:08 +03:00
Red Bear OS 381dd8ef20 fix: open() uses single SYS_OPENAT call — eliminates OtherScheme EOPNOTSUPP
The two-step pattern (open full path as scheme root, then open reference
relative to root_fd) failed for namespace-internal paths like
/scheme/namespace/scheme-creation-cap. The namespace scheme resolves the
full path and returns OtherScheme pointing to SchemeList (a kernel scheme
that does not implement kopenat). The second call then hits
SchemeList.kopenat() → EOPNOTSUPP.

The namespace scheme already handles reference resolution internally via
open_scheme_resource(), so a single SYS_OPENAT call with the full path
resolves everything. This also bypasses FILETABLE.insert_upper (which
previously collided with the untracked ns_fd at UPPER index 0).
2026-07-13 22:57:31 +03:00
Red Bear OS a540890851 relibc: fix open() to bypass FILETABLE.insert_upper collision
The open() function used openat_into_upper which calls
FILETABLE.insert_upper() to allocate UPPER fd slots. This can collide
with the namespace fd (ns_fd) that is stored in DYNAMIC_PROC_INFO,
causing the kernel to overwrite the namespace fd entry. All subsequent
open() calls then resolve to the wrong scheme.

Fix: use raw SYS_OPENAT syscalls (which auto-assign POSIX fds) and
register them with register_external_fd, bypassing insert_upper entirely.
2026-07-13 22:42:31 +03:00
Red Bear OS eac112e919 relibc: fix pipe2 to use raw syscalls + register_external_fd
The previous pipe2 implementation used redox_rt::sys::open() which goes
through the FILETABLE's insert_upper mechanism. This can collide with
the untracked namespace fd (ns_fd) stored in DYNAMIC_PROC_INFO, causing
the kernel to overwrite the namespace fd entry with a pipe scheme root
entry. Subsequent open() calls then resolve to the wrong scheme, and
kdup fails with EBADF because it receives a write-end (odd) ID instead
of a read-end (even) ID.

Fix: bypass the open() function entirely and use raw syscall::openat +
syscall::dup, then register both fds with register_external_fd so the
FILETABLE tracks them correctly.
2026-07-13 22:13:02 +03:00
Red Bear OS 9ada7b78bb relibc: remove PIPE_DIAG debug noise, fix F_SETFD arg in pipe2
Remove eprintln debug output from pipe2() FdGuard::open error path.
Fix F_SETFD argument: pass flags & O_CLOEXEC instead of write_flags
(which includes O_WRONLY — not an fd flag).
2026-07-13 21:13:04 +03:00
Red Bear OS aa219c6509 rb: add cbindgen config for bits_eventfd (eventfd_t type)
bits/eventfd.h defines the eventfd_t 64-bit counter type used by
sys/eventfd.h. Without this config, cbindgen skipped the directory
and the type wasn't generated.
2026-07-12 19:35:50 +03:00
Red Bear OS e47a604197 rb: add cbindgen config for sys_timerfd
sys_timerfd was fully implemented in Rust (timerfd_create,
timerfd_settime, timerfd_gettime, itimerspec support) but lacked
the cbindgen.toml needed to generate the <sys/timerfd.h> C header.
Qt6's QSocketNotifier and many other C programs depend on this header.
Without it, cbindgen skips the directory entirely.

This adds the cbindgen config + trailer with all function prototypes,
matching the pattern used by sys_signalfd.
2026-07-12 19:19:35 +03:00
vasilito d8ced461fa Add __fseterr and __freadahead to stdio ext (P3-stdio-fseterr patch) 2026-07-12 16:05:57 +03:00
Red Bear OS bb20fe9c76 Remove FEXEC_STEP diagnostic from proc.rs 2026-07-12 15:17:50 +03:00
Red Bear OS 5049c25a79 diag: print ns_fd in pipe2 on failure 2026-07-12 12:15:24 +03:00
Red Bear OS 5ee906eee3 fix: add MAP_SHARED to map_mut_anywhere flags
validate_kfmap_flags in kernel proc scheme requires exactly one of
MAP_SHARED or MAP_PRIVATE. Without it, shared == private == false,
and the check fails with EINVAL. This was the root cause of the
fexec_impl crash at step 62 (first PT_LOAD segment mapping).
2026-07-12 11:31:34 +03:00
Red Bear OS f643e1b58b fix: register external fds with userspace FILETABLE
redox-scheme Socket and RawEventQueue create fds via libredox raw
syscalls (SYS_DUP, openat) that bypass the redox-rt userspace
FILETABLE. When FdGuard::dup later reserves a POSIX fd slot via
FILETABLE.add_posix, it can reserve a position occupied by the
untracked socket fd. SYS_DUP_INTO then closes the socket and
replaces it, corrupting the procmgr's fd table.

Add register_external_fd() to redox-rt::sys that marks an
existing kernel fd as occupied in the userspace FILETABLE.
Call it from procmgr::run() for the socket fd and event queue
fd.
2026-07-12 11:17:57 +03:00
Red Bear OS 58dfd26452 diag: remove 31 FK: debug prints from redox-rt fork implementation
Removes all syscall::write(1, b'FK:...') debug trace lines from
fork_impl/fork_inner in redox-rt/src/proc.rs that were polluting
serial output during every fork() call.
2026-07-12 05:32:20 +03:00
Red Bear OS 0ce58a8c0d fix: add stdint.h to signal.h sys_includes
Generated signal.h uses uint32_t, int32_t, uint64_t, uintptr_t etc.
without including stdint.h, causing compilation failures in C packages
that include signal.h (diffutils, etc).
2026-07-12 03:19:44 +03:00
Red Bear OS f222c3464b fix: resolve 6 compilation errors from patch absorption
- fcntl/mod.rs: Remove misplaced F_DUPFD_CLOEXEC fallback code from
  inside the flock struct definition (bad patch merge artifact)
- fcntl/mod.rs: Remove unused 'close' import
- signal/mod.rs: Remove duplicate 'mod signalfd' declaration
- pthread/mod.rs: Add Pal+Sys imports for sched_yield() in pthread_yield
- time/mod.rs: Remove duplicate From<&TimeSpec> impl (already in
  bits_timespec/mod.rs)
- pthread/mod.rs: Add FINISHED flag to PthreadFlags and set it on
  thread exit (referenced by pthread_kill in signal/mod.rs)
2026-07-12 02:12:54 +03:00
Red Bear OS fa54b985ff 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.
2026-07-12 01:29:50 +03:00
Red Bear OS d60ba8730d Add granular FK: progress markers throughout fork_inner to pinpoint EOPNOTSUPP 2026-07-11 21:58:08 +03:00
Red Bear OS 64527aae68 debug: add FK:ENTER and FK:INNER markers to trace fork EOPNOTSUPP 2026-07-11 20:14:02 +03:00
Red Bear OS 11195dac6d relibc: fix unsafe block for from_bytes_with_nul_unchecked in eventfd 2026-07-11 18:46:16 +03:00
Red Bear OS 4b9f90c2b9 relibc: fix eventfd EventFlags constants (EVENT_READ/WRITE not FLAG_) 2026-07-11 18:43:54 +03:00
Red Bear OS 1a121303a3 relibc: implement eventfd() using event scheme
Creates sys_eventfd header module providing eventfd(), eventfd_read(),
and eventfd_write(). Uses the kernel event scheme (/scheme/event) on
Redox, returning ENOSYS on Linux. Required for packages like Python
that link against eventfd.
2026-07-11 18:35:03 +03:00
Red Bear OS 353c43ce13 relibc: add missing IPV6_{RECVPKTINFO,PKTINFO,RECVTCLASS,TCLASS} socket option constants 2026-07-11 18:02:43 +03:00
Red Bear OS 2576fe453e redox-rt: add fork debug tracing to identify EOPNOTSUPP source 2026-07-11 17:40:31 +03:00
Red Bear OS af769016b4 relibc: add LDBL_DIG, DECIMAL_DIG, LDBL_MIN/MAX_10_EXP to float.h cbindgen
C11 <float.h> requires these macros. Without them, gnulib-based
packages (diffutils, coreutils, etc.) fail with 'LDBL_DIG undeclared'.
2026-07-11 13:57:03 +03:00
Red Bear OS 48b3490ad6 relibc: fix unsafe block for mutable static access (Rust 2024) 2026-07-11 13:48:02 +03:00
Red Bear OS 03e71cd749 relibc: implement getprogname() in stdlib
BSD extension used by diffutils, coreutils, and other GNU software.
Returns the basename of program_invocation_name.
2026-07-11 13:42:06 +03:00
Red Bear OS 45ecf48235 relibc: regenerate Cargo.lock with [patch.crates-io] properly applied 2026-07-11 12:01:00 +03:00
Red Bear OS 0be7dec907 relibc: start from latest upstream master (cbc14a31) + RB path deps
Upstream precedence: upstream provides eventfd, signalfd, timerfd, POSIX
stubs, cbindgen fixes, Rust 2024 edition, fenv, scheduler, and many more
that RB had previously patched. All RB patches for already-upstreamed
functionality have been dropped per the golden rule.

RB additions on top of upstream:
- Version suffix +rb0.3.1
- Path deps for redox_syscall and libredox (local fork policy)
- [patch.crates-io] for local fork resolution
- Author attribution
2026-07-11 11:45:31 +03:00
Jeremy Soller cbc14a3176 Merge branch 'redoxioctl-lints' into 'master'
tackle clippy lints in redox-ioctl

See merge request redox-os/relibc!1543
2026-07-10 17:33:47 -06:00
auronandace 6f75b90451 remove expect and wrapping 2026-07-10 19:06:40 +01:00
auronandace 433eb0dce7 tackle clippy lints in redox-ioctl 2026-07-10 07:22:32 +01:00
Jeremy Soller d58990030e Fix inverted pointer alignment checks 2026-07-09 13:28:42 -06:00
Jeremy Soller cfc63f23ec Merge branch 'ct-related-docs' into 'master'
add documentation for functions relating to controlling terminal

See merge request redox-os/relibc!1541
2026-07-09 08:48:57 -06:00
Jeremy Soller 36944c4049 Merge branch 'redoxrt-lint-improvements' into 'master'
tackle some clippy lints in redox-rt

See merge request redox-os/relibc!1540
2026-07-09 08:48:46 -06:00
Jeremy Soller dfa26984cf Merge branch 'clippy-check' into 'master'
CI: Add clippy check

See merge request redox-os/relibc!1539
2026-07-09 08:48:24 -06:00
auronandace d5afd3fe81 add documentation for functions relating to controlling terminal 2026-07-09 13:23:16 +01:00
auronandace 8f3ac79670 tackle some clippy lints in redox-rt 2026-07-09 08:35:50 +01:00
Jeremy Soller 88483b96fe Merge branch 'fix-pthread-null' into 'master'
correct definition for PTHREAD_NULL

See merge request redox-os/relibc!1538
2026-07-08 09:21:25 -06:00
auronandace 60d98aebf2 correct definition for PTHREAD_NULL 2026-07-08 14:38:51 +01:00
Jeremy Soller e16f2a4e0d Merge branch 'manual-let-else' into 'master'
apply manual_let_else clippy lint

See merge request redox-os/relibc!1536
2026-07-08 06:01:40 -06:00