Fix NFS export parsing to handle both inline and continuation formats
All checks were successful
Build and Release / build-and-release (push) Successful in 1m20s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m20s
Support exportfs output where network info appears on same line as path (e.g. /srv/media/tv 192.168.0.0/16(...)) in addition to continuation line format. Ensures all NFS exports are detected correctly.
This commit is contained in:
@@ -1067,15 +1067,36 @@ impl SystemdCollector {
|
||||
}
|
||||
|
||||
if trimmed.starts_with('/') {
|
||||
// New export path line
|
||||
current_path = trimmed.split_whitespace().next().map(|s| s.to_string());
|
||||
// Export path line - may have network on same line or continuation
|
||||
let parts: Vec<&str> = trimmed.splitn(2, char::is_whitespace).collect();
|
||||
let path = parts[0].to_string();
|
||||
current_path = Some(path.clone());
|
||||
|
||||
// Check if network info is on the same line
|
||||
if parts.len() > 1 {
|
||||
let rest = parts[1].trim();
|
||||
if let Some(paren_pos) = rest.find('(') {
|
||||
let network = rest[..paren_pos].trim();
|
||||
|
||||
if let Some(end_paren) = rest.find(')') {
|
||||
let options = &rest[paren_pos+1..end_paren];
|
||||
let mode = if options.contains(",rw,") || options.ends_with(",rw") {
|
||||
"rw"
|
||||
} else {
|
||||
"ro"
|
||||
};
|
||||
|
||||
exports_map.entry(path)
|
||||
.or_insert_with(Vec::new)
|
||||
.push((network.to_string(), mode.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let Some(ref path) = current_path {
|
||||
// Continuation line with network and options
|
||||
// Format: "192.168.0.0/16(options...)"
|
||||
if let Some(paren_pos) = trimmed.find('(') {
|
||||
let network = trimmed[..paren_pos].trim();
|
||||
|
||||
// Extract ro/rw from options
|
||||
if let Some(end_paren) = trimmed.find(')') {
|
||||
let options = &trimmed[paren_pos+1..end_paren];
|
||||
let mode = if options.contains(",rw,") || options.ends_with(",rw") {
|
||||
|
||||
Reference in New Issue
Block a user