Skip to content

Commit a6eeb11

Browse files
committed
ignore Read-only file system error on sysctl set
Signed-off-by: Peter Hunt <[email protected]>
1 parent eb4251b commit a6eeb11

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/network/core_utils.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,18 @@ impl CoreUtils {
282282
}
283283
Err(e) => return Err(e),
284284
}
285-
ctl.set_value_string(val)
285+
let result = ctl.set_value_string(val);
286+
// if we have a read only /proc we ignore it as well
287+
match result {
288+
Ok(_) => result,
289+
Err(SysctlError::IoError(e)) => {
290+
if e.raw_os_error() == Some(libc::EROFS) {
291+
return Ok(String::from(""));
292+
}
293+
return Err(e.into());
294+
},
295+
Err(err) => return Err(err),
296+
}
286297
}
287298
}
288299

@@ -433,9 +444,6 @@ pub fn disable_ipv6_autoconf(if_name: &str) -> NetavarkResult<()> {
433444
// just ignore that case
434445
}
435446

436-
// if we have a read only /proc we ignore it as well
437-
SysctlError::IoError(ref e) if e.raw_os_error() == Some(libc::EROFS) => {}
438-
439447
_ => {
440448
return Err(NetavarkError::wrap(
441449
"failed to set autoconf sysctl",

0 commit comments

Comments
 (0)