From ad73dcc308c9295cb3b31c503d482c667436631a Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 5 Jun 2024 17:02:57 +0200 Subject: [PATCH] Update nix to 0.29 --- Cargo.lock | 46 +++++++++++++++---------------- Cargo.toml | 4 +-- printf/Cargo.toml | 2 +- src/common.rs | 2 +- src/fd_monitor.rs | 2 +- src/fds.rs | 13 ++++----- src/topic_monitor.rs | 2 +- src/universal_notifier/inotify.rs | 6 ++-- src/wutil/mod.rs | 2 +- 9 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76f107590..0fdea6d0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,12 +20,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -34,9 +28,9 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "cc" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" dependencies = [ "jobserver", "libc", @@ -49,6 +43,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "dashmap" version = "5.5.3" @@ -92,7 +92,7 @@ source = "git+https://github.com/fish-shell/fast-float-rust?branch=fish#9590c33a name = "fish" version = "0.1.0" dependencies = [ - "bitflags 2.5.0", + "bitflags", "cc", "errno", "fast-float", @@ -161,9 +161,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" @@ -204,13 +204,13 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nix" -version = "0.25.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "autocfg", - "bitflags 1.3.2", + "bitflags", "cfg-if", + "cfg_aliases", "libc", ] @@ -241,9 +241,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -343,9 +343,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -404,7 +404,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 2.5.0", + "bitflags", ] [[package]] @@ -470,9 +470,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -628,5 +628,5 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.66", ] diff --git a/Cargo.toml b/Cargo.toml index c849bc1e7..8849854cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,12 +26,12 @@ fast-float = { git = "https://github.com/fish-shell/fast-float-rust", branch="fi bitflags = "2.4.0" errno = "0.2.8" lazy_static = "1.4.0" -libc = "= 0.2.151" +libc = "0.2.155" # lru pulls in hashbrown by default, which uses a faster (though less DoS resistant) hashing algo. # disabling default features uses the stdlib instead, but it doubles the time to rewrite the history # files as of 22 April 2024. lru = "0.10.0" -nix = { version = "0.25.0", default-features = false, features = ["inotify", "resource", "fs"] } +nix = { version = "0.29.0", default-features = false, features = ["inotify", "resource", "fs"] } num-traits = "0.2.15" once_cell = "1.17.0" printf = { path = "./printf" } diff --git a/printf/Cargo.toml b/printf/Cargo.toml index 76519815f..d36402c14 100644 --- a/printf/Cargo.toml +++ b/printf/Cargo.toml @@ -4,5 +4,5 @@ edition = "2021" version = "0.1.0" [dependencies] -libc = "= 0.2.151" +libc = "0.2.155" widestring = "1.0.2" diff --git a/src/common.rs b/src/common.rs index 645678bac..7e800013e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1525,7 +1525,7 @@ pub fn write_loop(fd: &Fd, buf: &[u8]) -> std::io::Result { let fd = fd.as_raw_fd(); let mut total = 0; while total < buf.len() { - match nix::unistd::write(fd, &buf[total..]) { + match nix::unistd::write(unsafe { BorrowedFd::borrow_raw(fd) }, &buf[total..]) { Ok(written) => { total += written; } diff --git a/src/fd_monitor.rs b/src/fd_monitor.rs index dac3bda7a..b5bea9b89 100644 --- a/src/fd_monitor.rs +++ b/src/fd_monitor.rs @@ -120,7 +120,7 @@ impl FdEventSignaller { let mut ret; loop { let bytes = c.to_ne_bytes(); - ret = nix::unistd::write(self.write_fd(), &bytes); + ret = nix::unistd::write(unsafe { BorrowedFd::borrow_raw(self.write_fd()) }, &bytes); match ret { Ok(_) => break, diff --git a/src/fds.rs b/src/fds.rs index c7f5b13a4..a9953d0a4 100644 --- a/src/fds.rs +++ b/src/fds.rs @@ -40,7 +40,7 @@ impl Read for AutoCloseFd { impl Write for AutoCloseFd { fn write(&mut self, buf: &[u8]) -> std::io::Result { - nix::unistd::write(self.as_raw_fd(), buf).map_err(std::io::Error::from) + nix::unistd::write(self, buf).map_err(std::io::Error::from) } fn flush(&mut self) -> std::io::Result<()> { @@ -161,8 +161,8 @@ pub fn make_autoclose_pipes() -> nix::Result { } }; - let readp = unsafe { OwnedFd::from_raw_fd(pipes.0) }; - let writep = unsafe { OwnedFd::from_raw_fd(pipes.1) }; + let readp = pipes.0; + let writep = pipes.1; // Ensure our fds are out of the user range. let readp = heightenize_fd(readp, already_cloexec)?; @@ -271,17 +271,16 @@ mod o_search { /// where O_EXEC is 0x40000000. This is only on macOS 12.0+ or later; however /// prior macOS versions ignores O_EXEC so it is treated the same as O_RDONLY. #[cfg(target_os = "macos")] - pub const BEST_O_SEARCH: OFlag = - unsafe { OFlag::from_bits_unchecked(libc::O_DIRECTORY | 0x40000000) }; + pub const BEST_O_SEARCH: OFlag = OFlag::from_bits_truncate(libc::O_DIRECTORY | 0x40000000); /// On FreeBSD, we have O_SEARCH = 0x00040000. #[cfg(target_os = "freebsd")] - pub const BEST_O_SEARCH: OFlag = unsafe { OFlag::from_bits_unchecked(0x00040000) }; + pub const BEST_O_SEARCH: OFlag = OFlag::from_bits_truncate(0x00040000); /// On Linux we can use O_PATH, it has nearly the same semantics. we can use the fd for openat / fchdir, with only requiring /// x permission on the directory. #[cfg(any(target_os = "linux", target_os = "android"))] - pub const BEST_O_SEARCH: OFlag = unsafe { OFlag::from_bits_unchecked(libc::O_PATH) }; + pub const BEST_O_SEARCH: OFlag = OFlag::from_bits_truncate(libc::O_PATH); /// Fall back to O_RDONLY. #[cfg(not(any( diff --git a/src/topic_monitor.rs b/src/topic_monitor.rs index 42fc37878..cbb011e03 100644 --- a/src/topic_monitor.rs +++ b/src/topic_monitor.rs @@ -208,7 +208,7 @@ impl binary_semaphore_t { Self::Pipes(pipes) => { // Write exactly one byte. loop { - match unistd::write(pipes.write.as_raw_fd(), &[0]) { + match unistd::write(&pipes.write, &[0]) { Err(Errno::EINTR) => continue, Err(_) => self.die("write"), Ok(_) => break, diff --git a/src/universal_notifier/inotify.rs b/src/universal_notifier/inotify.rs index 50472d41f..95c45d348 100644 --- a/src/universal_notifier/inotify.rs +++ b/src/universal_notifier/inotify.rs @@ -5,7 +5,7 @@ use crate::wchar::prelude::*; use crate::wutil::{wbasename, wdirname}; use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify}; use std::ffi::OsString; -use std::os::fd::{AsRawFd, RawFd}; +use std::os::fd::{AsFd, AsRawFd, RawFd}; /// A notifier based on inotify. pub struct InotifyNotifier { @@ -50,13 +50,13 @@ impl UniversalNotifier for InotifyNotifier { // Returns the fd from which to watch for events. fn notification_fd(&self) -> Option { - Some(self.inotify.as_raw_fd()) + Some(self.inotify.as_fd().as_raw_fd()) } // The notification_fd is readable; drain it. Returns true if a notification is considered to // have been posted. fn notification_fd_became_readable(&self, fd: RawFd) -> bool { - assert_eq!(fd, self.inotify.as_raw_fd(), "unexpected fd"); + assert_eq!(fd, self.inotify.as_fd().as_raw_fd(), "unexpected fd"); let Ok(evts) = self.inotify.read_events() else { return false; }; diff --git a/src/wutil/mod.rs b/src/wutil/mod.rs index abb73978b..4778abeae 100644 --- a/src/wutil/mod.rs +++ b/src/wutil/mod.rs @@ -492,7 +492,7 @@ pub fn wrename(old_name: &wstr, new_name: &wstr) -> libc::c_int { } pub fn write_to_fd(input: &[u8], fd: RawFd) -> nix::Result { - nix::unistd::write(fd, input) + nix::unistd::write(unsafe { BorrowedFd::borrow_raw(fd) }, input) } /// Write a wide string to a file descriptor. This avoids doing any additional allocation.