b9874d0941
Add redbear-usb-storage-check in-guest binary that validates USB mass storage read and write I/O: discovers /scheme/disk/ devices, writes a test pattern to sector 2048, reads it back, verifies match, restores original content. Updates test-usb-storage-qemu.sh with write-proof verification step. Includes all accumulated Red Bear OS work: kernel patches, relibc patches, driver infrastructure, DRM/GPU, KDE recipes, firmware, validation tooling, build system hardening, and documentation.
27 lines
978 B
Rust
27 lines
978 B
Rust
use anyhow::{Context, Result};
|
|
|
|
// TODO: Do not use target architecture to distinguish these.
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
mod x86;
|
|
|
|
/// The rtc driver runs only once, being perhaps the first of all processes that init starts (since
|
|
/// early logging benefits from knowing the time, even though this can be adjusted later once the
|
|
/// time is known). The sole job of `rtcd` is to read from the hardware real-time clock, and then
|
|
/// write the offset to the kernel.
|
|
|
|
fn main() -> Result<()> {
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
{
|
|
common::acquire_port_io_rights().context("failed to set iopl")?;
|
|
|
|
let time_s = self::x86::get_time();
|
|
let time_ns = u128::from(time_s) * 1_000_000_000;
|
|
|
|
std::fs::write("/scheme/sys/update_time_offset", &time_ns.to_ne_bytes())
|
|
.context("failed to write to time offset")?;
|
|
}
|
|
// TODO: aarch64 is currently handled in the kernel
|
|
|
|
Ok(())
|
|
}
|