1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
This patch is based on the commit below, taken from
https://github.com/serialport/serialport-rs/pull/263
adapted for use in the Debian package by Peter Michael Green.
commit 90ab58e732d2660e3da7e4afceeb5a6c64161a61
Author: Paolo Barbolini <paolo.barbolini@m4ss.net>
Date: Wed Apr 30 09:22:22 2025 +0200
Upgrade `nix` to v0.30
Index: serialport/src/posix/tty.rs
===================================================================
--- serialport.orig/src/posix/tty.rs
+++ serialport/src/posix/tty.rs
@@ -111,7 +111,6 @@ impl TTYPort {
OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK | OFlag::O_CLOEXEC,
nix::sys::stat::Mode::empty(),
)?;
- let fd = unsafe { OwnedFd::from_raw_fd(fd) };
// Try to claim exclusive access to the port. This is performed even
// if the port will later be set as non-exclusive, in order to respect
@@ -158,7 +157,7 @@ impl TTYPort {
}
// clear O_NONBLOCK flag
- fcntl(fd.as_raw_fd(), F_SETFL(nix::fcntl::OFlag::empty()))?;
+ fcntl(fd.as_fd(), F_SETFL(nix::fcntl::OFlag::empty()))?;
// Configure the low-level port settings
let mut termios = termios::get_termios(fd.as_raw_fd())?;
@@ -308,7 +307,6 @@ impl TTYPort {
OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
nix::sys::stat::Mode::empty(),
)?;
- let fd = unsafe { OwnedFd::from_raw_fd(fd) };
// Set the port to a raw state. Using these ports will not work without this.
let mut termios = MaybeUninit::uninit();
@@ -322,7 +320,7 @@ impl TTYPort {
unsafe { crate::posix::tty::libc::tcsetattr(fd.as_raw_fd(), libc::TCSANOW, &termios) };
fcntl(
- fd.as_raw_fd(),
+ fd.as_fd(),
nix::fcntl::FcntlArg::F_SETFL(nix::fcntl::OFlag::empty()),
)?;
@@ -375,7 +373,7 @@ impl TTYPort {
/// This function returns an error if the serial port couldn't be cloned.
pub fn try_clone_native(&self) -> Result<TTYPort> {
let fd_cloned: i32 = fcntl(
- self.fd.as_raw_fd(),
+ self.fd.as_fd(),
nix::fcntl::F_DUPFD_CLOEXEC(self.fd.as_raw_fd()),
)?;
Ok(TTYPort {
@@ -446,7 +444,7 @@ impl io::Read for TTYPort {
return Err(io::Error::from(Error::from(e)));
}
- nix::unistd::read(self.fd.as_raw_fd(), buf).map_err(|e| io::Error::from(Error::from(e)))
+ nix::unistd::read(self.fd.as_fd(), buf).map_err(|e| io::Error::from(Error::from(e)))
}
}
Index: serialport/Cargo.toml
===================================================================
--- serialport.orig/Cargo.toml
+++ serialport/Cargo.toml
@@ -166,7 +166,7 @@ version = "0.1.3"
version = "2.4.0"
[target."cfg(unix)".dependencies.nix]
-version = "0.28"
+version = "0.30"
features = [
"fs",
"ioctl",
|