Commit Graph

35 Commits

Author SHA1 Message Date
vasilito 65889dbd92 libredox: reference syscall::flag::O_CLOEXEC instead of duplicating
O_CLOEXEC was defined in both libredox (0x0100_0000) and syscall
(0x0100_0000). Per the Single Source of Truth principle (and the
Local Fork Supremacy Policy: 'never version-string-duplicate a
Cat 2 fork crate'), a primitive constant should be defined once
in the most-primitive crate that has it (syscall) and re-exported
by higher-level crates (libredox).

Change: libredox::flag::O_CLOEXEC is now
'syscall::flag::O_CLOEXEC' instead of a literal 0x0100_0000. The
F_DUPFD_CLOEXEC constant stays as a literal since syscall does not
define it (it's a Linux-specific fcntl flag that Redox may not need).
2026-07-27 18:17:28 +09:00
vasilito 5bb745ec6f libredox: Fd::ftruncate and Fd::futimens take &self, not self
POSIX ftruncate(2) and futimens(2) do not close the file descriptor.
The previous 'self' (by-value) signature consumed the Fd on call, which
would trigger Fd::drop and close the fd as a side effect. After a
successful ftruncate the user could no longer use the fd, which is
the opposite of the intended semantics.

Change to '&self' to match the surrounding methods (fsync, fdatasync
both already use &self) and to match POSIX behaviour. The drop-on-
failure semantics is preserved by Rust's normal borrow checker: if
ftruncate returns Err, the caller's borrow is still valid and the
fd stays open.
2026-07-27 17:05:08 +09:00
vasilito bfb5f8b2ca libredox: replace demux() .expect() with .unwrap_or(u16::MAX)
CRITICAL F3.1 from NETWORKING-AND-DRIVERS-CODE-ASSESSMENT-2026-07-27.md
§3.4: demux() panicked on edge-case errno via '.expect("2^BITS - res < 4096")'.
Called from every syscall wrapper (~40 call sites). A kernel returning
errno outside the 0..=4095 range would panic the entire process.

Fix: saturate to u16::MAX on overflow rather than panic. The errno
field is u16; values above u16::MAX indicate a kernel ABI violation,
and surfacing u16::MAX is safer than crashing every caller.

Trivial change (one line: .expect -> .unwrap_or(u16::MAX)) with a
comment explaining the saturate-vs-panic tradeoff.
2026-07-27 16:09:41 +09:00
vasilito d787867f8c libredox: add minimal # Safety comments to lib.rs
Adds 45 minimal SAFETY: comments above unsafe blocks in lib.rs:
- demux(): caller guarantees errno fits in u16 (handled with unwrap_or)
- Fd::Drop munmap: caller guarantees fd is still valid at drop time
- SocketCall enum: caller validates discriminator
- from_raw_fd: caller guarantees fd is valid, open, not aliased
- copy_nonoverlapping: caller guarantees non-overlapping regions
- generic catch-all: caller must verify the safety contract

Part of the systematic fix for ZERO # Safety docs across libredox
(NETWORKING-AND-DRIVERS-CODE-ASSESSMENT-2026-07-27.md §3.4,
Finding 9.2).
2026-07-27 15:07:59 +09:00
vasilito 6908adc9a4 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
2026-07-11 11:34:24 +03:00
Ibuki Omatsu 0899f212c0 feat: Add fcntl 2026-07-01 08:01:37 -06:00
Ibuki Omatsu 5cc70f148f feat: Add relpathat 2026-05-27 16:02:55 +02:00
Jeremy Soller eb3b30ed33 Merge branch 'priority-sched' into 'master'
{Get/Set}ProcPriority

See merge request redox-os/libredox!24
2026-04-04 07:40:47 -06:00
Akshit Gaur 33192ebab7 {Get/Set}ProcPriority 2026-03-23 22:50:21 +05:30
Benton60 c7b39521e4 add MSG flags for sockets 2026-03-22 12:13:02 -04:00
Akshit Gaur 1b859147f5 Add Set and Get Priority 2026-03-22 17:51:09 +05:30
Ibuki Omatsu 17f21113a0 feat: Move redox-rt::protocol into libredox::protocol. Add getdents and futimens. 2026-02-27 08:37:26 -07:00
Ibuki Omatsu 6c5a628461 Add Fd::new, setns, getns, and register_scheme_to_ns. 2025-12-27 07:47:25 -07:00
Ibuki Omatsu fd13f1b8dd Add getens. 2025-09-09 07:36:12 -06:00
Wildan M b4c4fb9fd1 Add waitpid flags 2025-08-09 07:31:24 +07:00
Ibuki Omatsu 86444c59a2 fix: Add cfg attribute for the redox_syscall feature to all call functions. 2025-07-30 15:34:25 -06:00
Ibuki Omatsu c8ad74b402 feat: Add call_ro, call_wo and call_wr to call module. 2025-07-28 09:33:13 -06:00
Ibuki Omatsu 144500e2c9 feat: Add call as a new method of Fd. 2025-07-26 16:21:22 +02:00
Ibuki Omatsu c21fcb6847 refactor: Use redox_get_socket_token from relibc 2025-07-19 07:36:33 -06:00
Ibuki Omatsu 690884e0a6 feat: Change get_proc_credentials to use capability fd and add get_socket_token. 2025-07-18 18:27:36 -06:00
Darley Barreto 6e05857046 Add fcntl_flags to openat 2025-07-05 12:55:13 -03:00
Ibuki Omatsu 7bb0cff932 feat: Add get_proc_credentials functions. 2025-06-25 08:48:33 -06:00
Darley Barreto 2a04c02f36 Add openat 2025-04-05 12:35:10 -03:00
4lDO2 fa1739a954 Add mkns API. 2024-03-18 17:08:14 +01:00
4lDO2 0ef1244bd7 Impl From<libredox Error> for syscall Error. 2024-02-23 10:34:48 +01:00
4lDO2 7341724f55 Make the redox_syscall dependency optional. 2024-01-11 15:03:09 +01:00
4lDO2 4de57e2c98 Allow disabling redox_syscall public APIs. 2023-12-26 12:20:13 +01:00
4lDO2 dcb73fea4b Move scheme API to redox-scheme. 2023-12-26 11:21:01 +01:00
4lDO2 8201e827c8 Add fstat, fstatvfs, and futimens. 2023-11-05 13:03:57 +01:00
4lDO2 3a0e50ef3f Implement mmap and munmap 2023-11-04 16:42:12 +01:00
4lDO2 a15ce02753 Compile on non-Redox platforms. 2023-10-12 20:13:05 +02:00
4lDO2 619de8a521 Add more ABI functions and some scheme APIs. 2023-10-12 20:08:07 +02:00
4lDO2 eaf682b6b4 Ensure ABI uses unsigned arguments
This is important because compilers may not correctly sign-extend args
otherwise, if e.g. flags are extended.
2023-10-02 17:08:07 +02:00
4lDO2 9904ebe0c1 Add clock_gettime. 2023-10-02 17:06:25 +02:00
4lDO2 7016837f1f Initial Commit 2023-09-28 16:32:39 +02:00