summaryrefslogtreecommitdiff
path: root/src/sys
AgeCommit message (Collapse)Author
2022-04-07Add IP_DONTFRAG and IPV6_DONTFRAG SockOptsJunho Choi
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).
2022-03-28Enable statfs magic constants for target_os = "android"Felix Obenhuber
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
2022-03-24Merge #1672bors[bot]
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](https://github.com/bminor/glibc/blob/b92a49359f33a461db080a33940d73f47c756126/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>
2022-03-24Merge #1686bors[bot]
1686: [skip ci] better docs for SockaddrLike::from_raw r=asomers a=asomers Fixes #1680 Co-authored-by: Alan Somers <asomers@gmail.com>
2022-03-23Make `uname` always safeJan Bujak
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.
2022-03-22[skip ci] better docs for SockaddrLike::from_rawAlan Somers
Fixes #1680
2022-03-22Deprecate IpAddr, Ipv4Addr, and Ipv6AddrAlan Somers
Because they're redundant with types in the standard library. Fixes #1681
2022-03-21Replace the Sockaddr enum with a unionAlan Somers
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 #1504 Fixes #1544
2022-03-20uclibc uses a u32 for RLIMIT definitionsRyan Zoeller
2022-03-20Redox renamed sigaction.sa_handler to .sa_sigactionRyan Zoeller
2022-03-13Use the same signature for LinkAddr::addr on all platformsAlan Somers
This should've been done as part of #1675
2022-03-13Change getrlimit and setrlimit to use rlim_t directly.Arnavion
Fixes #1666
2022-03-13Fix a panic in Linkaddr::addrAlan Somers
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.
2022-03-13Merge #1671bors[bot]
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>
2022-03-09wait: implement waitid()Matthias Schiffer
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
2022-03-09docs: fix link in doc for cmsg_space in sys/socketbin liu
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>
2022-03-08Merge #1670bors[bot]
1670: Add `MsgFlag::MSG_NOSIGNAL` r=rtzoeller a=i509VCB (I guess I will see if I did the cfg block correctly) Co-authored-by: i509VCB <git@i509.me>
2022-03-06Add MsgFlag::MSG_NOSIGNALi509VCB
2022-03-05linux.rs: Define consts for rv32 architectureKhem Raj
Upstream-Status: Pending Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-03-05Fix complation on riscv32Khem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-02-27Define _POSIX_VDISABLE on Android to fix doc testRyan Zoeller
2022-02-20Implement Extend and From/IntoIterator for SigSetWATANABE Yuki
2022-02-07enable process_vm_readv, process_vm_writev for androidrupansh-arch
CHANGELOG: add process_vm_* entry process_vm_*: fix documentation for android expose process_vm_readv, process_vm_writev for android Signed-off-by: rupansh-arch <rupanshsekar@hotmail.com>
2022-02-06Merge #1653bors[bot]
1653: Document inotify, mman, personality, reboot, timerfd r=asomers a=rtzoeller Document the `inotify`, `mman`, `personality`, `reboot`, and `timerfd` modules. Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-02-04Add accept4 on supported platformsRyan Zoeller
2022-02-02Document timerfd.rsRyan Zoeller
2022-02-02Document reboot.rsRyan Zoeller
2022-02-02Document personality.rsRyan Zoeller
2022-02-02Document mman.rsRyan Zoeller
No documentation provided for MADV_CAN_REUSE, as Darwin doesn't actually document its functionality.
2022-01-31Document inotify.rsRyan Zoeller
2022-01-29Fix typo in pread docsRyan Zoeller
2022-01-24uclibc supportJonah Petri
2022-01-23InetAddr::from_std should set sin_len/sin6_len on the BSDsRyan Zoeller
2022-01-22Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSDAlan Somers
Technically these functions don't violate Rust's safety rules, because libc::ptrace doesn't dereference those pointer args. Instead, it passes them directly to the kernel.
2022-01-19Merge #1636bors[bot]
1636: Add MAP_FIXED_NOREPLACE on Linux r=rtzoeller a=rtzoeller Resolves #1393. Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-18Define UMOUNT_NOFOLLOW, FUSE_SUPER_MAGIC on LinuxRyan Zoeller
Requested-by: jiangliu
2022-01-18Add MAP_FIXED_NOREPLACE on LinuxRyan Zoeller
2022-01-16Remove EventFlag::EV_SYSFLAGRyan Zoeller
It is not stable across OpenBSD versions and is reserved by the system on FreeBSD and NetBSD.
2022-01-03Add sendfile(2) for DragonFlyRyan Zoeller
2022-01-02Correct MAP_FIXED documentation for NetBSDRyan Zoeller
The previous documentation described the default behavior, rather than the behavior when the flag was set. Also fix a test which is failing due to passing this flag erroneously.
2021-12-31Merge #1622 #1623bors[bot]
1622: Introduce `timer_*` support r=asomers a=blt This commit adds support for the signal timer mechanism in POSIX, the mirror to timerfd on Linux. I wasn't _quite_ sure of how to fit into the project organization but hopefully this patch isn't too far off. Resolves #1424 Signed-off-by: Brian L. Troutwine <brian@troutwine.us> 1623: Remove cc dependency on DragonFly r=asomers a=rtzoeller f5ee22db489f78b9c003ef60b7ad1b837503bc4a removed the need for this dependency. Co-authored-by: Brian L. Troutwine <brian@troutwine.us> Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-31Merge #1618bors[bot]
1618: Refactor UnixAddr r=asomers a=asomers * Within UnixAddr, replace the path_len variable (length of the sun_path field) with sun_len (length of the whole structure). This is more similar to how other sockaddr types work, and it's the same way that the BSDs use the sun_len field. Also, don't require that sun_path be nul-terminated. The OS doesn't require it. * On BSD-derived operating systems, struct sockaddr has a sa_len field that holds the length of the structure. UnixAddr's path_len field is redundant. Remove path_len on BSD-derived OSes, retaining it only for Illumos and Linux-based OSes. Co-authored-by: Alan Somers <asomers@gmail.com>
2021-12-30Introduce timer_* supportBrian L. Troutwine
This commit adds support for the signal timer mechanism in POSIX, the mirror to timerfd on Linux. Resolves #1424 Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
2021-12-30Optimize UnixAddr for the BSDsAlan Somers
On BSD-derived operating systems, struct sockaddr has a sa_len field that holds the length of the structure. UnixAddr's path_len field is redundant. Remove path_len on BSD-derived OSes, retaining it only for Illumos and Linux-based OSes. Also, ensure that two UnixAddrs compare equal if they differ only by the presence of a trailing NUL. On Linux, syscalls like getsockname add a trailing NUL to the sockaddr they return, even if no NUL was present on the sockaddr originally passed to the kernel via a syscall like bind, and even though the docs explicitly say that any NUL passed to bind is not considered to be part of the address. Work around this bug by stripping it in UnixAddrKind::get(), so that at least two UnixAddrs will compare identical even if they differ in the presence of a trailing NUL.
2021-12-29Add support for the SO_TXTIME sockopt and SCM_TXTIME control messageAlessandro Ghedini
2021-12-27Merge #1596 #1621bors[bot]
1596: Add NetBSD configuration for supported process resources r=asomers a=schctl In addition to existing resources, NetBSD supports `RLIMIT_MEMLOCK`, `RLIMIT_NPROC` and `RLIMIT_RSS`. https://man.netbsd.org/setrlimit.2 `RLIMIT_AS` is also supported, but it looks like it was added [after version 5.0](https://mail-index.netbsd.org/tech-kern/2009/03/28/msg004702.html), so I'm not sure if that should be enabled. 1621: Add posix_fallocate on DragonFly r=asomers a=rtzoeller Enable the existing `posix_fallocate()` tests as they are passing locally. Co-authored-by: Sachin Cherian <sachinctl@protonmail.com> Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-26Fix typosRyan Zoeller
2021-12-24Merge #1547bors[bot]
1547: feat: Add glibc::SOF_TIMESTAMPING_* support r=asomers a=pacak Support for kernel and hardware receive timestamps Co-authored-by: Michael Baikov <manpacket@gmail.com>
2021-12-24Add NetBSD configuration for supported process resourcesSachin Cherian
2021-12-23feat: Add glibc::SOF_TIMESTAMPING_* supportMichael Baikov