From fafba030c267bf73eff98808f2035cbefba8e160 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 27 Jun 2025 19:37:27 +0800 Subject: [PATCH] fix --- crates/utils/src/os/linux.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/crates/utils/src/os/linux.rs b/crates/utils/src/os/linux.rs index 7d0f4845..01399aaf 100644 --- a/crates/utils/src/os/linux.rs +++ b/crates/utils/src/os/linux.rs @@ -1,5 +1,5 @@ use nix::sys::stat::{self, stat}; -use nix::sys::statfs::{self, FsType, statfs}; +use nix::sys::statfs::{self, statfs, FsType}; use std::fs::File; use std::io::{self, BufRead, Error, ErrorKind}; use std::path::Path; @@ -19,10 +19,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(reserved) => reserved, None => { return Err(Error::other(format!( - "detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'", - bavail, - bfree, - p.as_ref().display() + "detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({p.as_ref().display()}). please run 'fsck'" ))); } }; @@ -31,10 +28,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(total) => total * bsize, None => { return Err(Error::other(format!( - "detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'", - reserved, - blocks, - p.as_ref().display() + "detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({p.as_ref().display()}). please run 'fsck'" ))); } }; @@ -44,10 +38,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(used) => used, None => { return Err(Error::other(format!( - "detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'", - free, - total, - p.as_ref().display() + "detected free space ({free}) > total drive space ({total}), fs corruption at ({p.as_ref().display()}). please run 'fsck'" ))); } }; @@ -101,7 +92,7 @@ pub fn same_disk(disk1: &str, disk2: &str) -> std::io::Result { } pub fn get_drive_stats(major: u32, minor: u32) -> std::io::Result { - read_drive_stats(&format!("/sys/dev/block/{}:{}/stat", major, minor)) + read_drive_stats(&format!("/sys/dev/block/{major}:{minor}/stat")) } fn read_drive_stats(stats_file: &str) -> std::io::Result { @@ -109,7 +100,7 @@ fn read_drive_stats(stats_file: &str) -> std::io::Result { if stats.len() < 11 { return Err(Error::new( ErrorKind::InvalidData, - format!("found invalid format while reading {}", stats_file), + format!("found invalid format while reading {stats_file}"), )); } let mut io_stats = IOStats { @@ -153,7 +144,7 @@ fn read_stat(file_name: &str) -> std::io::Result> { for token in line.split_whitespace() { let ui64: u64 = token .parse() - .map_err(|e| Error::new(ErrorKind::InvalidData, format!("failed to parse '{}' as u64: {}", token, e)))?; + .map_err(|e| Error::new(ErrorKind::InvalidData, format!("failed to parse '{token}' as u64: {e}")))?; stats.push(ui64); } }