INNER CODE UNIT · Rust
open_kmsg_at_end
KernelSU-Next/KernelSU-Next · userspace/ksuinit/src/lib.rs:88
fn open_kmsg_at_end() -> Result<File> {
let mut last_error = None;
for path in ["/dev/kmsg", "/kmsg"] {
match OpenOptions::new()
.read(true)
.custom_flags(O_NONBLOCK)
.open(path)
{
Ok(mut file) => {
file.seek(SeekFrom::End(0))
.with_context(|| format!("Cannot seek {path} to end"))?;
log::info!("Reading kernel log from {path}");
return Ok(file);
}
Err(error) => {
last_error = Some((path, error));