summaryrefslogtreecommitdiff
path: root/src/sys/mman.rs
AgeCommit message (Collapse)Author
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-13Use https instead of httpRyan Zoeller
2020-10-13Add wrapper for mremapJim Newsome
2020-06-27misc clippy cleanupAlan Somers
2020-05-31Convert the crate to edition 2018Alan Somers
2020-04-21Add the MAP_HUGE_<SIZE> flags for linux.GuillaumeDIDIER
Closes #1194 Use git libc for development (Remember to reset this to released version for the next nix release, once libc has released >=0.2.69)
2019-06-02Fix the build on Linux/mips with recent libcAlan Somers
libc just undefined MADV_SOFT_OFFLINE on mips. https://github.com/rust-lang/libc/pull/1365 Fixes #1074
2019-01-22add `mman::mprotect`Adam C. Foltzer
2018-12-08Replace try! with ?Alan Somers
try! is not available in Rust 2018
2018-06-03Fix compilation on aarch64-unknown-linux-muslBryant Mairs
2018-03-27add docs for memory locking functionsAndreas Fackler
2018-03-27add mlockall and munlockallAndreas Fackler
2018-01-28Fail to compile for any unused codeBryant Mairs
2018-01-28Deny unused qualificationsBryant Mairs
2017-12-11Merge #806bors[bot]
806: Cleanup all doc warnings r=asomers a=Susurrus With the impending switch to Pulldown as the default doc generator, warnings have been enabled for incompatible syntax. This fixes all of said warnings.
2017-12-10Cleanup doc warningsBryant Mairs
With the impending switch to Pulldown as the default doc generator, warnings have been enabled for incompatible syntax. This fixes all of said warnings.
2017-12-04Stop reexporting `Errno` and its variantsJonas Schievink
cc #664 (unsure if this is everything needed)
2017-08-16Match libc_bitflags! syntax to upstream bitflags!Bryant Mairs
2017-08-11Use libc for FFI functions and constantsBryant Mairs
2017-06-18Fix BSD errorequal-l2
2017-06-18Update bitflags to 0.9equal-l2
2017-03-18Actually mark mmap and related functions as `unsafe`Kevin Mehall
The nix::sys::mman::mmap documentation says > Calls to mmap are inherently unsafe, so they must be made in an unsafe block. however, the function was not actually marked unsafe. * `munmap` should also be `unsafe` for obvious reasons. * `madvise` should be `unsafe` because of the MADV_DONTNEED flag. * `mlock` was already marked `unsafe` * `munlock` and `msync` don't strictly need to be `unsafe` despite taking pointers AFAICT, but are marked `unsafe` for consistency and in case they add additional flags in the future.
2017-02-19Fix the style for bitflags!Mathias Svensson
Prefer libc_bitflags! over bitflags!. Prefer libc::CONSTANTS over writing the constant manually.
2017-02-16Update bitflags to 0.7Simon Sapin
2016-07-18Fix NetBSD buildTobias Bucher
2016-03-16mman: Use libc_bitflags macro for ProtFlagsKamal Marhubi
This serves as an example use of the libc_bitflags macro.
2016-02-25Limit MAP_NOSYNC flag to FreeBSD kinVasily Kolobkov
2016-02-25Withdraw MAP_STACK flag from OpenBSDVasily Kolobkov
2016-02-25Use libcVasily Kolobkov
2016-01-29cfg out MAP_32BIT on non-x86arcnmx
2016-01-28Rename to MapFlags and MsFlags.Philipp Matthias Schaefer
2016-01-28Convert MS_ flags to bitflags! type.Philipp Matthias Schaefer
2016-01-28Convert PROT_ flags to bitflags! type.Philipp Matthias Schaefer
2016-01-28Convert MAP_ flags to bitflags! type.Philipp Matthias Schaefer
2016-01-28Move errno::Result back to crate rootarcnmx
2016-01-28Errno::result()arcnmx
2016-01-18allow improper_ctypes for size_tMattis Marjak
2015-11-20netbsd supportJeremy Fitzhardinge
2015-09-09Add/Fix support for DragonFly BSDMichael Neumann
2015-05-29Basic OpenBSD support.Laurence Tratt
Some of the tests are currently unrunnable, but the basic library is at least buildable.
2015-05-28Remove std::os::unix::io::RawFd re-exportCarl Lerche
2015-05-21Fix NixPath yield with CStr instead of OsStrCarl Lerche
As described in #117, the `AsExtStr` trait is defined to return a raw `*const libc::c_char`. Its impl for `OsStr` simply borrowed the byte slice from its `OsStr` argument and cast it to a `*const libc::c_char`, which does not construct a proper null-terminated C string. Given this, the `AsExtStr` is not necessary and is removed. `NixPath` is updated to yield `CStr`. Fixes #117, #120 Thanks to @dead10ck
2015-05-11Get the library to build on freebsdAndrew J. Stone
`cargo build` works.
2015-03-24NixResult -> nix::Result; NixError -> nix::ErrorCarl Lerche
2015-03-13Amend some files to make it compile on arm-linux-androideabi.kennytm
2015-02-27Further SockAddr & NixPath cleanupCarl Lerche
2015-02-10Add `NixPath`, `NixError`, and `NixResult`.Utkarsh Kukreti
2015-01-27Add a `Mode` bitflags and use it instead of `std::io::FilePermission`.Utkarsh Kukreti
These constants are defined in POSIX [1] so we should export them anyways, plus we don't need to depend on `std::io` anymore! [breaking-change] [1]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html
2015-01-13changed uint and int to usize and isize respectivelyRick Richardson
2015-01-07ToCStr removal falloutValerii Hiora