From 06693d61cebbd05088c054ea545115c870140a18 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 13 Aug 2025 19:34:52 +0200 Subject: [PATCH] install: Use read_file from composefs-boot Just reducing code here. --- crates/lib/src/install.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/crates/lib/src/install.rs b/crates/lib/src/install.rs index 3b07ed99..8116db76 100644 --- a/crates/lib/src/install.rs +++ b/crates/lib/src/install.rs @@ -15,7 +15,7 @@ pub(crate) mod osconfig; use std::collections::HashMap; use std::fs::create_dir_all; -use std::io::{Read, Write}; +use std::io::Write; use std::os::fd::{AsFd, AsRawFd}; use std::os::unix::fs::symlink; use std::os::unix::process::CommandExt; @@ -40,9 +40,9 @@ use cap_std_ext::cmdext::CapStdExtCommandExt; use cap_std_ext::prelude::CapStdExtDirExt; use chrono::prelude::*; use clap::ValueEnum; +use composefs_boot::bootloader::read_file; use fn_error_context::context; use ostree::gio; -use ostree_ext::composefs::tree::RegularFile; use ostree_ext::composefs::{ fsverity::{FsVerityHashValue, Sha256HashValue}, repository::Repository as ComposefsRepository, @@ -1591,24 +1591,6 @@ fn get_booted_bls() -> Result { Err(anyhow::anyhow!("Booted BLS not found")) } -pub fn read_file( - file: &RegularFile, - repo: &ComposefsRepository, -) -> Result> { - match file { - RegularFile::Inline(data) => Ok(data.clone()), - RegularFile::External(id, size) => { - let mut data = vec![]; - std::fs::File::from(repo.open_object(id)?).read_to_end(&mut data)?; - ensure!( - *size == data.len() as u64, - "File content doesn't have the expected length" - ); - Ok(data.into_boxed_slice()) - } - } -} - pub(crate) enum BootSetupType<'a> { /// For initial setup, i.e. install to-disk Setup((&'a RootSetup, &'a State)),