The implementation for confstr is straightforward. Most of the constants
return 1 on both musl and glibc. The only constant that doesn't is
required for Fish.
I also switched an #[unsafe(no_mangle)] from my last patch back
to a #[no_mangle] because we need to bump cbindgen. #[unsafe(no_mangle)]
is required for Rust 2024.
I copied the constants and definitions from musl which we can presume is
correct. Relibc is missing some features which affects our sysconf as
well, such as constants in limits.h or a working resources.h.
Most platforms use a c_int though glibc uses a u32. GNU defines a type,
__rlimit_resource_t, for the RLIMIT enum that is a u32.
Using a c_int is nicer for a few reasons. The first is that our
(unimplemented) functions receive a c_int for the enum - using a u32 is
technically wrong but doesn't affect anything since the constants are
turned into macros by cbindgen.
The second reason is that a c_int is nicer for libc and nix (the crate)
too since we don't need to pollute the crates with guards for Redox.
Fish only requires BSHELL. The constants are implementation specific so
this header will evolve as needed.
Cbindgen doesn't emit defines for strings (even CStrs) so I only
provided what's needed for Fish in a C header for now with the ideal
implementation, in Rust, unbuilt.
%m is a format specifier that prints an error string for errno. The
specifier is technically only for syslog, but musl and glibc implement
it for printf itself. Parsing for a single specifier in a single
function is error prone, especially when syslog itself is variadic.
* Fix PERROR to match musl/glibc better
* More unit tests + enabled on Linux
* Pack priority and facility into one i32 and check the bits with
bitflags
* Add LOG_UPTO (logic is straight from musl)
Not done:
* "%m" - this could just be added to printf
* LOG_CONS
Linux's syslog is a local socket, so this uses the recent UDS work.
* Most of redox.rs is refactored into mod.rs now which has all of the C
facing functions and consts.
* I wrapped the global logger in a Mutex instead of a RwLock. The logger
is almost always locked for writing so a Mutex is simpler as RwLock
provides no benefits.
* I implemented LOG_PERROR which also prints errors to stderr as well as
the log.
* Syslog should be sys/syslog.h with syslog.h as an alias (the
original code only had syslog.h).
feat: Integrate UDS bind and connect operation with RedoxFS and switch get_proc_credentials to a capability-based approach.
See merge request redox-os/relibc!665