From 2d2407abcdc12b4ac45ddc7e9d3561311edb403b Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Thu, 11 Jan 2024 09:25:55 +0000 Subject: [PATCH] Rework nix::unistd::ftruncate to use AsFd instead of AsRawFd nix::unistd::ftruncate from nix 0.27 requires the output argument to be AsFd instead of AsRawFd. Rework the function call. Signed-off-by: Christopher Obbard --- bmap-rs/src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bmap-rs/src/main.rs b/bmap-rs/src/main.rs index 5d1f3e6..c3b91ca 100644 --- a/bmap-rs/src/main.rs +++ b/bmap-rs/src/main.rs @@ -11,7 +11,7 @@ use std::ffi::OsStr; use std::fmt::Write; use std::fs::File; use std::io::Read; -use std::os::unix::io::AsRawFd; +use std::os::unix::io::AsFd; use std::path::{Path, PathBuf}; use tokio_util::compat::TokioAsyncReadCompatExt; @@ -173,10 +173,9 @@ fn setup_spinner() -> ProgressBar { pb } -fn setup_output(output: &T, bmap: &Bmap, metadata: std::fs::Metadata) -> Result<()> { +fn setup_output(output: &T, bmap: &Bmap, metadata: std::fs::Metadata) -> Result<()> { if metadata.is_file() { - ftruncate(output.as_raw_fd(), bmap.image_size() as i64) - .context("Failed to truncate file")?; + ftruncate(output.as_fd(), bmap.image_size() as i64).context("Failed to truncate file")?; } Ok(()) }