summaryrefslogtreecommitdiff
path: root/src/errno.rs
AgeCommit message (Collapse)Author
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-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-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-14Add more errno definitions for better backwards compat with 0.21.0Alan Somers
Fixes #1466
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-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-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-03-21illumos and Solaris supportJason King
Co-authored-by: Dominik Hassler <hadfl@omnios.org> Co-authored-by: Joshua M. Clulow <josh@sysmgr.org>
2020-12-19Add fuchsia supportAmanda Tait
Allow nix to compile on Fuchsia by conditionally avoiding libc functionality that does not exist for Fuchsia.
2020-09-21DragonFlyBSD: use __errno_location now provided by the libc crateChuck Musser
This obviates the need for the C language shim for this variable, which this commit removes.
2020-06-27Make Errno::clear safeAlan Somers
All it does is assign a value to a thread-local int. There's nothing unsafe about that.
2020-05-31Convert the crate to edition 2018Alan Somers
2020-05-17Add Redox support for most of the modulesXavier L'Heureux
Some things are not implemented yet in redox, so a lot of annotations were added to remove functions when compiling for redox. Those functions will hopefully be added in time, but for now it's better to have partial support than none. Blocked by https://github.com/rust-lang/libc/pull/1438
2019-12-29remove deprecated Error::descriptionRadyk Andrii
2019-08-29Clippy cleanupAlan Somers
2019-03-29add errno constants for OpenBSD 6.2 and format long linesJenn Wheeler
2019-03-28Add ENOTSUP to Linux and AndroidJulio Merino
While ENOTSUP is defined as equal to EOPNOTSUPP on these platforms, exposing the ENOTSUP symbol (as libc does) allows for writing portable code that may want to reference this error code.
2019-01-13Implement nix wrapper for libc::signalRobert Gardner
Closes #476
2018-12-03DragonflyBSD: Remove unused Errno'sLevente Kurusa
EUNUSED* were removed from <sys/errno.h> in DragonflyBSD, so there is no need for them to be in nix either. This also fixes the build on DragonflyBSD. Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-01-10Expose mqueue functions for all supported OSesAlan Somers
2017-12-20Merge redundant match armsBryant Mairs
2017-12-19Merge #799bors[bot]
799: Fix nix on Dragonfly r=Susurrus a=mneumann This commit replaces pull request https://github.com/nix-rust/nix/pull/684. It fixes building `nix` on DragonFly. All tests pass. This requires most recent libc to build: https://github.com/rust-lang/libc/pull/851.
2017-12-19Fix support for DragonFlyMichael Neumann
* DragonFly does not have a O_DSYNC flag * Fix type_of_cmsg_data on DragonFly * No fexecve() on DragonFly * Do not run aio test cases on DragonFly * Keep target lists in alphabetical order * Unscrable #[cfg] directives and use cfg_if! macro instead * Fix errno on DragonFly Below follows an explanation why we have to use a C extension to get errno working on DragonFly: DragonFly uses a thread-local errno variable, but #[thread_local] is feature-gated and not available in stable Rust as of this writing (Rust 1.21.0). We have to use a C extension (src/errno_dragonfly.c) to access it. Tracking issue for `thread_local` stabilization: https://github.com/rust-lang/rust/issues/29594 Once this becomes stable, we can remove build.rs, src/errno_dragonfly.c, remove the build-dependency from Cargo.toml, and use: extern { #[thread_local] static errno: c_int; } Now all targets will use the build.rs script, but only on DragonFly this will do something. Also, there are no additional dependencies for targets other than DragonFly (no gcc dep).
2017-12-05Derive Eq for ErrnoBryant Mairs
2017-12-05Remove redundant constant testsBryant Mairs
Now that these constants are verified within libc, these tests are no longer necessary.
2017-12-05Switch to libc definitons of errno constantsBryant Mairs
2017-12-04Stop reexporting `Errno` and its variantsJonas Schievink
cc #664 (unsure if this is everything needed)
2017-11-16Use libc function declarations for errno gettersBryant Mairs
2017-11-16Remove bitrig #[cfgsBryant Mairs
Bitrig is in the process of re-merging with OpenBSD as is no longer actively developed. Additionally it was never tested, and probably was quite broken, for nix. So let's remove all references and not even pretend to support it.
2017-07-04Allow nix to compile on android targetsroblabla
2017-04-09Re-enabled errorno test for not_android.Zac Berkowitz
2017-04-09Fixed constants for MIPSZac Berkowitz
2016-01-28Move errno::Result back to crate rootarcnmx
2016-01-28Errno::result()arcnmx
2015-11-20netbsd supportJeremy Fitzhardinge
2015-09-09Add/Fix support for DragonFly BSDMichael Neumann
2015-09-03Make tests compile on FreeBSDGeoffrey Thomas
Add <sys/types.h>, which GNU is generally lenient about requiring, and drop the spurious errno "ETYPE" which is nowhere to be seen in the source tree (or in Apple's <errno.h>, either).
2015-07-06Consts are not on all kernelsTilde Engineering
2015-07-03Add support for ptraceJoseph Kain
Closes #138
2015-05-29Basic OpenBSD support.Laurence Tratt
Some of the tests are currently unrunnable, but the basic library is at least buildable.
2015-05-21Test sockopt const valuesCarl Lerche
2015-05-11Get the library to build on freebsdAndrew J. Stone
`cargo build` works.
2015-04-24FromPrimitive is no moreFlorian Hartwig
2015-04-06Get compiling on Rust 1.0 betaCarl Lerche
Initially support this by assuming the lowest common denominator. The long term solution is to improve the build system to allow pulling in more specific features that are available on the target system.
2015-03-16Fix deprecation warningsCarl Lerche
2015-03-13Amend some files to make it compile on arm-linux-androideabi.kennytm
2015-02-19Test errno definesCarl Lerche