Files
initrd/src/cmd/bootstrap.rs
Mikaël Cluseau 8fcd2d6684 migrate to rust
2025-07-03 15:58:32 +02:00

20 lines
447 B
Rust
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use eyre::Result;
use tokio::{fs, io, io::AsyncWriteExt};
pub async fn run() -> Result<()> {
let mut input = io::stdin();
let mut out = fs::File::create("/bootstrap.tar.part").await?;
let n = io::copy(&mut input, &mut out).await?;
out.flush().await?;
drop(out);
eprintln!("copied {n} bytes");
fs::rename("/bootstrap.tar.part", "/bootstrap.tar").await?;
eprintln!("/bootstrap.tar ready to use");
Ok(())
}