summaryrefslogtreecommitdiff
path: root/test/sys/test_ioctl.rs
AgeCommit message (Collapse)Author
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-06-24Fix all formating problems to pass CI formating testCostin-Robert Sin
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
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-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.
2020-04-19Remove a few more cases of mem::uninitialized in the testsAlan Somers
Somehow I didn't noticed these in PR #1158, probably because they're only built on Linux.
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-08-28Fix some ioctl tests on muslAlan Somers
Weirdly, musl uses i32 to store the ioctl opcode
2018-04-10Implement equivalent for _IOWINT for FreeBSD-like targetsBryant Mairs
ioctls on FreeBSD and DragonflyBSD have a separate request code generation macro `_IOWINT` which is now exposed as `request_code_write_int`. `ioctl_write_int` is also fixed on these platforms to use this new request
2018-04-10Refactor the ioctl API and documentationBryant Mairs
* Split `ioctl!` into separate macros. This makes documentation easier to read. * For every `ioctl_*!` macro include a description of the macro arguments as, the function prototype for the generated wrapper function, and an example if we have one. * Expose `request_code_*!` in the documentation to make the `ioctl_*_bad` macros easier to use. * Reorganize the file hierarchy to be simpler
2017-12-20Remove unnecessary mutBryant Mairs
2017-12-20Correct ioctl read and write_ptr testsBryant Mairs
Looks like a copy/paste error might have caused this
2017-12-20Make numeric literals easier to readBryant Mairs
2017-12-04Stop reexporting `Errno` and its variantsJonas Schievink
cc #664 (unsure if this is everything needed)
2017-07-24Disable failing tests on mips64Bryant Mairs
These are assumed to be QEMU issues, as they also fail on mips.
2017-07-21Allow doc attributes in ioctl macroroblabla
2017-07-20Add tests of actual ioctl usageBryant Mairs
2017-07-19Refactor ioctl! for buffersBryant Mairs
Instead of relying on the macro user to calculate the length in bytes do that within the macro itself
2017-07-19Add 'bad' prefixes for read, write_*, and readwrite ioctlsBryant Mairs
2017-07-19Split ioctl!(write ...) into write_ptr and write_intBryant Mairs
There two different write semantics used with ioctls: one involves passing a pointer the other involves passing an int. Previously the ioctl! macro did not distinguish between these cases and left it up to the user to set the proper datatype. This previous version was not type safe and prone to errors. The solution here is to split the "write" variant into a "write_ptr" and "write_int" variant that makes the semantics more explicit and improves type safety by specifying arguments better.
2017-07-19Add a "bad none" variant to the ioctl macroBryant Mairs
2017-07-19Re-add bad variant of ioctl!Bryant Mairs
2017-06-19Support powerpc64Luca Barbato
The test_ioctl values are computed using ioctl-test.c
2017-04-09Fixed failing ioctl tests.Zac Berkowitz
2016-12-10Add ioctl support for BSDConrad Kramer
2015-08-12ioctl: return result type rather than raw integerPaul Osborne
This change also adds macro usages in the tests. Nothing is asserted but the use of the macros provides a basic compile-time check that is otherwise missing. Signed-off-by: Paul Osborne <osbpau@gmail.com>
2015-08-12conditionally enable ioctl test for linuxCorey Richardson
2015-08-12Fix testsCorey Richardson
2015-05-21Test sockopt const valuesCarl Lerche
2015-05-12ioctl: implement generic support for the ioctl syscall and supporting functionsPaul Osborne
This commit provides a new implementation for ioctl that is much more generic, allowing for clients to use send any manner of ioctl requests at special files. The implementation provides two main features that help to raise the level of abstraction over that provided by libc. 1. The module now provides functions that provide the same functionality as the linux kernel _IO* macros. These are used frequently in the linux kernel for building ops for ioctls. The use of these helper functions are not required. 2. Functions are provided for the 3 main types of ioctl usage patterns (read, write, and execute). For many subystems, the read() call which returns a Result<T> and the write calls taking a &T provide a nice interface. All of the methods wrapping ioctl are unsafe and will probably need to remain that way unless knowledge of the semantics of every possible ioctl call are added to the nix library. The best that exists for ioctls are some conventions around the op, but even these conventions are really only used for newer devices added to the kernel. This change resolves #108