boot-tree: portable unit, dracut and mkinitcpio hooks, self-quieting console, minimal NixOS module
This commit is contained in:
1 parent
2b1447965a
commit
1482d4437a
13 files changed
+208
-121
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use std::fs;
|
||||
|
||||
use rustix::{
|
||||
io::Errno,
|
||||
ioctl::{Getter, IntegerSetter, Opcode, ioctl},
|
||||
@@ -9,6 +11,27 @@ const VT_GETSTATE: Opcode = 0x5603;
|
||||
const VT_ACTIVATE: Opcode = 0x5606;
|
||||
const VT_WAITACTIVE: Opcode = 0x5607;
|
||||
const VIRTUAL_TERMINAL_PREFIX: &str = "/dev/tty";
|
||||
const KERNEL_PRINTK: &str = "/proc/sys/kernel/printk";
|
||||
const ALERTS_ONLY: &str = "1";
|
||||
|
||||
pub struct QuietKernelConsole {
|
||||
previous_level: String,
|
||||
}
|
||||
|
||||
impl QuietKernelConsole {
|
||||
pub fn take() -> Option<Self> {
|
||||
let levels = fs::read_to_string(KERNEL_PRINTK).ok()?;
|
||||
let previous_level = levels.split_whitespace().next()?.to_owned();
|
||||
fs::write(KERNEL_PRINTK, ALERTS_ONLY).ok()?;
|
||||
Some(Self { previous_level })
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for QuietKernelConsole {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::write(KERNEL_PRINTK, &self.previous_level);
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct VtState {
|
||||
|
||||
Reference in new issue
Block a user