mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-25 19:21:53 +00:00
Merge pull request #4441 from liubin/fix/refactor-reading-mountstat-log
agent: refactor reading file timing for debugging
This commit is contained in:
commit
db2a4d6cdf
@ -840,15 +840,13 @@ pub fn get_mount_fs_type_from_file(mount_file: &str, mount_point: &str) -> Resul
|
|||||||
return Err(anyhow!("Invalid mount point {}", mount_point));
|
return Err(anyhow!("Invalid mount point {}", mount_point));
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = File::open(mount_file)?;
|
let content = fs::read_to_string(mount_file)?;
|
||||||
let reader = BufReader::new(file);
|
|
||||||
|
|
||||||
let re = Regex::new(format!("device .+ mounted on {} with fstype (.+)", mount_point).as_str())?;
|
let re = Regex::new(format!("device .+ mounted on {} with fstype (.+)", mount_point).as_str())?;
|
||||||
|
|
||||||
// Read the file line by line using the lines() iterator from std::io::BufRead.
|
// Read the file line by line using the lines() iterator from std::io::BufRead.
|
||||||
for (_index, line) in reader.lines().enumerate() {
|
for (_index, line) in content.lines().enumerate() {
|
||||||
let line = line?;
|
let capes = match re.captures(line) {
|
||||||
let capes = match re.captures(line.as_str()) {
|
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
@ -861,7 +859,7 @@ pub fn get_mount_fs_type_from_file(mount_file: &str, mount_point: &str) -> Resul
|
|||||||
Err(anyhow!(
|
Err(anyhow!(
|
||||||
"failed to find FS type for mount point {}, mount file content: {:?}",
|
"failed to find FS type for mount point {}, mount file content: {:?}",
|
||||||
mount_point,
|
mount_point,
|
||||||
fs::read_to_string(mount_file)
|
content
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user