summaryrefslogtreecommitdiff
path: root/src/sys
AgeCommit message (Collapse)Author
2022-11-20Adds IP_TOS, IPV6_TCLASS and SO_PRIORITY sockopt wrappersmzachar
2022-11-19Merge #1872bors[bot]
1872: Misc internal optimizations r=rtzoeller a=asomers * Make ipv4addr_to_libc const * Use mem::transmute in ipv4addr_to_libc and ipv6addr_to_libc Fixes #1687 Fixes #1688 Co-authored-by: Alan Somers <asomers@gmail.com>
2022-11-19Misc internal optimizationsAlan Somers
* Make ipv4addr_to_libc const * Use mem::transmute in ipv4addr_to_libc and ipv6addr_to_libc Fixes #1687 Fixes #1688
2022-11-19Fix using SockaddrStorage to store Unix domain addresses on LinuxAlan Somers
Since it has variable length, the user of a sockaddr_un must keep track of its true length. On the BSDs, this is handled by the builtin sun_len field. But on Linux-like operating systems it isn't. Fix this bug by explicitly tracking it for SockaddrStorage just like we already do for UnixAddr. Fixes #1866
2022-11-19Mode flag documentationJonathan
2022-11-06Reformat everythingAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-10-23Add a Statfs::flags methodAlan Somers
It returns the mount flags on the BSDs. On Linux, it returns a slightly different set of flags.
2022-10-23Define `MntFlags` and `unmount` on all of the BSDs.Alan Somers
2022-10-23On Linux-like operating systems, use statfs64 instead of statfs.Alan Somers
And fstatfs64 instead of fstatfs.
2022-10-23Suppress deprecation warnings from the latest libcAlan Somers
https://github.com/rust-lang/libc/pull/2963
2022-10-14include docsMichael Baikov
2022-10-14disable a flaky test on aarch64Michael Baikov
See https://github.com/nix-rust/nix/pull/1744 for more details
2022-10-14reimplement recvmsg/sendmmsgMichael Baikov
New implementation performs no allocations after all the necessary structures are created, removes potentially unsound code that was used by the old version (see below) and adds a bit more documentation about bugs in how timeout is actually handled ``` let timeout = if let Some(mut t) = timeout { t.as_mut() as *mut libc::timespec } else { ptr::null_mut() }; ```
2022-10-14pack_mhdr_to_receive: pass iovec ptr and capacity separatelyMichael Baikov
We'll be using that to reinitialize buffers later
2022-10-14pack_mhdr_to_receive: pass pointer and capacity directlyMichael Baikov
This is already an unsafe function, dealing with pointers directly does not make it much more unsafe but simplifies lifetimes later on and similar to a previous commit allows to alocate a single buffer to store all the control messages
2022-10-14socket: stop setting vector length inside read_mhdrMichael Baikov
CMSG_FIRSTHDR/CMSG_NEXTHDR operate in terms of pointers contained inside msghdr structure, vector capacity doesn't matter for them. This would change external behavior of recvmsg/recvmmsg in a sense that buffer passed to store controll messages won't have it's length updated but intended way to receive control messages is with cmsgs iterator on `RecvMsg` which would still work. This change is required to allow using a single vector to store control messages from multiple packets
2022-10-13add XFS_SUPER_NUMBER to nix::sys::statfsMrCroxx
2022-10-08Fix clippy warnings on nightlyRyan Zoeller
Clippy is now smarter about detecting unnecessary casts and useless conversions, which means we need to be more explicit about when the conversions are needed for a subset of platforms. Required changes found by repeatedly running the following command against a list of the supported platforms. `xargs -t -I {} sh -c "cargo clippy -Zbuild-std --target {} --all-targets -- -D warnings || exit 255"` I removed the casts it complained about, and then restored them with an `#[allow]` if a later target needed the cast.
2022-10-02re-export RLIM_INFINITY from libcSteve Lau
2022-09-30statfs: add namespace fs magicPedro Tammela
Namespace filesystem magic is missing from FsType constants.
2022-09-12Merge branch 'master' into issue1814-expose-domainname-of-utsnameSteveLau
2022-09-12Merge #1808bors[bot]
1808: expose memfd on freebsd r=asomers a=i509VCB Resolves #1775 Co-authored-by: i509VCB <git@i509.me>
2022-09-12fix issue1814Steve Lau
2022-09-11Clippy cleanupAlan Somers
2022-09-07expose memfd on freebsdi509VCB
2022-08-22Merge #1805bors[bot]
1805: Add `line` field to `Termios` struct r=rtzoeller a=tertsdiepraam Fixes https://github.com/nix-rust/nix/issues/1802 I have to admit I'm not really sure how to test this properly, so if that's necessary I require some help :) Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
2022-08-22add line field to Termios structTerts Diepraam
2022-08-21Merge #1806bors[bot]
1806: Remove MSRV-related workaround for doc aliases r=asomers a=rtzoeller Remove the MSRV-related workaround added by #1693, since we now can use doc aliases in all supported versions of Rust. Closes #1674. Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-08-20Remove MSRV-related workaround for doc aliasesRyan Zoeller
2022-08-20fix microsecond calculation for TimeSpecS.J.R. van Schaik
2022-08-14Raise the MSRV to 1.56.1 in anticipation of the next releaseAlan Somers
And fix some documentation lints warned about by the newer rustdoc.
2022-08-12Merge #1776bors[bot]
1776: Add support for the IP_SENDSRCADDR control message r=rtzoeller a=matttpt This control message is available on FreeBSD, NetBSD, and OpenBSD. When used with `sendmsg`, it sets the IPv4 source address. This adds support through a new `ControlMessage::Ipv4SendSrcAddr` variant that complements `ControlMessageOwned::Ipv4RecvDstAddr`. A few notes: * `IP_SENDSRCADDR` is actually just an alias for `IP_RECVDSTADDR` (though the code doesn't depend on this). * On NetBSD, `IP_PKTINFO` can be used to accomplish the same thing and is already supported by nix. On FreeBSD and OpenBSD, though, `IP_SENDSRCADDR` is the only method I'm aware of. * The accompanying test binds a UDP socket to all local interfaces (0.0.0.0). If this is not acceptable, please let me know; however, FreeBSD requires this to use `IP_SENDSRCADDR`. I'll add a change-log entry once I see the PR number. Thanks! Co-authored-by: Matthew Ingwersen <matttpt@gmail.com>
2022-08-12fix CI errorSteveLauC
2022-08-12Merge branch 'nix-rust:master' into remove-deprecated-itemsSteveLau
2022-08-12Folloup for !1778, remove some of the less helpful error msgsMichael Baikov
2022-08-09remove deprecated itemsSteveLauC
2022-08-09format codeSteveLauC
2022-08-09remove deprecated itemsSteveLauC
2022-08-05Add support for the IP_SENDSRCADDR control messageMatthew Ingwersen
This control message (actually just an alias for IP_RECVDSTADDR) sets the IPv4 source address when used with sendmsg. It is available on FreeBSD, NetBSD, OpenBSD, and DragonFlyBSD.
2022-08-04fix clippy assertions_on_result_statesMichael Baikov
https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
2022-07-26Merge #1772bors[bot]
1772: Add support for RecvOrigDstAddr on Linux r=asomers a=brianmay Fixes #1767 Co-authored-by: Brian May <brian@linuxpenguins.xyz>
2022-07-26Fix typo guarding memfd export on android.Jason Heeris
2022-07-26Add support for RecvOrigDstAddr on LinuxBrian May
Fixes #1767
2022-07-25Add memfd for target_os = "android"Felix Obenhuber
Memory fds (`memfd`) are implemented and exported by Androids bionic. Export the `memfd` module if the target os is `android`. https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/mman.h;drc=23c7543b8e608ebcbb38b952761b54bb56065577;bpv=1;bpt=1;l=182
2022-07-24Add ETH_P_ALL protocol number to SockProtocolvaldaarhun
Add note to Changelog.md Make changes in comments Co-authored-by: Alan Somers <asomers@gmail.com> Add Android as target os for ETH_P_ALL
2022-07-23Fix SockaddrLike::from_raw with unaligned inputsAlan Somers
The major users of this function are functions like gethostname, which will always properly align their buffers. But out-of-crate consumers could manually construct an unaligned buffer. Handle that correctly. Enable Clippy's cast_ptr_alignment lint. It's disabled by default as it reports many false positives, but it would've caught this problem. Reported-by: Miri Fixes: 1769
2022-07-15Merge #1741bors[bot]
1741: SigSet: A new unsafe helper method to create a SigSet from a sigset_t r=rtzoeller a=germag Currently, the only way to create a `SigSet` from a `sigset_t` object is by using pointer casts, like: ``` unsafe { let sigset = *(&sigset as *const libc::sigset_t as *const SigSet) }; ``` This is un-ergonomic for library creators with interfaces to C. So, let's add a new unsafe method that creates a `SigSet` from a `libc::sigset_t` object. We can't implement `From` since converting from `libc::sigset_t` to `SigSet` is unsafe, because objects of type `libc::sigset_t` must be initialized by calling either `sigemptyset(3)` or `sigfillset(3)` before being used. In other case, the results are undefined. We can't implement `TryFrom` either, because there is no way to check if an object of type `libc::sigset_t` is initialized. Signed-off-by: German Maglione <gmaglione@redhat.com> Co-authored-by: German Maglione <gmaglione@redhat.com>
2022-07-14Fix a buffer overflow in sys::socket::recvfromAlan Somers
IPv4 and stream sockets are unaffected, but for datagram sockets of other address types libc::recvfrom might overwrite part of the stack. Fixes #1762
2022-07-13Add chflagsmusikid
2022-07-12SigSet: Add the `repr(transparent)` attributeGerman Maglione
This commit adds the `repr(transparent)` attribute to the `SigSet` struct, to make sure that its representation is exactly like the `sigset_t` struct from C, in all cases. Signed-off-by: German Maglione <gmaglione@redhat.com>