Skip to content

Commit

Permalink
refactor: change type of module_name in function is_module_filename()…
Browse files Browse the repository at this point in the history
… to &Path
  • Loading branch information
Integral-Tech committed Jan 31, 2025
1 parent aad15e6 commit b590953
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/kernel/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::style::Symbol;
use std::{ffi::OsStr, path::Path};

/// Kernel module related command
#[derive(Debug)]
Expand Down Expand Up @@ -56,7 +57,7 @@ impl ModuleCommand {
match self {
Self::None => Command::new(String::from(""), "", &format!("Module: {module_name}"), Symbol::None),
Self::Load => Command::new(
if Self::is_module_filename(module_name) {
if Self::is_module_filename(Path::new(module_name)) {
format!("insmod {}", &module_name)
} else {
format!("modprobe {0} || insmod {0}.ko", &module_name)
Expand Down Expand Up @@ -114,8 +115,8 @@ impl ModuleCommand {
}

/// Check if module name is a filename with suffix 'ko'
pub fn is_module_filename(module_name: &str) -> bool {
module_name.ends_with(".ko")
pub fn is_module_filename(module_name: &Path) -> bool {
module_name.extension() == Some(OsStr::new("ko"))
}
}

Expand Down

0 comments on commit b590953

Please sign in to comment.