Compare commits

...

6 commits
v0.1.5 ... main

Author SHA1 Message Date
bc090fa9b2
Remove redundant log statement in echo1 and add confirmation log in reset_device
All checks were successful
/ release (nightly) (push) Successful in 1m51s
2025-05-21 13:53:13 +02:00
86cf230f21
Bump package version to 0.2.1 in Cargo.toml
All checks were successful
/ release (nightly) (push) Successful in 2m20s
2025-05-14 22:22:29 +02:00
fefcbe4373
Remove debug statement from manage_line function
All checks were successful
/ release (nightly) (push) Successful in 2m9s
2025-05-14 22:19:06 +02:00
f7c9605f26
Update package version to 0.2.0 in Cargo.toml
All checks were successful
/ release (nightly) (push) Successful in 34m39s
2025-05-14 18:43:03 +02:00
f4374459dd
Refactor kernel message file handling to improve readability and add debugging output 2025-05-14 18:42:48 +02:00
89be5b3542
Use environment variable for kernel message file path 2025-05-14 17:58:41 +02:00
2 changed files with 10 additions and 3 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "phenix"
description = "Utility to restart PCIe devices when link is lost."
version = "0.1.5"
version = "0.2.1"
edition = "2024"
license = "GPL-3.0-or-later"
repository="https://code.edgarpierre.fr/edpibu/phenix"

View file

@ -1,13 +1,20 @@
#![feature(file_buffered)]
use std::env;
use std::fs::File;
use std::io::BufRead;
use std::io::Write;
use std::io::Seek;
use std::io::SeekFrom;
fn main() {
println!("Reading kernel messages...");
let kmsg_file = File::open_buffered("/dev/kmsg").expect("Failed to open /dev/kmsg");
let mut kmsg_file =
File::open_buffered(env::var("PHENIX_KMSG").unwrap_or(String::from("/dev/kmsg")))
.expect("Failed to open /dev/kmsg");
kmsg_file.seek(SeekFrom::End(0)).expect("Failed to seek to end");
let lines = kmsg_file.lines();
for line in lines {
match line {
@ -34,6 +41,7 @@ fn manage_line(line: String) {
fn reset_device(id: &str) {
println!("Resetting {id}");
echo1(rm_file_path(&id));
println!("Removed device {id}");
echo1(String::from("/sys/bus/pci/rescan"));
println!("Rescanned PCI bus");
}
@ -45,7 +53,6 @@ fn echo1(path: String) {
Ok(mut file) => {
file.write_all(b"1")
.expect("Failed to write to remove file");
println!("Removed device {path}");
}
}
}