summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/io
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/io')
-rw-r--r--vendor/rustix/src/io/errno.rs25
-rw-r--r--vendor/rustix/src/io/ioctl.rs23
2 files changed, 19 insertions, 29 deletions
diff --git a/vendor/rustix/src/io/errno.rs b/vendor/rustix/src/io/errno.rs
index 7640d3111..2b72de005 100644
--- a/vendor/rustix/src/io/errno.rs
+++ b/vendor/rustix/src/io/errno.rs
@@ -12,31 +12,6 @@ use std::error;
/// A specialized [`Result`] type for `rustix` APIs.
pub type Result<T> = result::Result<T, Errno>;
-/// `errno`—An error code.
-///
-/// The error type for `rustix` APIs. This is similar to `std::io::Error`, but
-/// only holds an OS error code, and no extra error value.
-///
-/// # References
-/// - [POSIX]
-/// - [Linux]
-/// - [Winsock2]
-/// - [FreeBSD]
-/// - [NetBSD]
-/// - [OpenBSD]
-/// - [DragonFly BSD]
-/// - [illumos]
-/// - [glibc]
-///
-/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
-/// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
-/// [Winsock2]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
-/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
-/// [NetBSD]: https://man.netbsd.org/errno.2
-/// [OpenBSD]: https://man.openbsd.org/errno.2
-/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=errno&section=2
-/// [illumos]: https://illumos.org/man/3C/errno
-/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
pub use backend::io::errno::Errno;
impl Errno {
diff --git a/vendor/rustix/src/io/ioctl.rs b/vendor/rustix/src/io/ioctl.rs
index d9bfa1fb3..e85719a4d 100644
--- a/vendor/rustix/src/io/ioctl.rs
+++ b/vendor/rustix/src/io/ioctl.rs
@@ -6,7 +6,10 @@
//! Some ioctls, such as those related to filesystems, terminals, and
//! processes, live in other top-level API modules.
-use crate::{backend, io};
+#![allow(unsafe_code)]
+
+use crate::{backend, io, ioctl};
+use backend::c;
use backend::fd::AsFd;
/// `ioctl(fd, FIOCLEX, NULL)`—Set the close-on-exec flag.
@@ -26,7 +29,11 @@ use backend::fd::AsFd;
#[doc(alias = "FIOCLEX")]
#[doc(alias = "FD_CLOEXEC")]
pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
- backend::io::syscalls::ioctl_fioclex(fd.as_fd())
+ // SAFETY: FIOCLEX is a no-argument setter opcode.
+ unsafe {
+ let ctl = ioctl::NoArg::<ioctl::BadOpcode<{ c::FIOCLEX }>>::new();
+ ioctl::ioctl(fd, ctl)
+ }
}
/// `ioctl(fd, FIONBIO, &value)`—Enables or disables non-blocking mode.
@@ -42,7 +49,11 @@ pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
#[inline]
#[doc(alias = "FIONBIO")]
pub fn ioctl_fionbio<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
- backend::io::syscalls::ioctl_fionbio(fd.as_fd(), value)
+ // SAFETY: FIONBIO is a pointer setter opcode.
+ unsafe {
+ let ctl = ioctl::Setter::<ioctl::BadOpcode<{ c::FIONBIO }>, c::c_int>::new(value.into());
+ ioctl::ioctl(fd, ctl)
+ }
}
/// `ioctl(fd, FIONREAD)`—Returns the number of bytes ready to be read.
@@ -66,5 +77,9 @@ pub fn ioctl_fionbio<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
#[inline]
#[doc(alias = "FIONREAD")]
pub fn ioctl_fionread<Fd: AsFd>(fd: Fd) -> io::Result<u64> {
- backend::io::syscalls::ioctl_fionread(fd.as_fd())
+ // SAFETY: FIONREAD is a getter opcode that gets a c_int.
+ unsafe {
+ let ctl = ioctl::Getter::<ioctl::BadOpcode<{ c::FIONREAD }>, c::c_int>::new();
+ ioctl::ioctl(fd, ctl).map(|n| n as u64)
+ }
}