-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12186ff
commit 1e76d68
Showing
3 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::io::Read; | ||
use std::path::Path; | ||
|
||
use anyhow::{bail, Result}; | ||
|
||
use composefs_experiments::{fsverity::Sha256HashValue, repository::Repository}; | ||
|
||
fn parse_composefs_cmdline() -> Result<Sha256HashValue> { | ||
let mut cmdline = vec![]; | ||
let mut proc_cmdline = std::fs::File::open("/proc/cmdline")?; | ||
proc_cmdline.read_to_end(&mut cmdline)?; | ||
// TODO?: officially we need to understand quoting with double-quotes... | ||
for part in cmdline.split(|c| *c == b' ') { | ||
if let Some(digest) = part.strip_prefix(b"composefs=") { | ||
let mut value = [0; 32]; | ||
hex::decode_to_slice(digest, &mut value)?; | ||
return Ok(value); | ||
} | ||
} | ||
bail!("Unable to find composefs= cmdline parameter"); | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let repo = Repository::open_system()?; | ||
let image = parse_composefs_cmdline()?; | ||
repo.pivot_sysroot(&hex::encode(image), Path::new("/sysroot"))?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters