Commit Graph

3345 Commits

Author SHA1 Message Date
Red Bear OS 733da06876 fix(redox): translate POSIX F_DUPFD_CLOEXEC (1030) to Redox syscall ABI (5)
fcntl(F_DUPFD_CLOEXEC) reached redox_rt/kernel with the POSIX/C value 1030
instead of the Redox syscall value (syscall::F_DUPFD_CLOEXEC=5). redox_rt did
not recognize it as a dup, forwarded the raw command to the kernel, and the
kernel's fcntl fell through to its EINVAL catch-all. That made
OwnedFd::try_clone() return EINVAL, which broke tokio Runtime::build() (its I/O
reactor try_clones the epoll fd) for every tokio user on Redox: all the zbus
system daemons (sessiond/polkit/udisks/upower) and the login shell. F_DUPFD and
plain dup worked because they share the same value in both namespaces;
F_DUPFD_CLOEXEC was the sole untranslated command.

Also drop the ineffective epoll_ctl EINVAL/EBADF retry loop: it was based on a
disproven 'transient scheme churn' theory; epoll registrations always succeed
immediately. The real dup failure is fixed above.
2026-07-17 22:59:55 +09:00
Red Bear OS 415fa3c8c2 epoll: retry EPOLL_CTL_ADD/MOD on transient EINVAL/EBADF (Redox)
Registering an fd with /scheme/event can transiently fail with
EINVAL/EBADF while the scheme backing the fd is still starting up or the
fd table is churning during early boot (e.g. a tokio/mio reactor built by
a daemon that races ahead of ipcd's uds_stream scheme). Without recovery,
tokio's Runtime::build aborts the whole runtime with "Invalid argument
(os error 22)", killing every zbus daemon (sessiond, polkit, udisks,
upower) and any tokio program including the login shell.

Retry the /scheme/event registration write with a 5ms backoff, up to ~2s,
on EINVAL/EBADF; a genuinely permanent failure still surfaces after the
bounded window. Redox-only. This is the registration-site counterpart to
the existing park-path recovery in the P0-epoll-redox-recovery tokio patch.
2026-07-17 00:31:27 +09:00
Red Bear OS ab699eaa50 sys_wait: drop unnecessary unsafe around Out::from_mut in waitid 2026-07-16 22:08:17 +09:00
Red Bear OS 3ed376e153 sys_wait: implement waitid (idtype_t/id_t/P_*/CLD_*, siginfo population)
Adapted from the archived local P3-waitid.patch. Fills a POSIX gap needed by
job-control-capable shells (brush/nix). waitid() maps (idtype,id)->waitpid pid,
translates WEXITED/WSTOPPED/WCONTINUED/WNOWAIT options, and populates siginfo_t
(si_pid/si_signo/si_code/si_status) from the wait status.
2026-07-16 21:28:52 +09:00
Red Bear OS a7663b3adf redox: drop now-unused EPERM import after setrlimit rewrite 2026-07-16 06:52:23 +09:00
Red Bear OS 323b95416b redox: implement getrlimit/setrlimit with a per-process limits table (finite RLIMIT_NOFILE) 2026-07-16 06:39:43 +09:00
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 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 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 5049c25a79 diag: print ns_fd in pipe2 on failure 2026-07-12 12:15:24 +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 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 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
auronandace d5afd3fe81 add documentation for functions relating to controlling terminal 2026-07-09 13:23:16 +01: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
auronandace 3af54162cf add description to pthread_once function 2026-07-08 12:17:09 +01:00
auronandace 7840bfcdd1 apply manual_let_else clippy lint 2026-07-08 10:07:15 +01:00
Connor-GH d465f3d34d sys_ioctl: add Redox implementations for tcdrain, tcflow, and tcsendbreak
Strangely enough, the `dup_write` was already done for `tcflush`, but wasn't implemented in ptyd.
2026-07-07 16:51:18 -05:00
Jeremy Soller 3a44b63a9a Merge branch 'termios-oflag-doc' into 'master'
share some more termios constants

See merge request redox-os/relibc!1534
2026-07-07 06:47:11 -06:00
Jeremy Soller 939180a769 Merge branch 'log-ldso' into 'master'
Enable logging for ld_so

See merge request redox-os/relibc!1533
2026-07-07 06:46:04 -06:00
Jeremy Soller ba0ac174df Merge branch 'no-tcb' into 'master'
Handle panic without TCB

See merge request redox-os/relibc!1530
2026-07-07 06:45:42 -06:00
auronandace bcbd9bb69c share some more termios constants 2026-07-07 08:57:07 +01:00
Jeremy Soller 82d444324e Explicitly include features.h in sys/types.h 2026-07-06 17:37:20 -06:00
Jeremy Soller 77f87530c1 Merge branch 'threads-bits' into 'master'
split out pthread types for threads header

See merge request redox-os/relibc!1532
2026-07-06 12:19:20 -06:00
Jeremy Soller 0948df3432 Merge branch 'race-tcb' into 'master'
Fix exit_current_thread racing with pthread_join

See merge request redox-os/relibc!1531
2026-07-06 12:18:58 -06:00
Jeremy Soller c699b37cc0 Merge branch 'ftok-doc' into 'master'
add descriptions to the ftok function and ipc_perm struct members

See merge request redox-os/relibc!1529
2026-07-06 12:18:34 -06:00
auronandace d7859174b7 split out pthread types for threads header 2026-07-06 16:41:09 +01:00
Wildan M 30f50abbfa Enable logging for ld_so 2026-07-06 22:00:53 +07:00
auronandace 5acc81cc97 add descriptions to the ftok function and ipc_perm struct members 2026-07-06 14:46:07 +01:00
auronandace ff37890ea2 add descriptions to termios iflags 2026-07-06 14:06:53 +01:00
Jeremy Soller 52bb3bbfe3 Merge branch 'ptr-offset-by-literal-lint' into 'master'
add ptr_offset_by_literal clippy lint and set to deny

See merge request redox-os/relibc!1527
2026-07-06 06:04:43 -06:00
Jeremy Soller c8d99d6481 Merge branch 'termios-func-doc' into 'master'
document termios functions

See merge request redox-os/relibc!1526
2026-07-06 05:45:24 -06:00
Jeremy Soller 103b040f86 Merge branch 'rename-def-source' into 'master'
Add _GNU_SOURCE to get bits/uio.h

See merge request redox-os/relibc!1524
2026-07-06 05:44:33 -06:00
Jeremy Soller 66dcae87bf Merge branch 'open-log' into 'master'
Parse flags when logging openat

See merge request redox-os/relibc!1523
2026-07-06 05:44:05 -06:00
auronandace bf6dc24407 add ptr_offset_by_literal clippy lint and set to deny 2026-07-06 12:40:43 +01:00
auronandace 3683a14ab4 document termios functions 2026-07-06 11:26:04 +01:00