1694: Use singular number for all feature names r=rtzoeller a=asomers
features => feature
users => user
Neither of these features have yet been included in a release, so it's
ok to rename them.
Co-authored-by: Alan Somers <asomers@gmail.com>
1643: Replace the IoVec struct with IoSlice and IoSliceMut from the standard library r=asomers a=notgull
As per discussion in #1637, the `IoVec<&[u8]>` and `IoVec<&mut [u8]>` types have been replaced with `std::io::IoSlice` and `IoSliceMut`, respectively. Notable changes made in this pull request include:
- The complete replacement of `IoVec` with `IoSlice*` types in both public API, private API, and tests.
- Replacing `IoVec` with `IoSlice` in docs.
- Replacing `&[IoVec<&mut [u8]>]` with `&mut [IoSliceMut]`, note that the slice requires a mutable reference now. This is how it's done in the standard library, and there might be a soundness issue in doing it the other way.
Resolves#1637
Co-authored-by: not_a_seagull <notaseagull048@gmail.com>
1692: Add IP_DONTFRAG and IPV6_DONTFRAG SockOpts r=rtzoeller a=junhochoi
IP_DONTFRAG: iOS, macOS
IPV6_DONTFRAG: android, iOS, linux and macOS
Test: `cargo test --test test dontfrag_opts`
Some CI tests running ENOPROTOOPT are disabled.
Co-authored-by: Junho Choi <junho.choi@gmail.com>
IP_DONTFRAG: iOS, macOS
IPV6_DONTFRAG: android, iOS, linux and macOS
Test: `cargo test --test test dontfrag_opts`
Some CI tests running ENOPROTOOPT are disabled (qemu-based).
1690: Enable statfs magic constants for target_os = "android" r=rtzoeller a=flxo
The statfs magic constants of file systems types are available on
target_os android and the cfg guard is updated accordingly.
Sync the list of constant with the constants declared in libc.
Fixes#1689
Co-authored-by: Felix Obenhuber <felix@obenhuber.de>
The statfs magic constants of file systems types are available on
target_os android and the cfg guard is updated accordingly.
Sync the list of constant with the constants declared in libc.
Fixes#1689
The latest redox-syscall crate requires at least Rust 1.59.0, but they
don't define an MSRV policy. And the version given in the
rust-toolchain file in the Redox repository doesn't work. So until they
clarify their MSRV, use nightly.
30f29c3295
1672: Make `uname` always safe r=asomers a=koute
Currently `uname` doesn't check for errors and just blindly assumes that it always succeeds. According to the manpage this function can fail, even though no actual errors are defined:
```
RETURN VALUE
Upon successful completion, a non-negative value shall be returned. Otherwise, -1 shall be returned and errno set to indicate the error.
ERRORS
No errors are defined.
The following sections are informative.
```
Looking at [the glibc's sources](b92a49359f/posix/uname.c (L29)) we can see that it indeed could fail if the internal `gethostname` call fails for some reason.
This code also assumes that every field of `utsname` is going to be initialized by the call to `uname`, which apparently is also not true. Even though the interface doesn't expose this field so it's not a problem in practice (although it might be UB since we do call `assume_init` on the whole struct) [the `utsname` does have a `domainname` field](https://docs.rs/libc/0.2.119/libc/struct.utsname.html) which glibc doesn't initialize.
The code also assumes that every field is a valid UTF-8 string, which is also technically not guaranteed.
The code also assumes that every field will be null terminated, which might not be true if any of the strings are too long (since glibc uses `strncpy` which will *not* null-terminate the string if it ends up running out of space).
This PR should fix all of these problems.
This is a breaking change.
Co-authored-by: Jan Bujak <jan@parity.io>
This fixes several issues with the current `uname` bindings:
- Do not ignore `uname` errors; at least on glibc `uname` can fail,
so now it returns a `Result` instead of assuming that the call
will always succeed.
- Do not assume `uname` will initialize every member of `utsname`;
not every implementation initializes every field, so internally
the struct is now zero-initialized.
- Do not blindly assume strings returned by `uname` will always be valid UTF-8;
`UtsName`'s accessors will now return `&OsStr`s instead of `&str`s.
1685: Deprecate IpAddr, Ipv4Addr, and Ipv6Addr r=rtzoeller a=asomers
Because they're redundant with types in the standard library.
Fixes#1681
Co-authored-by: Alan Somers <asomers@gmail.com>
1684: Replace the Sockaddr enum with a union r=rtzoeller a=asomers
The SockAddr enum is quite large, and the user must allocate space for
the whole thing even though he usually knows what type he needs.
Furthermore, thanks to the sa_family field, the sockaddr types are
basically an enum even in C.
So replace the ungainly enum with a SockaddrLike trait implemented by
all sockaddr types and a SockaddrStorage union that has safe accessors.
Also, deprecate InetAddr, which only existed to support SockAddr.
Supplants #1504Fixes#1544
Co-authored-by: Alan Somers <asomers@gmail.com>
The SockAddr enum is quite large, and the user must allocate space for
the whole thing even though he usually knows what type he needs.
Furthermore, thanks to the sa_family field, the sockaddr types are
basically an enum even in C.
So replace the ungainly enum with a SockaddrLike trait implemented by
all sockaddr types and a SockaddrStorage union that has safe accessors.
Also, deprecate InetAddr, which only existed to support SockAddr.
Supplants #1504Fixes#1544
1683: Fix build for Redox and uclibc r=asomers a=rtzoeller
- Redox renamed `sigaction.sa_handler` to `.sa_sigaction`, which lets us drop some specialized code for the platform.
- uclibc now uses a `u32` for the `RLIMIT` definitions, like Linux GNU.
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
1677: Use the same signature for LinkAddr::addr on all platforms r=rtzoeller a=asomers
This should've been done as part of #1675
Co-authored-by: Alan Somers <asomers@gmail.com>
1675: Fix a panic in Linkaddr::addr r=rtzoeller a=asomers
The function assumed something about the values of the sockaddr_dl's
fields. But because the inner type is public, we musn't do that. The
only solution is to change the function's signature to return an Option.
1676: Fix the build on DragonflyBSD with -Zminimal-versions r=asomers a=asomers
Co-authored-by: Alan Somers <asomers@gmail.com>
The function assumed something about the values of the sockaddr_dl's
fields. But because the inner type is public, we musn't do that. The
only solution is to change the function's signature to return an Option.
1671: docs: fix link in doc for cmsg_space in sys/socket r=rtzoeller a=liubin
Link to cmsg_space macro for recvmmsg and recvmsg should
be the doc's root of crate as macro is an exported macro.
Signed-off-by: bin liu <liubin0329@gmail.com>
Co-authored-by: bin liu <liubin0329@gmail.com>
1584: wait: implement waitid() r=rtzoeller a=NeoRaider
waitid() has a number of additional features that waitpid() is missing:
- WNOWAIT is only accepted for waitid() on Linux (and possibly other platforms)
- Support for waiting on PID file descriptors on Linux
For now support is added for all platforms with waitid() that have proper siginfo_t support in libc. NetBSD support is currently a work in progress [1].
Tests for the signal/exit code are currently skipped on MIPS platforms due to multiple bugs in qemu-user in the translation of siginfo_t (one fixed in January [2], one currently under review [3]).
[1] rust-lang/libc#2476
[2] https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg04810.html
[3] https://lists.nongnu.org/archive/html/qemu-devel/2021-10/msg05433.html
Co-authored-by: Matthias Schiffer <mschiffer@universe-factory.net>
waitid() has a number of additional features that waitpid() is missing:
- WNOWAIT is only accepted for waitid() on Linux (and possibly other
platforms)
- Support for waiting on PID file descriptors on Linux
For now support is added for all platforms with waitid() that have proper
siginfo_t support in libc. NetBSD support is currently a work in progress
[1].
Tests for the signal/exit code are currently skipped on MIPS platforms due
to bugs in qemu-user's translation of siginfo_t (fixed in [2] and [3]; the
second fix is not in a released qemu version yet).
[1] https://github.com/rust-lang/libc/pull/2476
[2] https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg04810.html
[3] https://lists.nongnu.org/archive/html/qemu-devel/2021-10/msg05433.html
Link to cmsg_space macro for recvmmsg and recvmsg should
be the doc's root of crate as macro is an exported macro.
Signed-off-by: bin liu <liubin0329@gmail.com>
1667: Define _POSIX_VDISABLE on Android to fix doc test r=asomers a=rtzoeller
This fixes the compilation [this](1a2ee3da30/src/sys/termios.rs (L27)) example documentation on Android. Tested on Termux.
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
1664: also implement Read and Write for &PtyMaster r=rtzoeller a=doy
align with std::fs::File which also does this because the underlying calls are just syscalls which are safe to run concurrently
Co-authored-by: Jesse Luehrs <doy@tozt.net>