summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2021-08-13constify more functionsAlan Somers
Constify more functions, since we're raising the MSRV from 1.41.0 to 1.46.0. Fixes #1477
2021-08-13Fix warnings with Rust 1.46.0 - 1.51.0, inclusiveAlan Somers
These ranges of rustc are pickier about where to place an #[allow(unused_doc_comments)] attribute. It caused warnings when building for BSD-based targets.
2021-08-11Merge #1482bors[bot]
1482: Add support for LOCAL_PEER_CRED r=asomers a=asomers On FreeBSD and its derivatives, this socket option gets the credentials of the connected peer. Co-authored-by: Alan Somers <asomers@gmail.com>
2021-08-11Merge #1484bors[bot]
1484: Optionally implement TryFrom in libc_enum! r=asomers a=asomers This saves code in several separate places that need to do this separately. At the same time, remove a few uses of mem::transmute that were implementing TryFrom or similar functionality. Issue #373 Co-authored-by: Alan Somers <asomers@gmail.com>
2021-08-10Add support for LOCAL_PEER_CREDAlan Somers
On FreeBSD and its derivatives, this socket option gets the credentials of the connected peer.
2021-08-09Optionally implement TryFrom in libc_enum!Alan Somers
This saves code in several separate places that need to do this separately. At the same time, remove a few uses of mem::transmute that were implementing TryFrom or similar functionality. Issue #373
2021-08-09Replace some mem::transmute calls in signal.rs with pointer castsAlan Somers
Issue #373
2021-08-09Add PTRACE_INTERRUPTMika Vatanen
2021-08-09Remove some actually unsupported termios iflags on redoxNoah
2021-08-01Add getrlimit and setrlimitLMJW
This work is a continutation on previou contribution by @kpcyrd and @j1ah0ng.
2021-07-29Merge #1473 #1474 #1476bors[bot]
1473: sys/stat: add a safe wrapper for mknodat(2) r=asomers a=lucab This introduces a new `mknodat` helper. Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html 1474: Mark most C-derived enums as non_exhaustive r=asomers a=asomers Since libc may add new variants at any time, Nix's consumers should not use exhaustive match patterns. Fixes #1182 1476: Constify many functions r=asomers a=asomers Constify most functions that can be constified. The exceptions are mostly accessors for structs that have no const constructor. Co-authored-by: Luca BRUNO <luca.bruno@coreos.com> Co-authored-by: Alan Somers <asomers@gmail.com>
2021-07-28sys/stat: add a safe wrapper for mknodat(2)Luca BRUNO
This introduces a new `mknodat` helper. Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html
2021-07-27Expose `sys::eventfd` for target_os = "android"Felix Obenhuber
Androids bionic supports eventfd. Extend the conditional compilation check to include the target_os "android". Fixes #1480
2021-07-24Constify many functionsAlan Somers
Constify most functions that can be constified. The exceptions are mostly accessors for structs that have no const constructor.
2021-07-24unistd: Add conversion from User to libc::passwdorvij
Add From<User> for libc::passwd trait implementation to convert a User into a libc::passwd Implementation consumes the User struct, giving ownership over the internal members to the libc::passwd struct Add the User::gecos field to 64-bit Android builds, since it is supported by libc::passwd for those builds
2021-07-24Merge #1472bors[bot]
1472: Add pthread_kill r=asomers a=mkroening This adds `pthread_kill`, following the design of `killpg`. What do you think? Co-authored-by: Martin Kröning <mkroening@posteo.net>
2021-07-24Merge branch 'master' into const_timespecAlan Somers
2021-07-24Add pthread_killMartin Kröning
2021-07-24Mark most C-derived enums as non_exhaustiveAlan Somers
Since libc may add new variants at any time, Nix's consumers should not use exhaustive match patterns. Fixes #1182
2021-07-16Add the IPV6_V6ONLY sockoptDaniel Dulaney
2021-07-14Add more errno definitions for better backwards compat with 0.21.0Alan Somers
Fixes #1466
2021-07-13Enable creating a const TimeSpecDaniel Dulaney
Previously, there was no way to create a TimeSpec in a const context because all creation was through traits. This adds two utility functions to create a const TimeSpec from a libc::timespec or a std::time::Duration
2021-07-13Use immutable receivers for FdSet::{highest, contains, fds}Alan Somers
There was never any good reason to use mutable receives in the first place. Nix originally did so because libc defined FD_ISSET as taking a mutable receiver, which it did based on an inaccurate Linux man page. But that's fixed now. https://github.com/rust-lang/libc/pull/1725
2021-07-09Fix fork test and enable doc testJim Newsome
Replaces `println!` with raw `libc::write`. `println!` isn't guaranteed to be async-signal-safe, and almost certainly *isn't* due to internal buffering and locking. Adds a call to `libc::_exit` in the child arm, so that it doesn't fall through and start executing the parent code. Adds a call to `waitpid` in the parent arm, to clean up the child process. Removes the `no_run` directive, so that it's run in the doc tests.
2021-07-08Support SO_RXQ_OVFL socket option (android/fuchsia/linux)Junho Choi
This PR implements support of RXQ_OVFL flag and parsing ControlMessage to get the packet drop counter of UDP socket.
2021-07-08Adding linux specific renameat2()Tom Boland
2021-07-07Collapse Error into ErrnoAlan Somers
Now that Nix's weird error types are eliminated, there's no reason not to simply use Errno as the Error type.
2021-07-07Overhaul Nix's error typesAlan Somers
For many of Nix's consumers it be convenient to easily convert a Nix error into a std::io::Error. That's currently not possible because of the InvalidPath, InvalidUtf8, and UnsupportedOperation types that have no equivalent in std::io::Error. However, very few of Nix's public APIs actually return those unusual errors. So a more useful API would be for Nix's standard error type to implement Into<std::io::Error>. This commit makes Error a simple NewType around Errno. For most functions it's a drop-in replacement. There are only three exceptions: * clearenv now returns a bespoke error type. It was the only Nix function whose error couldn't be cleanly mapped onto an Errno. * sys::signal::signal now returns Error(Errno::ENOTSUP) instead of Error::UnsupportedOperation when the user passes an incompatible argument to `handler`. * When a NixPath exceeds PATH_MAX, it will now return Error(Errno::ENAMETOOLONG) instead of Error::InvalidPath. In the latter two cases there is now some abiguity about whether the error code was generated by Nix or by the OS. But I think the ambiguity is worth it for the sake of being able to implement Into<io::Error>. This commit also introduces Error::Sys() as a migration aid. Previously that as an enum variant. Now it's a function, but it will work in many of the same contexts as the original. Fixes #1155
2021-07-07ptsname_r now returns a lossily-converted string in the event of bad UTFAlan Somers
2021-07-05Add TcpUserTimeout socket optionAnthony Ramine
2021-06-23Add IpFreebind socket optionAnthony Ramine
2021-06-16Missing changes from PR #1453Alan Somers
2021-06-13Add nmount for FreeBSD.Alan Somers
2021-06-12Add Errno::EOPNOTSUPP to FreeBSD, where it is missingAlan Somers
2021-06-12Errno aliases are now associated consts of the Errno type.Alan Somers
Previously they had to be consts in the errno module, because associated consts weren't supported until Rust 1.20.0. Now that they're associated consts, they can be used interchangeably with regular Errno enum variants.
2021-06-12Remove Errno consts from platforms where they aren't defined.Alan Somers
Previously these were aliases for UnknownErrno. Now, they're compile errors.
2021-06-12Merge pull request #1450 from asomers/alarm-errorsAlan Somers
Hopefully fix unreliability in unistd::alarm's doc test
2021-06-12Hopefully fix unreliability in unistd::alarm's doc testAlan Somers
2021-06-12Fix bad links in the aio docsAlan Somers
2021-06-12wordsmithing on sched::cloneAlan Somers
2021-06-12Add documentation for sched::cloneKonstantinos Andrikopoulos
Add a note in the documentation for sched::clone to point out that the stack pointer does not neet to be a reference to the highest address of the stack. Users who simply read the manpages for clone(2) might assume that they will need to use unsafe pointer arithmetics in order to create a reference to the highest address of their buffer, rather than providing their buffer directly.
2021-06-06Add a wrapper around if_nameindexNoah
2021-05-31Add getresuid() and getresgid() to unistdJeryl Vaz
2021-05-30misc Clippy cleanupAlan Somers
* Fix race conditions in the tests. Two tests were grabbing a mutex but immediately dropping it. Thank you, Clippy. * Remove vestigial Windows support. Remove some code added to support Windows in 2015. Nix is no longer intended to ever run on Windows. * Various other minor Clippy lints.
2021-05-31Merge #1437bors[bot]
1437: Add MS_LAZYTIME flag r=asomers a=ManaSugi MS_LAZYTIME (since Linux 4.0) reduces on-disk updates of inode timestamps (atime, mtime, ctime) by maintaining these changes only in memory. MS_LAZYTIME is available from `libc` v0.2.95. Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com> Co-authored-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2021-05-31Add MS_LAZYTIME flagManabu Sugimoto
MS_LAZYTIME (since Linux 4.0) reduces on-disk updates of inode timestamps (atime, mtime, ctime) by maintaining these changes only in memory. Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2021-05-30Adapt aio to the world of async/await, and fix some potential unsoundness.Alan Somers
* libc::aiocb must not be moved while the kernel has a pointer to it. This change enforces that requirement by using std::pin. * Split LioCbBuilder out of LioCb. struct LioCb relied on the (incorrect) assumption that a Vec's elements have a stable location in memory. That's not true; they can be moved during Vec::push. The solution is to use a Vec in the new Builder struct, but finalize it to a boxed slice (which doesn't support push) before allowing it to be submitted to the kernel. * Eliminate owned buffer types. mio-aio no longer uses owned buffers with nix::aio. There's little need for it in the world of async/await. I'm not aware of any other consumers. This substantially simplifies the code.
2021-05-30Merge pull request #1442 from asomers/issue-1441Alan Somers
Suppress a build warning on Fuchsia
2021-05-30Suppress a build warning on FuchsiaAlan Somers
Beginning with 1.41.0, Rust considers it UB to zero-initialize a function pointer, even if you try to hide it behind `mem::MaybeUninit`. Suppress this warning to fix the build until we come up with a better permanent solution. Issue #1441
2021-05-28Disable sendfile64 on androidTom Dryer
It's not available from libc on that platform.