Skip to content

Commit 212f3e9

Browse files
cgwaltersjeckersb
authored andcommitted
install: Use read_file from composefs-boot
Just reducing code here.
1 parent deabf43 commit 212f3e9

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;
@@ -42,9 +42,9 @@ use cap_std_ext::cap_tempfile::TempDir;
4242
use cap_std_ext::cmdext::CapStdExtCommandExt;
4343
use cap_std_ext::prelude::CapStdExtDirExt;
4444
use clap::ValueEnum;
45+
use composefs_boot::bootloader::read_file;
4546
use fn_error_context::context;
4647
use ostree::gio;
47-
use ostree_ext::composefs::tree::RegularFile;
4848
use ostree_ext::composefs::{
4949
fsverity::{FsVerityHashValue, Sha256HashValue},
5050
repository::Repository as ComposefsRepository,
@@ -1571,24 +1571,6 @@ fn get_booted_bls() -> Result<BLSConfig> {
15711571
Err(anyhow::anyhow!("Booted BLS not found"))
15721572
}
15731573

1574-
pub fn read_file<ObjectID: FsVerityHashValue>(
1575-
file: &RegularFile<ObjectID>,
1576-
repo: &ComposefsRepository<ObjectID>,
1577-
) -> Result<Box<[u8]>> {
1578-
match file {
1579-
RegularFile::Inline(data) => Ok(data.clone()),
1580-
RegularFile::External(id, size) => {
1581-
let mut data = vec![];
1582-
std::fs::File::from(repo.open_object(id)?).read_to_end(&mut data)?;
1583-
ensure!(
1584-
*size == data.len() as u64,
1585-
"File content doesn't have the expected length"
1586-
);
1587-
Ok(data.into_boxed_slice())
1588-
}
1589-
}
1590-
}
1591-
15921574
pub(crate) enum BootSetupType<'a> {
15931575
/// For initial setup, i.e. install to-disk
15941576
Setup((&'a RootSetup, &'a State)),

0 commit comments

Comments
 (0)