summaryrefslogtreecommitdiff
path: root/src/fcntl.rs
AgeCommit message (Collapse)Author
2022-12-04Move some pure formatting changes out of #1863Alex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-09-11Clippy cleanupAlan Somers
2022-08-12feat nix-rust#1733: add F_GET_SEALS and F_ADD_SEALS on FreeBSDSteveLauC
2022-06-24Fix all formating problems to pass CI formating testCostin-Robert Sin
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-06Cleanup cfg blocksRyan Zoeller
Remove obsolete references to target_env = wasi, target_os = nacl, target_os = osx, and a typo'd target_os = fushsia that didn't compile when fixed. - target_env = wasi is dead: https://github.com/rust-lang/rust/pull/60117 - target_os = nacl is dead: https://github.com/rust-lang/rust/pull/45041 - target_os = osx is dead, but I can't find a link.
2022-05-14add haiku supportAl Hoang
* enabled as much functionality and defines that match updated libc definitions for haiku
2022-05-14Rewrite the aio moduleAlan Somers
The existing AIO implementation has some problems: 1) The in_progress field is checked at runtime, not compile time. 2) The mutable field is checked at runtime, not compile time. 3) A downstream lio_listio user must store extra state to track whether the whole operation is partially, completely, or not at all submitted. 4) Nix does heap allocation itself, rather than allowing the caller to choose it. This can result in double (or triple, or quadruple) boxing. 5) There's no easy way to use lio_listio to submit multiple operations with a single syscall, but poll each individually. 6) The lio_listio usage is far from transparent and zero-cost. 7) No aio_readv or aio_writev support. 8) priority has type c_int; should be i32 9) aio_return should return a usize instead of an isize, since it only uses negative values to indicate errors, which Rust represents via the Result type. This rewrite solves several problems: 1) Unsolved. I don't think it can be solved without something like C++'s guaranteed type elision. It might require changing the signature of Future::poll too. 2) Solved. 3) Solved, by the new in_progress method and by removing the complicated lio_listio resubmit code. 4) Solved. 5) Solved. 6) Solved, by removing the lio_listo resubmit code. It can be reimplemented downstream if necessary. Or even in Nix, but it doesn't fit Nix's theme of zero-cost abstractions. 7) Solved. 8) Solved. 9) Solved. The rewrite includes functions that don't work on FreeBSD, so add CI testing for FreeBSD 14 too. By default only enable tests that will pass on FreeBSD 12.3. But run a CI job on FreeBSD 14 and set a flag that will enable such tests.
2022-04-08Replace the IoVec type with IoSlice and IoSliceMutnot_a_seagull
2022-01-23Disable the fspacectl testsAlan Somers
They fail to link prior to FreeBSD 14.0, which we don't use in CI. So mark them as no_run. The only alternative I see would be to add a build script.
2022-01-23Add fspacectl on FreeBSDAlan Somers
2021-12-27Add posix_fallocate on DragonFlyRyan Zoeller
2021-12-20feature-gate most Nix functionsVincent Dagonneau
Using features reduces build time and size for consumer crates. By default all features are enabled.
2021-09-28Fix return value of posix_fadviseHaruki Okada
libc::posix_fadvise returns errnos directly rather than in the errno variable.
2021-09-19Clippy cleanupAlan Somers
And this time, start running Clippy in CI
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-08Adding linux specific renameat2()Tom Boland
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.
2021-05-23Use fstatat to check long path sizes in fcntl::readlinkatJason Francis
2021-03-21illumos and Solaris supportJason King
Co-authored-by: Dominik Hassler <hadfl@omnios.org> Co-authored-by: Joshua M. Clulow <josh@sysmgr.org>
2021-01-03Fix fcntl for FreeBSDAlexander Thaller
Need to use the right cfg option for the conditional compilation. target_os is the right option to use when targeting FreeBSD. target_env was used before which seems to be a typo.
2020-06-27misc clippy cleanupAlan Somers
2020-05-31Convert the crate to edition 2018Alan Somers
2020-05-17Make sure to leave the values as-is in openXavier L'Heureux
2020-05-17Remove more unsupported functions and make it possible to run testsXavier L'Heureux
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
2020-05-10Add support for reading symlinks longer than `PATH_MAX` to `readlink` and ↵Solra Bizna
`readlinkat`
2020-04-08Merge #1195bors[bot]
1195: Implement open file descriptor locks in fcntl r=asomers a=andrenth Hello This PR updates libc to 0.2.68, which adds the `F_OFD_*` fcntl commands, and uses them in `nix::fcntl::fcntl`. Co-authored-by: Andre Nathan <andre@digirati.com.br>
2020-03-28Fix fallocate return typeDiana
Untested, done on github. Fixes #1200
2020-03-17Handle open file descriptor locks in fcntlAndre Nathan
2019-11-03Implment linkatJohnnie Birch
This adds the linkat function which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/linkat.html and widely implmented on Unix-Family platforms. Add back trailing whitespace removed on previous force push
2019-09-12posix_fallocateDing Xiang Fei
2019-08-29Clippy: remove an unused lifetime parameterAlan Somers
2019-08-29Clippy cleanupAlan Somers
2019-08-22updated changelogSendil Kumar
2019-08-22fix review commentsSendil Kumar
2019-08-22update readlink to return the path instead of mangling the bufferSendil Kumar
2019-08-22fix readlink/readlinkat to return too long only when it is longSendil Kumar
2019-07-17Add renameatScott Lamb
renameat is (somewhat oddly, imho) in stdio.h. I put it in nix::fcntl because there's no nix::stdio and all its friends (including the AT_* constants) are in nix::fcntl.
2019-07-14Implement unlinkatJohnnie Birch
This adds the unlinkat function, which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html and widely implmented on Unix-family platforms. Implement unlinkat - Update comments to unlink at and breakup tests Changes made based on comments from pull request #1058 Implement unlinkat - Update should_panic for more precise check Updae should_panic attribute for more precise check. Also remove some dead code and note the pull request ID. Implement unlinkat - Update error handling to use unwrap_err The previous patch failed testing on two targets that returned EPERM as the Sys error instead of EISDIR. This patch changes from using the should_panic attribute to using the unwrap_err and matching against the result. Implement Unlinkat - Passing tests should not print anything. Fix. Implement unlinkat - Update location of commit comment in the CHANGELOG Implement unlinkat - Remove newline
2019-07-09implement posix_fadviseKevin Wern
2019-06-12Implement `copy_file_range()`Árni Dagur
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-05-23Update fcntl.rsJakub Konka
Just a minor typo in the docs of `O_RDWR`. It read: ``` /// Allow both reading and writing. /// /// This should not be combined with `O_WRONLY` or `O_RDWR`. O_RDWR; ``` but I believe it should read ``` /// Allow both reading and writing. /// /// This should not be combined with `O_WRONLY` or `O_RDONLY`. O_RDWR; ``` instead :-)
2018-12-08Replace try! with ?Alan Somers
try! is not available in Rust 2018
2018-10-19Add a fchownat(2) wrapperJulio Merino
2018-01-28Require Debug impls for all typesBryant Mairs
2018-01-28Implement Copy/Clone for all types missing itBryant Mairs
2018-01-28Deny unused qualificationsBryant Mairs
2017-12-20Remove unnecessary lifetime annotationsBryant Mairs