summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-09[skip ci] fix CHANGELOG after PR #1422Alan Somers
2021-08-09Merge #1422bors[bot]
1422: Add PTRACE_INTERRUPT call as `ptrace::interrupt(pid)` r=asomers a=blaind I've based the test on `fn test_ptrace_cont`. Removed some parts, but not 100% sure what's the proper way of testing in nix context. From ptrace-man page: ``` PTRACE_INTERRUPT (since Linux 3.4) Stop a tracee. If the tracee is running or sleeping in kernel space and PTRACE_SYSCALL is in effect, the system call is interrupted and syscall-exit-stop is reported. (The interrupted system call is restarted when the tracee is restarted.) If the tracee was already stopped by a signal and PTRACE_LISTEN was sent to it, the tracee stops with PTRACE_EVENT_STOP and WSTOPSIG(status) returns the stop signal. If any other ptrace-stop is generated at the same time (for example, if a signal is sent to the tracee), this ptrace-stop happens. If none of the above applies (for example, if the tracee is running in user space), it stops with PTRACE_EVENT_STOP with WSTOPSIG(status) == SIGTRAP. PTRACE_INTERRUPT only works on tracees attached by PTRACE_SEIZE. ``` Co-authored-by: Mika Vatanen <blaind@blaind.net>
2021-08-09Add PTRACE_INTERRUPTMika Vatanen
2021-08-09Merge #1483bors[bot]
1483: Remove some actually unsupported termios iflags on redox r=asomers a=coolreader18 Related to rust-lang/libc#2327 Co-authored-by: Noah <33094578+coolreader18@users.noreply.github.com>
2021-08-09Remove some actually unsupported termios iflags on redoxNoah
2021-08-01Merge #1302bors[bot]
1302: Add getrlimit and setrlimit r=asomers a=LMJW This PR is based on the previous PR https://github.com/nix-rust/nix/pull/1190, which has not been updated for a very long time. I have fixed the segfault and compilation error of the original PR and rebased the changes to the latest master branch. Please let me know if anything need to been changed. Co-authored-by: LMJW <heysuperming@gmail.com>
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-29Merge #1481bors[bot]
1481: Include `sys::eventfd` for target_os = "android" r=asomers a=flxo Androids bionic [supports](https://android.googlesource.com/platform/bionic/+/d1ad4f6/libc/include/sys/eventfd.h) `eventfd`. The `libc` crate also exposes [`eventfd`](https://github.com/rust-lang/libc/blob/36a6a8e254db89cd31d178b4ba102055ceabf9a8/src/unix/linux_like/android/mod.rs#L2648) for target `android`. Extend the conditional compilation check to include the target_os "android". Fixes #1480 Co-authored-by: Felix Obenhuber <felix@obenhuber.de>
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-25Merge #1471bors[bot]
1471: unistd: Add conversion from User to libc::passwd r=asomers a=orvij 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 Exposes the `User::gecos` field to 64-bit Android builds, since `libc::passwd::pw_gecos` is supported on those builds Co-authored-by: orvij <85481483+orvij@users.noreply.github.com>
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 #1465bors[bot]
1465: Enable creating a const TimeSpec r=asomers a=danieldulaney 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 an `std::time::Duration`. An alternative approach would be to make the inner `timespec` field `pub`, which would not require any additional functions but would expose some (potentially unwanted) implementation details. Co-authored-by: Daniel Dulaney <dulaney.daniel@gmail.com> Co-authored-by: Alan Somers <asomers@gmail.com>
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-17Merge #1470bors[bot]
1470: Add the IPV6_V6ONLY sockopt r=asomers a=danieldulaney `IPV6_V6ONLY` allows the user to select between dual-stack and IPv6-only sockets. Platform support seems to be good; all platforms with IPv6 support seem to have this sockopt. Co-authored-by: Daniel Dulaney <dulaney.daniel@gmail.com>
2021-07-16Merge #1469bors[bot]
1469: Fix CONTRIBUTING.md formating r=asomers a=rusty-snake Guess the label prefixes should be rendered bold and not with literal stars. Co-authored-by: rusty-snake <41237666+rusty-snake@users.noreply.github.com>
2021-07-16Add the IPV6_V6ONLY sockoptDaniel Dulaney
2021-07-15Merge #1467bors[bot]
1467: Add more errno definitions for better backwards compat with 0.21.0 r=asomers a=asomers Fixes #1464 Co-authored-by: Alan Somers <asomers@gmail.com>
2021-07-15Fix CONTRIBUTING.md formatingrusty-snake
Guess the label prefixes should be rendered bold and not with literal stars. [skip ci]
2021-07-14Add more errno definitions for better backwards compat with 0.21.0Alan Somers
Fixes #1466
2021-07-14Update changelog with TimeSpec additionsDaniel Dulaney
2021-07-13Merge pull request #1464 from asomers/fdsetAlan Somers
Use immutable receivers for FdSet::{highest, contains, fds}
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-11Merge pull request #1463 from asomers/cargo-dietAlan Somers
Slim down the size of the built package
2021-07-11Add more file types to .gitignoreAlan Somers
2021-07-11Switch Cargo from an exclude list to an include listAlan Somers
The exclude list had gotten out-of-date.
2021-07-10Merge #1462bors[bot]
1462: Fix fork test and enable doc test r=asomers a=sporksmith 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. Co-authored-by: Jim Newsome <jnewsome@torproject.org>
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-09Merge pull request #1461 from asomers/0.22.0Alan Somers
Release v0.22.0
2021-07-09Release v0.22.0Alan Somers
2021-07-09Merge #1455bors[bot]
1455: Support SO_RXQ_OVFL socket option (android/fuchsia/linux) r=asomers a=junhochoi This PR implements support of RXQ_OVFL flag and parsing ControlMessage to get the packet drop counter of UDP socket. Co-authored-by: Junho Choi <junho@cloudflare.com>
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-08Merge #1458bors[bot]
1458: Added support for renameat2 on linux r=asomers a=tomboland Hi, please find my PR for adding the linux-specific `renameat2` syscall. It's largely similar to `renameat`, with an additional flags parameter: The flags are: * RENAME_REPLACE - performs an atomic swap. * RENAME_NOREPLACE - returns EEXIST if the target already exists. * RENAME_WHITEOUT - specific to overly/union filesystems, and I haven't added a test-case for this one. PLEASE NOTE: It looks like my formatter has made numerous changes. If you have a preferred formatting config then please let me know, and I can push up changes consistent with the accepted style. I'm not all that experienced with rust, and this is my first time looking at the nix project, so I'm more than happy to receive guidance on improving my submission. Cheers! Co-authored-by: Tom Boland <tom@t0mb.net>
2021-07-08Adding linux specific renameat2()Tom Boland
2021-07-08Merge #1446bors[bot]
1446: Overhaul Nix's error types r=asomers a=asomers 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>, and the few functions that must return unusual errors like InvalidUtf8 should use bespoke error types. This commit prototypes that approach by modifying just one function, for now, to use the new error type. Co-authored-by: Alan Somers <asomers@gmail.com>
2021-07-07Add CHANGELOG entry for PR #1446Alan Somers
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-07Merge #1460bors[bot]
1460: Bump libc to 0.2.98 r=asomers a=nox A new libc release with the MNT_ fixes was released. Co-authored-by: Anthony Ramine <nox@nox.paris>
2021-07-07Bump libc to 0.2.98Anthony Ramine
A new libc release with the MNT_ fixes was released.
2021-07-06[skip ci] fix CHANGELOG for addition of nmountAlan Somers
Reported by: Anthony Ramine <@nox>
2021-07-05Merge #1457bors[bot]
1457: Add TcpUserTimeout socket option r=asomers a=nox Co-authored-by: Anthony Ramine <nox@nox.paris>