relibc: replace last 2 active unimplemented!() stubs with real implementations

Round 6 follow-up: the prior 'replace all active unimplemented!()'
commit (1442195b) covered aio, time, stdlib, and most POSIX
functions, but left two actively-exported ones still panicking
at runtime.

* getnetbyaddr (src/header/netdb/mod.rs): replaced the
  unimplemented!() panic with a real implementation that walks
  /etc/networks (via setnetent/getnetent, same as getnetbyname)
  and returns the matching entry. Validates the address family
  parameter (AF_INET / AF_INET6 / AF_UNSPEC) and sets ENOENT for
  unknown families or no-match. This unblocks packages that call
  getnetbyaddr() directly (some network utilities and test suites).

* ptrace fallthrough (src/platform/redox/ptrace.rs): replaced
  the catch-all _ => unimplemented!() arm with a real
  io::Error::new(io::ErrorKind::InvalidInput, ...) Err return.
  The function is unreachable for any ptrace request the kernel
  actually supports (PTRACE_CONT / SINGLESTEP / SYSCALL / SYSEMU /
  GETREGS / SETREGS are all handled above); the catch-all only
  fires for unknown requests which should return EINVAL, not panic.

Verification: cargo check --target x86_64-unknown-redox on the
Mesa recipe (which uses relibc headers) still passes. The active
exported hard-stub surface in relibc is now effectively zero on
x86_64.

Per the explore-agent audit (bg_a0ebf329), the original claim
of 33 active x86_64 hard stubs was overcounted: many of the
unimplemented!() calls were in deprecated functions (ecvt, fcvt,
gcvt, setkey, ttyslot) or functions whose #[unsafe(no_mangle)]
attribute was commented out (gethostid, clock_getcpuclockid,
getdate, timer_getoverrun, readdir_r) and therefore NOT exported
as C symbols. The actual exported hard stubs were 2; both are
now real implementations.
This commit is contained in:
Red Bear OS
2026-07-27 00:15:50 +09:00
parent 1442195b84
commit ef52efdeae
2 changed files with 33 additions and 3 deletions
+4 -1
View File
@@ -261,7 +261,10 @@ unsafe fn inner_ptrace(
(&mut &session.regs).write(&redox_regs)?;
Ok(0)
}
_ => unimplemented!(),
_ => Err(io::Error::new(
io::ErrorKind::InvalidInput,
"unsupported ptrace request",
)),
}
}