summaryrefslogtreecommitdiff
path: root/src/sys
AgeCommit message (Collapse)Author
2020-01-12Add RISC-V support on GNU/Linuxmsizanoen1
2019-12-22Fix the build on OpenBSD.Alan Somers
We were assuming the wrong types for f_iosize and f_ffree in struct statfs on OpenBSD. Fixes #1125
2019-12-01ScmCredentials now wraps UnixCredentials instead of libc::ucredAlan Somers
2019-12-01Reenable a test that had been disabled due to old CI infrastructureAlan Somers
2019-12-01Remove some obsolete comments.Alan Somers
ignore really is the correct things to do for these doc tests. compile_fail should only be used for examples that demonstrate a compile failure by design, not for stuff that only works on one platform.
2019-12-01impl TryFrom<libc::speed_t> for BaudRateAlan Somers
The old From implementation was actually falliable, and would panic on failure.
2019-12-01Remove the last use of mem::uninitializedAlan Somers
Replace it with mem::zeroed. It isn't perfect, but it's better than it was. Issue #1115
2019-12-01Merge #1156bors[bot]
1156: Remove the deprecated CmsgSpace r=asomers a=asomers This eliminates one of the last remaining uninitialized memory accesses in Nix. Fixes #1142 Co-authored-by: Alan Somers <asomers@gmail.com>
2019-11-30Remove the deprecated CmsgSpaceAlan Somers
This eliminates one of the last remaining uninitialized memory accesses in Nix. Fixes #1142
2019-12-01Allow signal injection in ptrace::{syscall, detach}Francisco Giordano
2019-11-17ptrace: add ptrace::seize for LinuxJeremy Fitzhardinge
2019-11-02sys: termios: Use associated constants for VMIN and VTIME on sparc64John Paul Adrian Glaubitz
2019-11-01sys: termios: Fix inverted logic for [cfg()] conditional for sparc64John Paul Adrian Glaubitz
The fix for #1149 has the logic for the [cfg()] conditional inverted so that the aliases for VMIN and VTIME are defined on targets that are not linux-sparc64.
2019-11-01sys: termios: Define VMIN and VTIME as VEOF and VEOL on sparc64John Paul Adrian Glaubitz
On sparc64, glibc defines VMIN as VEOF and VTIME as VEOL for termios, so we need to inherit these alias definitions for nix-rust as well. Fixes #1149
2019-10-29Merge #1138bors[bot]
1138: Add Signal::as_str() to get representation as static string r=asomers a=MikailBag # Motivation Currently string representation of signal can be obtained with AsRef<str> impl. But it has downside: returned string's lifetime is bound to lifetime of signal, so &str must be converted to String. This allocation is avoidable, because as_ref() only returns static strings. To fix this problem, my PR adds Signal::as_str() method, which returns static string. Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2019-10-29Implement Signal::as_str()Mikail Bagishov
2019-10-28Fix sys::socket::recvfrom for TCP socketsAlan Somers
recvfrom(2) only returns the sender's address for protocols that provide it. Usually, that means it returns the sender's address for datagram sockets but not for stream sockets. Fixes #1144
2019-10-15Properly initialize msghdr when using muslYuxuan Shui
Because of the use of MaybeUninit::uninit, the padding fields in msghdr, which only present on musl builds, are not initialized. Causing garbage data to be sent to the kernel. This change ensures the paddings are always zeroed.
2019-09-19Where relevant, replace equality checks in assert! with assert_eq!Xavier L'Heureux
`assert_eq!` gives more debug info when the test fails by default than `assert!`. This should help make debugging easier.
2019-09-04Merge #1120bors[bot]
1120: Fix length of abstract socket address r=asomers a=yshui NULL bytes have no special significance in an abstrace address, and the length of the address is solely decided by the length member. If the length is set to sun_path.len(), all the NULL bytes will be considered part of the address. Tests are updated accordingly. Closes #1119 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com> Co-authored-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-09-04Fix length of abstract socket addressYuxuan Shui
NULL bytes have no special significance in an abstrace address, and the length of the address is solely decided by the length member. If the length is set to sun_path.len(), all the NULL bytes will be considered part of the address. Tests are updated accordingly. Closes #1119 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-09-04Replace Signal::from_c_int by Signal::try_fromAlan Somers
TryFrom wasn't stable when that function was written.
2019-09-03Replace most instances of mem::uninitialized with mem::MaybeUninitAlan Somers
Only two instances remain: * For the deprecated sys::socket::CmsgSpace::new. We should probably just remove that method. * For sys::termios::Termios::default_uninit. This will require some more thought. Fixes #1096
2019-08-29Implement Default for FdSetAlan Somers
2019-08-29Remove an obsolete commentAlan Somers
It was leftover from internal churn during PR #1020.
2019-08-29Clippy: silence a false-positive cast alignment warningAlan Somers
2019-08-29Clippy: remove unnecessary mem::transmuteAlan Somers
2019-08-29Clippy cleanupAlan Somers
2019-07-13Merge #1095bors[bot]
1095: Fix warnings on Rust 1.37.0 r=asomers a=asomers * Replace obsolete range syntax "..." with inclusive range "..=" * Use dyn Trait syntax instead of Box<Trait> * Raise MSRV to 1.27.0 (for dyn Trait syntax) * Test with nightly again Co-authored-by: Alan Somers <asomers@gmail.com>
2019-07-13Fix warnings on Rust 1.37.0Alan Somers
* Replace obsolete range syntax "..." with inclusive range "..=" * Use dyn Trait syntax instead of Box<Trait> * Raise MSRV to 1.27.0 (for dyn Trait syntax) * Raise MSRV to 1.31.0 (because of rand) tempfile pulls in rand, and rand pulls in fuchsia-cprng, which requires 1.31.0. Why rand pulls in fuchsia-cprng I don't know. It's specified as a target-specific dependency, but Cargo tries to build it anyway (only on Linux, not on FreeBSD or OSX). A bug in Cargo 1.27.0?
2019-07-12socket: add support for AF_VSOCKStefano Garzarella
This patch adds AF_VSOCK support to AddressFamily in order to use VSOCK socket. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2019-06-20Merge #928bors[bot]
928: Wrap libc::statfs r=asomers a=alesharik Fix for [#926](https://github.com/nix-rust/nix/issues/926) Co-authored-by: alesharik <alesharikreserv@yandex.ru>
2019-06-15sys/stat: implement mkdiratKevin Wern
2019-06-12Update statfsalesharik
2019-06-11Fix tests for abstract socketsBryant Mairs
Abstract paths should always be N-1 in length where N is the length of the `sun_path` field (first byte is \0). Given that, `UnixAddr::new_abstract()` should always return this N-1 length, not just the length of the string provided (the rest of the array will be \0s).
2019-06-09Add extra traits for all typesBryant Mairs
Derive Clone, Copy, Eq, Hash, and PartialEq for all types. Not all traits are supported by all types, which is why many are missing some.
2019-06-07socket: expose MSG_WAITALL in MsgFlagsStefano Garzarella
MSG_WAITALL can be useful with recv() to wait the full amount of data requested. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2019-06-06Fix the is_so_mark_functional test in Linux containersAlan Somers
It's not sufficient to check for root privileges. In a container, the euid may be root even though the user lacks some capabilities. Replace this test's root check with a check for the CAP_NET_ADMIN capability instead.
2019-06-03Check euid, not uid, for socket testsAlan Somers
2019-06-02Fix build on Android with recent libcAlan Somers
libc just changed the signedness of sigaction.sa_flags for Android. https://github.com/rust-lang/libc/commit/841b3eb01644283c3c41ac1d1a2ddcec141f15f2
2019-06-02Fix the build on Linux/mips with recent libcAlan Somers
libc just undefined MADV_SOFT_OFFLINE on mips. https://github.com/rust-lang/libc/pull/1365 Fixes #1074
2019-05-31fix more uintXY_t instancesJohannes Schilling
2019-05-31libc::uint32_t -> rust u32Johannes Schilling
2019-05-31libc::uint8_t deprecated in favor of rust u8Johannes Schilling
2019-05-24Allow import of Linux macros in Rust2018Bryant Mairs
Finish off the work started in 8c9ac5a70 allowing the use of macros without needing to import local inner macros.
2019-05-17Fix build on arm and s390x after recent libc changesAlan Somers
libc just removed some symbols on linux/arm32 and linux/s390x that never should've been defined in the first place. https://github.com/rust-lang/libc/commit/24f8972b8d2d915b1687fc8197e1ed95e349a82e https://github.com/rust-lang/libc/commit/d2695436ba5072078796c76f727a296e0f43caa6
2019-04-29Restored the bytes field on RecvMsg in order to know the amount of bytes ↵Vincent Dagonneau
received using recvmsg.
2019-04-12Merge #1041bors[bot]
1041: allow importing macros without helpers in the 2018 edition r=asomers a=euclio ~This PR adds the `$crate::` prefix to all uses of helper macros, which will allow users of the 2018 edition to import the macros without needing to also import their helpers.~ See https://doc.rust-lang.org/edition-guide/rust-2018/macros/macro-changes.html#macros-with-crate-prefix for more info. ~While this is a cleaner solution than using `#[macro_export(local_inner_macros)]`, it also requires bumping the minimum supported compiler version to 1.30. If this is acceptable, I'll add a commit to update the Travis configuration and docs.~ This PR now uses `local_inner_macros` to preserve compatibility with the current minimum Rust version. Co-authored-by: Andy Russell <arussell123@gmail.com>
2019-04-09Uncomment to_std and from_std methods for IpAddrrabbott99
2019-04-04export helper macros via `local_inner_macros`Andy Russell
This will allow users of the 2018 edition to import the macros without needing to also import their helpers.