Skip to content

Commit 1a7ac13

Browse files
cgwaltersJohan-Liebert1
authored andcommitted
install: Use read_file from composefs-boot
Just reducing code here.
1 parent 1137bd3 commit 1a7ac13

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

crates/lib/src/install.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) mod osconfig;
1616

1717
use std::collections::HashMap;
1818
use std::fs::create_dir_all;
19-
use std::io::{Read, Write};
19+
use std::io::Write;
2020
use std::os::fd::{AsFd, AsRawFd};
2121
use std::os::unix::fs::symlink;
2222
use std::os::unix::process::CommandExt;
@@ -41,9 +41,9 @@ use cap_std_ext::cap_tempfile::TempDir;
4141
use cap_std_ext::cmdext::CapStdExtCommandExt;
4242
use cap_std_ext::prelude::CapStdExtDirExt;
4343
use clap::ValueEnum;
44+
use composefs_boot::bootloader::read_file;
4445
use fn_error_context::context;
4546
use ostree::gio;
46-
use ostree_ext::composefs::tree::RegularFile;
4747
use ostree_ext::composefs::{
4848
fsverity::{FsVerityHashValue, Sha256HashValue},
4949
repository::Repository as ComposefsRepository,
@@ -1547,24 +1547,6 @@ fn get_booted_bls() -> Result<BLSConfig> {
15471547
Err(anyhow::anyhow!("Booted BLS not found"))
15481548
}
15491549

1550-
pub fn read_file<ObjectID: FsVerityHashValue>(
1551-
file: &RegularFile<ObjectID>,
1552-
repo: &ComposefsRepository<ObjectID>,
1553-
) -> Result<Box<[u8]>> {
1554-
match file {
1555-
RegularFile::Inline(data) => Ok(data.clone()),
1556-
RegularFile::External(id, size) => {
1557-
let mut data = vec![];
1558-
std::fs::File::from(repo.open_object(id)?).read_to_end(&mut data)?;
1559-
ensure!(
1560-
*size == data.len() as u64,
1561-
"File content doesn't have the expected length"
1562-
);
1563-
Ok(data.into_boxed_slice())
1564-
}
1565-
}
1566-
}
1567-
15681550
pub(crate) enum BootSetupType<'a> {
15691551
/// For initial setup, i.e. install to-disk
15701552
Setup((&'a RootSetup, &'a State)),

0 commit comments

Comments
 (0)