| { | ||
| "git": { | ||
| "sha1": "3cf9007216086b17a6ef5a09fa42dc00cde5c2bf" | ||
| "sha1": "9ac60c56b0e5dc1966fefeff41fd4f6aecf403f9" | ||
| }, | ||
| "path_in_vcs": "" | ||
| } |
+3
-3
@@ -87,5 +87,5 @@ # This file is automatically @generated by Cargo. | ||
| name = "libc" | ||
| version = "0.2.172" | ||
| version = "0.2.180" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" | ||
| checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" | ||
@@ -119,3 +119,3 @@ [[package]] | ||
| name = "nix" | ||
| version = "0.30.1" | ||
| version = "0.31.0" | ||
| dependencies = [ | ||
@@ -122,0 +122,0 @@ "assert-impl", |
+2
-2
@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "nix" | ||
| version = "0.30.1" | ||
| version = "0.31.0" | ||
| authors = ["The nix-rust Project Developers"] | ||
@@ -126,3 +126,3 @@ build = "build.rs" | ||
| [dependencies.libc] | ||
| version = "0.2.171" | ||
| version = "=0.2.180" | ||
| features = ["extra_traits"] | ||
@@ -129,0 +129,0 @@ |
+75
-68
@@ -8,12 +8,6 @@ //! List directory contents | ||
| use cfg_if::cfg_if; | ||
| use std::ffi; | ||
| use std::ffi::{CStr, CString}; | ||
| use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; | ||
| use std::ptr; | ||
| #[cfg(target_os = "linux")] | ||
| use libc::{dirent64 as dirent, readdir64_r as readdir_r}; | ||
| #[cfg(not(target_os = "linux"))] | ||
| use libc::{dirent, readdir_r}; | ||
| /// An open directory. | ||
@@ -30,3 +24,3 @@ /// | ||
| /// * returns entries for `.` (current directory) and `..` (parent directory). | ||
| /// * returns entries' names as a [`CStr`][cstr] (no allocation or conversion beyond whatever libc | ||
| /// * returns entries' names as a [`CStr`] (no allocation or conversion beyond whatever libc | ||
| /// does). | ||
@@ -124,3 +118,3 @@ /// | ||
| /// Returns an iterator of `Result<Entry>` which rewinds when finished. | ||
| pub fn iter(&mut self) -> Iter { | ||
| pub fn iter(&mut self) -> Iter<'_> { | ||
| Iter(self) | ||
@@ -130,6 +124,3 @@ } | ||
| // `Dir` is not `Sync`. With the current implementation, it could be, but according to | ||
| // https://www.gnu.org/software/libc/manual/html_node/Reading_002fClosing-Directory.html, | ||
| // future versions of POSIX are likely to obsolete `readdir_r` and specify that it's unsafe to | ||
| // call `readdir` simultaneously from multiple threads. | ||
| // `Dir` is not `Sync` because it's unsafe to call `readdir` simultaneously from multiple threads. | ||
| // | ||
@@ -140,3 +131,3 @@ // `Dir` is safe to pass from one thread to another, as it's not reference-counted. | ||
| impl std::os::fd::AsFd for Dir { | ||
| fn as_fd(&self) -> std::os::fd::BorrowedFd { | ||
| fn as_fd(&self) -> std::os::fd::BorrowedFd<'_> { | ||
| let raw_fd = self.as_raw_fd(); | ||
@@ -168,25 +159,18 @@ | ||
| // The pass by mut is technically needless only because the inner NonNull is | ||
| // Copy. But philosophically we're mutating the Dir, so we pass by mut. | ||
| // Copy. But we are actually mutating the Dir, so we pass by mut. | ||
| #[allow(clippy::needless_pass_by_ref_mut)] | ||
| fn next(dir: &mut Dir) -> Option<Result<Entry>> { | ||
| fn readdir(dir: &mut Dir) -> Option<Result<Entry>> { | ||
| Errno::clear(); | ||
| unsafe { | ||
| // Note: POSIX specifies that portable applications should dynamically allocate a | ||
| // buffer with room for a `d_name` field of size `pathconf(..., _PC_NAME_MAX)` plus 1 | ||
| // for the NUL byte. It doesn't look like the std library does this; it just uses | ||
| // fixed-sized buffers (and libc's dirent seems to be sized so this is appropriate). | ||
| // Probably fine here too then. | ||
| let mut ent = std::mem::MaybeUninit::<dirent>::uninit(); | ||
| let mut result = ptr::null_mut(); | ||
| if let Err(e) = Errno::result(readdir_r( | ||
| dir.0.as_ptr(), | ||
| ent.as_mut_ptr(), | ||
| &mut result, | ||
| )) { | ||
| return Some(Err(e)); | ||
| let de = libc::readdir(dir.0.as_ptr()); | ||
| if de.is_null() { | ||
| if Errno::last_raw() == 0 { | ||
| // EOF | ||
| None | ||
| } else { | ||
| Some(Err(Errno::last())) | ||
| } | ||
| } else { | ||
| Some(Ok(Entry::from_raw(&*de))) | ||
| } | ||
| if result.is_null() { | ||
| return None; | ||
| } | ||
| assert_eq!(result, ent.as_mut_ptr()); | ||
| Some(Ok(Entry(ent.assume_init()))) | ||
| } | ||
@@ -203,3 +187,3 @@ } | ||
| fn next(&mut self) -> Option<Self::Item> { | ||
| next(self.0) | ||
| readdir(self.0) | ||
| } | ||
@@ -222,3 +206,3 @@ } | ||
| fn next(&mut self) -> Option<Self::Item> { | ||
| next(&mut self.0) | ||
| readdir(&mut self.0) | ||
| } | ||
@@ -263,5 +247,14 @@ } | ||
| /// Note that unlike the std version, this may represent the `.` or `..` entries. | ||
| #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] | ||
| #[repr(transparent)] | ||
| pub struct Entry(dirent); | ||
| #[derive(Clone, Debug, Eq, Hash, PartialEq)] | ||
| pub struct Entry { | ||
| ino: u64, | ||
| type_: Option<Type>, | ||
| // On some platforms libc::dirent is a "flexible-length structure", where there may be | ||
| // data beyond the end of the struct definition. So it isn't possible to copy it and subsequently | ||
| // dereference the copy's d_name field. Nor is it possible for Entry to wrap a &libc::dirent. | ||
| // At least, not if it is to work with the Iterator trait. Because the Entry would need to | ||
| // maintain a mutable reference to the Dir, which would conflict with the iterator's mutable | ||
| // reference to the same Dir. So we're forced to copy the name here. | ||
| name: CString, | ||
| } | ||
@@ -289,6 +282,24 @@ /// Type of file referenced by a directory entry | ||
| /// Returns the inode number (`d_ino`) of the underlying `dirent`. | ||
| pub fn ino(&self) -> u64 { | ||
| self.ino | ||
| } | ||
| /// Returns the bare file name of this directory entry without any other leading path component. | ||
| pub fn file_name(&self) -> &CStr { | ||
| self.name.as_c_str() | ||
| } | ||
| /// Returns the type of this directory entry, if known. | ||
| /// | ||
| /// See platform `readdir(3)` or `dirent(5)` manpage for when the file type is known; | ||
| /// notably, some Linux filesystems don't implement this. The caller should use `stat` or | ||
| /// `fstat` if this returns `None`. | ||
| pub fn file_type(&self) -> Option<Type> { | ||
| self.type_ | ||
| } | ||
| #[allow(clippy::useless_conversion)] // Not useless on all OSes | ||
| // The cast is not unnecessary on all platforms. | ||
| #[allow(clippy::unnecessary_cast)] | ||
| pub fn ino(&self) -> u64 { | ||
| fn from_raw(de: &libc::dirent) -> Self { | ||
| cfg_if! { | ||
@@ -304,36 +315,32 @@ if #[cfg(any(target_os = "aix", | ||
| apple_targets))] { | ||
| self.0.d_ino as u64 | ||
| let ino = de.d_ino as u64; | ||
| } else { | ||
| u64::from(self.0.d_fileno) | ||
| let ino = u64::from(de.d_fileno); | ||
| } | ||
| } | ||
| } | ||
| /// Returns the bare file name of this directory entry without any other leading path component. | ||
| pub fn file_name(&self) -> &ffi::CStr { | ||
| unsafe { ffi::CStr::from_ptr(self.0.d_name.as_ptr()) } | ||
| } | ||
| /// Returns the type of this directory entry, if known. | ||
| /// | ||
| /// See platform `readdir(3)` or `dirent(5)` manpage for when the file type is known; | ||
| /// notably, some Linux filesystems don't implement this. The caller should use `stat` or | ||
| /// `fstat` if this returns `None`. | ||
| pub fn file_type(&self) -> Option<Type> { | ||
| #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))] | ||
| match self.0.d_type { | ||
| libc::DT_FIFO => Some(Type::Fifo), | ||
| libc::DT_CHR => Some(Type::CharacterDevice), | ||
| libc::DT_DIR => Some(Type::Directory), | ||
| libc::DT_BLK => Some(Type::BlockDevice), | ||
| libc::DT_REG => Some(Type::File), | ||
| libc::DT_LNK => Some(Type::Symlink), | ||
| libc::DT_SOCK => Some(Type::Socket), | ||
| /* libc::DT_UNKNOWN | */ _ => None, | ||
| cfg_if! { | ||
| if #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))] { | ||
| let type_ = match de.d_type { | ||
| libc::DT_FIFO => Some(Type::Fifo), | ||
| libc::DT_CHR => Some(Type::CharacterDevice), | ||
| libc::DT_DIR => Some(Type::Directory), | ||
| libc::DT_BLK => Some(Type::BlockDevice), | ||
| libc::DT_REG => Some(Type::File), | ||
| libc::DT_LNK => Some(Type::Symlink), | ||
| libc::DT_SOCK => Some(Type::Socket), | ||
| /* libc::DT_UNKNOWN | */ _ => None, | ||
| }; | ||
| } else { | ||
| // illumos, Solaris, and Haiku systems do not have the d_type member at all: | ||
| #[cfg(any(solarish, target_os = "aix", target_os = "haiku"))] | ||
| let type_ = None; | ||
| } | ||
| } | ||
| // Annoyingly, since libc::dirent is open-ended, the easiest way to read the name field in | ||
| // Rust is to treat it like a pointer. | ||
| // Safety: safe because we knod that de.d_name is in valid memory. | ||
| let name = unsafe { CStr::from_ptr(de.d_name.as_ptr()) }.to_owned(); | ||
| // illumos, Solaris, and Haiku systems do not have the d_type member at all: | ||
| #[cfg(any(solarish, target_os = "aix", target_os = "haiku"))] | ||
| None | ||
| Entry { ino, type_, name } | ||
| } | ||
| } |
+7
-2
@@ -748,3 +748,3 @@ //! File control options | ||
| F_SETLK(&'a libc::flock), | ||
| /// Like [`F_SETLK`](FcntlArg::F_SETLK) except that if a shared or exclusive lock is blocked by | ||
| /// Like [`F_SETLK`] except that if a shared or exclusive lock is blocked by | ||
| /// other locks, the process waits until the request can be satisfied. | ||
@@ -757,3 +757,3 @@ F_SETLKW(&'a libc::flock), | ||
| F_OFD_SETLK(&'a libc::flock), | ||
| /// Like [`F_OFD_SETLK`](FcntlArg::F_OFD_SETLK) except that if a conflicting lock is held on | ||
| /// Like [`F_OFD_SETLK`] except that if a conflicting lock is held on | ||
| /// the file, then wait for that lock to be released. | ||
@@ -1043,2 +1043,3 @@ #[cfg(linux_android)] | ||
| #[cfg(not(any(target_os = "redox", target_os = "solaris")))] | ||
| #[allow(clippy::unnecessary_unwrap)] // https://github.com/rust-lang/rust-clippy/issues/15744 | ||
| impl<T: Flockable> Drop for Flock<T> { | ||
@@ -1180,4 +1181,6 @@ fn drop(&mut self) { | ||
| /// Not applicable to `vmsplice`. | ||
| #[cfg(not(target_env = "uclibc"))] | ||
| SPLICE_F_MOVE; | ||
| /// Do not block on I/O. | ||
| #[cfg(not(target_env = "uclibc"))] | ||
| SPLICE_F_NONBLOCK; | ||
@@ -1187,2 +1190,3 @@ /// Hint that more data will be coming in a subsequent splice. | ||
| /// Not applicable to `vmsplice`. | ||
| #[cfg(not(target_env = "uclibc"))] | ||
| SPLICE_F_MORE; | ||
@@ -1192,2 +1196,3 @@ /// Gift the user pages to the kernel. | ||
| /// Not applicable to `splice`. | ||
| #[cfg(not(target_env = "uclibc"))] | ||
| SPLICE_F_GIFT; | ||
@@ -1194,0 +1199,0 @@ } |
+1
-1
@@ -36,3 +36,3 @@ //! Query network interface addresses | ||
| cfg_if! { | ||
| if #[cfg(any(linux_android, target_os = "emscripten", target_os = "fuchsia"))] { | ||
| if #[cfg(any(linux_android, target_os = "emscripten", target_os = "fuchsia", target_os = "hurd"))] { | ||
| fn get_ifu_from_sockaddr(info: &libc::ifaddrs) -> *const libc::sockaddr { | ||
@@ -39,0 +39,0 @@ info.ifa_ifu |
+2
-1
@@ -137,3 +137,4 @@ //! Rust friendly bindings to the various *nix system functions. | ||
| bsd, | ||
| solarish))] | ||
| solarish, | ||
| target_os = "hurd"))] | ||
| #[deny(missing_docs)] | ||
@@ -140,0 +141,0 @@ pub mod ifaddrs; |
+1
-1
@@ -318,3 +318,3 @@ //! Posix Message Queue functions | ||
| /// Borrow the underlying message queue descriptor. | ||
| fn as_fd(&self) -> BorrowedFd { | ||
| fn as_fd(&self) -> BorrowedFd<'_> { | ||
| // SAFETY: [MqdT] will only contain a valid fd by construction. | ||
@@ -321,0 +321,0 @@ unsafe { BorrowedFd::borrow_raw(self.0) } |
+0
-1
@@ -69,3 +69,2 @@ //! Network interface name resolution. | ||
| target_os = "fuchsia", | ||
| target_os = "netbsd", | ||
| target_os = "cygwin"))] | ||
@@ -72,0 +71,0 @@ IFF_NOTRAILERS as IflagsType; |
+32
-7
@@ -26,2 +26,3 @@ // vim: tw=80 | ||
| //! not support this for all filesystems and devices. | ||
| #![allow(clippy::doc_overindented_list_items)] // It looks better this way | ||
| #[cfg(target_os = "freebsd")] | ||
@@ -317,3 +318,3 @@ use std::io::{IoSlice, IoSliceMut}; | ||
| /// Returns the underlying file descriptor associated with the operation. | ||
| fn fd(&self) -> BorrowedFd; | ||
| fn fd(&self) -> BorrowedFd<'_>; | ||
@@ -460,3 +461,3 @@ /// Does this operation currently have any in-kernel state? | ||
| /// * `prio`: If POSIX Prioritized IO is supported, then the | ||
| /// operation will be prioritized at the process's priority level minus | ||
| /// operation will be prioritized at the process's priority level minus | ||
| /// `prio`. | ||
@@ -578,4 +579,5 @@ /// * `sigev_notify`: Determines how you will be notified of event completion. | ||
| /// * `buf`: A memory buffer. It must outlive the `AioRead`. | ||
| /// * `prio`: If POSIX Prioritized IO is supported, then the operation | ||
| /// will be prioritized at the process's priority level minus `prio` | ||
| /// * `prio`: If POSIX Prioritized IO is supported, then the | ||
| /// operation will be prioritized at the process's | ||
| /// priority level minus `prio`. | ||
| /// * `sigev_notify`: Determines how you will be notified of event completion. | ||
@@ -809,4 +811,5 @@ pub fn new( | ||
| /// * `buf`: A memory buffer. It must outlive the `AioWrite`. | ||
| /// * `prio`: If POSIX Prioritized IO is supported, then the operation | ||
| /// will be prioritized at the process's priority level minus `prio` | ||
| /// * `prio`: If POSIX Prioritized IO is supported, then the | ||
| /// operation will be prioritized at the process's | ||
| /// priority level minus `prio` | ||
| /// * `sigev_notify`: Determines how you will be notified of event completion. | ||
@@ -1146,3 +1149,25 @@ pub fn new( | ||
| /// possibly resubmit some. | ||
| /// ``` | ||
| /// | ||
| // Do not run this doc test on: | ||
| // * aarch64-unknown-linux-musl | ||
| // * i686-unknown-linux-musl | ||
| // because it hangs on these targets. After further debugging, we think this is | ||
| // likely a bug of musl. Since we only test our bindings and do not intend to | ||
| // fix the underlying libc bug, we skip this test here. | ||
| // See this thread for the discussion of this issue: | ||
| // https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159 | ||
| #[cfg_attr( | ||
| all( | ||
| target_env = "musl", | ||
| any(target_arch = "aarch64", target_arch = "x86") | ||
| ), | ||
| doc = " ```no_run" | ||
| )] | ||
| #[cfg_attr( | ||
| not(all( | ||
| target_env = "musl", | ||
| any(target_arch = "aarch64", target_arch = "x86") | ||
| )), | ||
| doc = " ```" | ||
| )] | ||
| /// # use libc::c_int; | ||
@@ -1149,0 +1174,0 @@ /// # use std::os::unix::io::AsFd; |
+2
-2
@@ -52,3 +52,3 @@ use crate::errno::Errno; | ||
| impl EpollEvent { | ||
| pub fn new(events: EpollFlags, data: u64) -> Self { | ||
| pub const fn new(events: EpollFlags, data: u64) -> Self { | ||
| EpollEvent { | ||
@@ -70,3 +70,3 @@ event: libc::epoll_event { | ||
| pub fn data(&self) -> u64 { | ||
| pub const fn data(&self) -> u64 { | ||
| self.event.u64 | ||
@@ -73,0 +73,0 @@ } |
+2
-7
@@ -94,8 +94,3 @@ //! Kernel event notification mechanism | ||
| #[cfg(any(freebsdlike, apple_targets, target_os = "openbsd"))] | ||
| type type_of_udata = *mut libc::c_void; | ||
| #[cfg(target_os = "netbsd")] | ||
| type type_of_udata = intptr_t; | ||
| #[cfg(target_os = "netbsd")] | ||
| type type_of_event_filter = u32; | ||
@@ -368,3 +363,3 @@ #[cfg(not(target_os = "netbsd"))] | ||
| data: data as _, | ||
| udata: udata as type_of_udata, | ||
| udata: udata as *mut libc::c_void, | ||
| ..unsafe { mem::zeroed() } | ||
@@ -461,3 +456,3 @@ }, | ||
| ev.kevent.data = 0; | ||
| ev.kevent.udata = udata as type_of_udata; | ||
| ev.kevent.udata = udata as *mut libc::c_void; | ||
| } |
@@ -104,3 +104,3 @@ use crate::errno::Errno; | ||
| impl AsFd for EventFd { | ||
| fn as_fd(&self) -> BorrowedFd { | ||
| fn as_fd(&self) -> BorrowedFd<'_> { | ||
| self.0.as_fd() | ||
@@ -107,0 +107,0 @@ } |
@@ -232,3 +232,3 @@ //! Monitoring API for filesystem events. | ||
| /// overflow occured. | ||
| pub fn fd(&self) -> Option<BorrowedFd> { | ||
| pub fn fd(&self) -> Option<BorrowedFd<'_>> { | ||
| if self.0.fd == libc::FAN_NOFD { | ||
@@ -447,2 +447,2 @@ None | ||
| } | ||
| } | ||
| } |
+10
-10
@@ -57,30 +57,30 @@ //! Interfaces for managing memory-backed files. | ||
| /// [`memfd_create(2)`]: https://man7.org/linux/man-pages/man2/memfd_create.2.html | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_1MB; | ||
| /// hugetlb size of 2MB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_2MB; | ||
| /// hugetlb size of 8MB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_8MB; | ||
| /// hugetlb size of 16MB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_16MB; | ||
| /// hugetlb size of 32MB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_32MB; | ||
| /// hugetlb size of 256MB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_256MB; | ||
| /// hugetlb size of 512MB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_512MB; | ||
| /// hugetlb size of 1GB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_1GB; | ||
| /// hugetlb size of 2GB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_2GB; | ||
| /// hugetlb size of 16GB. | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| MFD_HUGE_16GB; | ||
@@ -87,0 +87,0 @@ } |
+15
-2
@@ -558,5 +558,18 @@ //! Memory management declarations. | ||
| ) -> Result<()> { | ||
| let ptr = { | ||
| // The AIX signature of 'madvise()' differs from the POSIX specification, | ||
| // which expects 'void *' as the type of the 'addr' argument, whereas AIX uses | ||
| // 'caddr_t' (i.e., 'char *'). | ||
| #[cfg(target_os = "aix")] | ||
| { | ||
| addr.as_ptr() as *mut u8 | ||
| } | ||
| #[cfg(not(target_os = "aix"))] | ||
| { | ||
| addr.as_ptr() | ||
| } | ||
| }; | ||
| unsafe { | ||
| Errno::result(libc::madvise(addr.as_ptr(), length, advise as i32)) | ||
| .map(drop) | ||
| Errno::result(libc::madvise(ptr, length, advise as i32)).map(drop) | ||
| } | ||
@@ -563,0 +576,0 @@ } |
+1
-1
@@ -99,3 +99,3 @@ //! Mostly platform-specific functionality | ||
| target_os = "fuchsia", | ||
| solarish, | ||
| target_os = "solaris", | ||
| target_os = "haiku" | ||
@@ -102,0 +102,0 @@ )))] |
@@ -57,3 +57,4 @@ //! Process execution domains | ||
| /// | ||
| /// ``` | ||
| #[cfg_attr(any(qemu, target_arch = "aarch64"), doc = " ```no_run")] | ||
| #[cfg_attr(not(any(qemu, target_arch = "aarch64")), doc = " ```")] | ||
| /// # use nix::sys::personality::{self, Persona}; | ||
@@ -82,6 +83,6 @@ /// let pers = personality::get().unwrap(); | ||
| /// | ||
| // Disable test on aarch64 until we know why it fails. | ||
| // Disable test on aarch64 and with QEMU. seccomp interference is suspected. | ||
| // https://github.com/nix-rust/nix/issues/2060 | ||
| #[cfg_attr(target_arch = "aarch64", doc = " ```no_run")] | ||
| #[cfg_attr(not(target_arch = "aarch64"), doc = " ```")] | ||
| #[cfg_attr(any(qemu, target_arch = "aarch64"), doc = " ```no_run")] | ||
| #[cfg_attr(not(any(qemu, target_arch = "aarch64")), doc = " ```")] | ||
| /// # use nix::sys::personality::{self, Persona}; | ||
@@ -88,0 +89,0 @@ /// let mut pers = personality::get().unwrap(); |
@@ -507,3 +507,3 @@ //! For detailed description of the ptrace requests, consult `man ptrace`. | ||
| libc::pid_t::from(pid), | ||
| ptr::null_mut::<T>(), | ||
| std::mem::size_of::<T>(), | ||
| data.as_mut_ptr(), | ||
@@ -510,0 +510,0 @@ ) |
@@ -22,2 +22,3 @@ //! Configure the process resource limits. | ||
| target_os = "aix", | ||
| target_os = "illumos", | ||
| all(target_os = "linux", not(target_env = "gnu")), | ||
@@ -54,2 +55,3 @@ target_os = "cygwin" | ||
| target_os = "aix", | ||
| target_os = "illumos", | ||
| all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc"))), | ||
@@ -56,0 +58,0 @@ target_os = "cygwin" |
@@ -110,3 +110,3 @@ //! Portably monitor a group of file descriptors for readiness. | ||
| #[inline] | ||
| pub fn fds(&self, highest: Option<RawFd>) -> Fds { | ||
| pub fn fds(&self, highest: Option<RawFd>) -> Fds<'_, '_> { | ||
| Fds { | ||
@@ -113,0 +113,0 @@ set: self, |
@@ -756,3 +756,3 @@ //! Operating system signals. | ||
| /// A signal handler. | ||
| #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] | ||
| #[derive(Clone, Copy, Debug, Hash)] | ||
| pub enum SigHandler { | ||
@@ -933,3 +933,3 @@ /// Default signal handling. | ||
| /// | ||
| /// Returns [`Error(Errno::EOPNOTSUPP)`] if `handler` is | ||
| /// Returns [`Error(Errno::EOPNOTSUPP)`](Errno::EOPNOTSUPP) if `handler` is | ||
| /// [`SigAction`][SigActionStruct]. Use [`sigaction`][SigActionFn] instead. | ||
@@ -1040,3 +1040,3 @@ /// | ||
| /// * `signal` - Signal to send. If `None`, error checking is performed | ||
| /// but no signal is actually sent. | ||
| /// but no signal is actually sent. | ||
| /// | ||
@@ -1043,0 +1043,0 @@ /// See Also |
@@ -149,3 +149,3 @@ //! Interface for the `signalfd` syscall. | ||
| impl AsFd for SignalFd { | ||
| fn as_fd(&self) -> BorrowedFd { | ||
| fn as_fd(&self) -> BorrowedFd<'_> { | ||
| self.0.as_fd() | ||
@@ -152,0 +152,0 @@ } |
@@ -566,2 +566,3 @@ //! Socket options as used by `setsockopt` and `getsockopt`. | ||
| #[cfg(feature = "net")] | ||
| #[cfg(not(target_env = "uclibc"))] | ||
| sockopt_impl!( | ||
@@ -1124,3 +1125,3 @@ #[cfg_attr(docsrs, doc(cfg(feature = "net")))] | ||
| ); | ||
| #[cfg(target_os = "linux")] | ||
| #[cfg(linux_android)] | ||
| #[cfg(feature = "net")] | ||
@@ -1137,3 +1138,3 @@ sockopt_impl!( | ||
| ); | ||
| #[cfg(target_os = "linux")] | ||
| #[cfg(linux_android)] | ||
| #[cfg(feature = "net")] | ||
@@ -1249,3 +1250,6 @@ sockopt_impl!( | ||
| ); | ||
| #[cfg(any(linux_android, target_os = "freebsd"))] | ||
| #[cfg(any( | ||
| all(linux_android, not(target_env = "uclibc")), | ||
| target_os = "freebsd" | ||
| ))] | ||
| #[cfg(feature = "net")] | ||
@@ -1271,3 +1275,6 @@ sockopt_impl!( | ||
| ); | ||
| #[cfg(any(linux_android, apple_targets))] | ||
| #[cfg(any( | ||
| all(linux_android, not(target_env = "uclibc")), | ||
| apple_targets | ||
| ))] | ||
| sockopt_impl!( | ||
@@ -1963,3 +1970,3 @@ /// Set "don't fragment packet" flag on the IPv6 packet. | ||
| impl<'a> Set<'a, OsString> for SetOsString<'a> { | ||
| fn new(val: &OsString) -> SetOsString { | ||
| fn new(val: &OsString) -> SetOsString<'_> { | ||
| SetOsString { | ||
@@ -1981,2 +1988,3 @@ val: val.as_os_str(), | ||
| #[cfg(apple_targets)] | ||
| #[cfg(feature = "net")] | ||
| struct GetCString<T: AsMut<[u8]>> { | ||
@@ -1988,2 +1996,3 @@ len: socklen_t, | ||
| #[cfg(apple_targets)] | ||
| #[cfg(feature = "net")] | ||
| impl<T: AsMut<[u8]>> Get<CString> for GetCString<T> { | ||
@@ -1990,0 +1999,0 @@ fn uninit() -> Self { |
+12
-1
@@ -181,3 +181,3 @@ //! An interface for controlling asynchronous communication ports | ||
| /// safety. | ||
| pub(crate) fn get_libc_termios(&self) -> Ref<libc::termios> { | ||
| pub(crate) fn get_libc_termios(&self) -> Ref<'_, libc::termios> { | ||
| { | ||
@@ -508,4 +508,15 @@ let mut termios = self.inner.borrow_mut(); | ||
| #[cfg(any(linux_android, | ||
| target_os = "aix", | ||
| target_os = "cygwin", | ||
| target_os = "fuchsia", | ||
| target_os = "haiku", | ||
| target_os = "hurd", | ||
| target_os = "nto", | ||
| target_os = "redox", | ||
| solarish, | ||
| apple_targets))] | ||
| OFILL as tcflag_t; | ||
| #[cfg(any(linux_android, | ||
| target_os = "haiku", | ||
| apple_targets))] | ||
| NL0 as tcflag_t; | ||
@@ -512,0 +523,0 @@ #[cfg(any(linux_android, |
+8
-0
@@ -627,2 +627,6 @@ #[cfg_attr( | ||
| #[cfg_attr( | ||
| any(target_env = "musl", target_env = "ohos"), | ||
| allow(deprecated) | ||
| )] // https://github.com/rust-lang/libc/issues/1848 | ||
| fn micros_mod_sec(&self) -> suseconds_t { | ||
@@ -644,2 +648,6 @@ if self.tv_sec() < 0 && self.tv_usec() > 0 { | ||
| #[cfg_attr( | ||
| any(target_env = "musl", target_env = "ohos"), | ||
| allow(deprecated) | ||
| )] // https://github.com/rust-lang/libc/issues/1848 | ||
| pub const fn tv_usec(&self) -> suseconds_t { | ||
@@ -646,0 +654,0 @@ self.0.tv_usec |
@@ -114,3 +114,3 @@ use cfg_if::cfg_if; | ||
| cfg_if! { | ||
| if #[cfg(target_os = "linux")] { | ||
| if #[cfg(linux_android)] { | ||
| #[macro_export] macro_rules! require_kernel_version { | ||
@@ -117,0 +117,0 @@ ($name:expr, $version_requirement:expr) => { |
@@ -73,11 +73,7 @@ use std::{ | ||
| fn error() { | ||
| use std::mem; | ||
| const INITIAL: &[u8] = b"abcdef123456"; | ||
| // Create an invalid AioFsyncMode | ||
| let mode = unsafe { mem::transmute::<i32, AioFsyncMode>(666) }; | ||
| let mut f = tempfile().unwrap(); | ||
| f.write_all(INITIAL).unwrap(); | ||
| let mode = AioFsyncMode::O_SYNC; | ||
| // Operate on an invalid file descriptor. Should get EBADF | ||
| let fd = unsafe { BorrowedFd::borrow_raw(i32::MAX) }; | ||
| let mut aiof = | ||
| Box::pin(AioFsync::new(f.as_fd(), mode, 0, SigevNotify::SigevNone)); | ||
| Box::pin(AioFsync::new(fd, mode, 0, SigevNotify::SigevNone)); | ||
| let err = aiof.as_mut().submit(); | ||
@@ -84,0 +80,0 @@ err.expect_err("assertion failed"); |
+11
-20
@@ -115,20 +115,14 @@ use nix::errno::Errno; | ||
| raise(Signal::SIGINT).unwrap(); | ||
| assert_eq!( | ||
| unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(), | ||
| SigHandler::SigIgn | ||
| ); | ||
| let h = unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(); | ||
| assert!(matches!(h, SigHandler::SigIgn)); | ||
| let handler = SigHandler::Handler(test_sigaction_handler); | ||
| assert_eq!( | ||
| unsafe { signal(Signal::SIGINT, handler) }.unwrap(), | ||
| SigHandler::SigDfl | ||
| ); | ||
| let h = unsafe { signal(Signal::SIGINT, handler) }.unwrap(); | ||
| assert!(matches!(h, SigHandler::SigDfl)); | ||
| raise(Signal::SIGINT).unwrap(); | ||
| assert!(SIGNALED.load(Ordering::Relaxed)); | ||
| let h = unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(); | ||
| #[cfg(not(solarish))] | ||
| assert_eq!( | ||
| unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(), | ||
| handler | ||
| ); | ||
| assert!(matches!(h, SigHandler::Handler(_))); | ||
@@ -138,6 +132,3 @@ // System V based OSes (e.g. illumos and Solaris) always resets the | ||
| #[cfg(solarish)] | ||
| assert_eq!( | ||
| unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(), | ||
| SigHandler::SigDfl | ||
| ); | ||
| assert!(matches!(h, SigHandler::SigDfl)); | ||
@@ -312,3 +303,3 @@ // Restore default signal handler | ||
| ); | ||
| assert_eq!(action_sig.handler(), handler_sig); | ||
| assert!(matches!(action_sig.handler(), SigHandler::Handler(_))); | ||
@@ -321,9 +312,9 @@ mask = action_sig.mask(); | ||
| let action_act = SigAction::new(handler_act, flags, mask); | ||
| assert_eq!(action_act.handler(), handler_act); | ||
| assert!(matches!(action_act.handler(), SigHandler::SigAction(_))); | ||
| let action_dfl = SigAction::new(SigHandler::SigDfl, flags, mask); | ||
| assert_eq!(action_dfl.handler(), SigHandler::SigDfl); | ||
| assert!(matches!(action_dfl.handler(), SigHandler::SigDfl)); | ||
| let action_ign = SigAction::new(SigHandler::SigIgn, flags, mask); | ||
| assert_eq!(action_ign.handler(), SigHandler::SigIgn); | ||
| assert!(matches!(action_ign.handler(), SigHandler::SigIgn)); | ||
| }) | ||
@@ -330,0 +321,0 @@ .join() |
@@ -504,3 +504,3 @@ #[cfg(linux_android)] | ||
| #[test] | ||
| #[cfg(any(linux_android, apple_targets))] | ||
| #[cfg(any(all(linux_android, not(target_env = "uclibc")), apple_targets))] | ||
| // Disable the test under emulation because it fails in Cirrus-CI. Lack | ||
@@ -700,3 +700,3 @@ // of QEMU support is suspected. | ||
| #[test] | ||
| #[cfg(linux_android)] | ||
| #[cfg(all(linux_android, not(target_env = "uclibc")))] | ||
| // Disable the test under emulation because it fails with ENOPROTOOPT in CI | ||
@@ -703,0 +703,0 @@ // on cross target. Lack of QEMU support is suspected. |
@@ -544,9 +544,10 @@ #[cfg(not(target_os = "redox"))] | ||
| } | ||
| Err(Errno::EINVAL) => { | ||
| // POSIX requires posix_fallocate to return EINVAL both for | ||
| // invalid arguments (i.e. len < 0) and if the operation is not | ||
| // supported by the file system. | ||
| // There's no way to tell for sure whether the file system | ||
| // supports posix_fallocate, so we must pass the test if it | ||
| // returns EINVAL. | ||
| Err(Errno::ENOTSUP) | Err(Errno::EINVAL) => { | ||
| // POSIX 1003.1-2024 Issue 8 specified ENOTSUP for "the file | ||
| // system does not support this operation", so Nix should accept | ||
| // that error code and pass the test. | ||
| // But older POSIX required posix_fallocate to return EINVAL | ||
| // both for invalid arguments (i.e. len < 0) and if the | ||
| // operation is not supported by the file system. So we must | ||
| // also pass the test if it returns EINVAL. | ||
| } | ||
@@ -553,0 +554,0 @@ _ => res.unwrap(), |
@@ -162,6 +162,6 @@ use std::io::prelude::*; | ||
| let header_strings = | ||
| vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"]; | ||
| ["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"]; | ||
| let body = "Xabcdef123456"; | ||
| let body_offset = 1; | ||
| let trailer_strings = vec!["\n", "Served by Make Believe\n"]; | ||
| let trailer_strings = ["\n", "Served by Make Believe\n"]; | ||
@@ -199,3 +199,3 @@ // Write the body to a file | ||
| // Verify the message that was sent | ||
| assert_eq!(bytes_written as usize, expected_string.as_bytes().len()); | ||
| assert_eq!(bytes_written as usize, expected_string.len()); | ||
@@ -263,3 +263,3 @@ let mut read_string = String::new(); | ||
| // Verify the message that was sent | ||
| assert_eq!(bytes_written, expected_string.as_bytes().len()); | ||
| assert_eq!(bytes_written, expected_string.len()); | ||
@@ -266,0 +266,0 @@ let mut read_string = String::new(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display