Skip to content

Commit 06693d6

Browse files
committed
install: Use read_file from composefs-boot
Just reducing code here.
1 parent b091e0f commit 06693d6

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
@@ -15,7 +15,7 @@ pub(crate) mod osconfig;
1515

1616
use std::collections::HashMap;
1717
use std::fs::create_dir_all;
18-
use std::io::{Read, Write};
18+
use std::io::Write;
1919
use std::os::fd::{AsFd, AsRawFd};
2020
use std::os::unix::fs::symlink;
2121
use std::os::unix::process::CommandExt;
@@ -40,9 +40,9 @@ use cap_std_ext::cmdext::CapStdExtCommandExt;
4040
use cap_std_ext::prelude::CapStdExtDirExt;
4141
use chrono::prelude::*;
4242
use clap::ValueEnum;
43+
use composefs_boot::bootloader::read_file;
4344
use fn_error_context::context;
4445
use ostree::gio;
45-
use ostree_ext::composefs::tree::RegularFile;
4646
use ostree_ext::composefs::{
4747
fsverity::{FsVerityHashValue, Sha256HashValue},
4848
repository::Repository as ComposefsRepository,
@@ -1591,24 +1591,6 @@ fn get_booted_bls() -> Result<BLSConfig> {
15911591
Err(anyhow::anyhow!("Booted BLS not found"))
15921592
}
15931593

1594-
pub fn read_file<ObjectID: FsVerityHashValue>(
1595-
file: &RegularFile<ObjectID>,
1596-
repo: &ComposefsRepository<ObjectID>,
1597-
) -> Result<Box<[u8]>> {
1598-
match file {
1599-
RegularFile::Inline(data) => Ok(data.clone()),
1600-
RegularFile::External(id, size) => {
1601-
let mut data = vec![];
1602-
std::fs::File::from(repo.open_object(id)?).read_to_end(&mut data)?;
1603-
ensure!(
1604-
*size == data.len() as u64,
1605-
"File content doesn't have the expected length"
1606-
);
1607-
Ok(data.into_boxed_slice())
1608-
}
1609-
}
1610-
}
1611-
16121594
pub(crate) enum BootSetupType<'a> {
16131595
/// For initial setup, i.e. install to-disk
16141596
Setup((&'a RootSetup, &'a State)),

0 commit comments

Comments
 (0)