From 013f0ac3be21679d30f654a035de4db4c50b2f84 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:21:20 -0700 Subject: [PATCH 1/8] Fix warnings --- .../trident/src/engine/storage/encryption.rs | 25 ------------------- crates/trident/src/engine/storage/raid.rs | 17 ------------- crates/trident/src/osimage/cosi/mod.rs | 4 +-- crates/trident/src/osimage/mod.rs | 10 +++++--- .../trident/src/subsystems/extensions/mod.rs | 1 + 5 files changed, 9 insertions(+), 48 deletions(-) diff --git a/crates/trident/src/engine/storage/encryption.rs b/crates/trident/src/engine/storage/encryption.rs index c09ad5ada..46961840e 100644 --- a/crates/trident/src/engine/storage/encryption.rs +++ b/crates/trident/src/engine/storage/encryption.rs @@ -1,5 +1,4 @@ use std::{ - collections::BTreeMap, fs::{self, Permissions}, os::unix::fs::PermissionsExt, path::{Path, PathBuf}, @@ -8,7 +7,6 @@ use std::{ use anyhow::{Context, Error}; use enumflags2::BitFlags; use log::{debug, info}; -use serde::{Deserialize, Serialize}; use tempfile::NamedTempFile; use osutils::{ @@ -282,29 +280,6 @@ fn encrypt_and_open_device( Ok(()) } -/// This is an abbreviated representation of the JSON output of -/// `cryptsetup luksDump --dump-json-metadata ` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -struct LuksDump { - segments: BTreeMap, -} - -/// This is a complete representation of the segment object in the JSON -/// output of `cryptsetup luksDump --dump-json-metadata ` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -#[serde(deny_unknown_fields)] -struct LuksDumpSegment { - #[serde(rename = "type")] - segment_type: String, - offset: String, - size: String, - iv_tweak: String, - encryption: String, - sector_size: u64, -} - /// Returns paths of UKI and bootloader binaries that `systemd-pcrlock` tool should seal to. During /// encryption provisioning, returns binaries used for the current boot, as well as binaries that /// will be used in the future boot, i.e. in the target OS image. During rollback validation, diff --git a/crates/trident/src/engine/storage/raid.rs b/crates/trident/src/engine/storage/raid.rs index 268849d5c..66a0fd0f9 100644 --- a/crates/trident/src/engine/storage/raid.rs +++ b/crates/trident/src/engine/storage/raid.rs @@ -8,8 +8,6 @@ use std::{ use anyhow::{anyhow, bail, Context, Error}; use log::{debug, info, trace, warn}; -use serde::{Deserialize, Serialize}; -use strum_macros::{Display, EnumString}; use osutils::{block_devices, dependencies::Dependency, mdadm, udevadm}; use trident_api::{ @@ -23,21 +21,6 @@ use crate::engine::{storage::common::SetRelationship, EngineContext}; use super::common; -#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, Display, EnumString)] -#[serde(rename_all = "kebab-case")] -#[serde(deny_unknown_fields)] -pub(super) enum RaidState { - /// in a clean, healthy state - #[strum(serialize = "clean")] - Clean, - /// active and operational - #[strum(serialize = "active")] - Active, - /// IO error - #[strum(serialize = "inactive")] - Inactive, -} - fn create(config: SoftwareRaidArray, ctx: &EngineContext) -> Result<(), Error> { let devices = &config.devices; let device_paths = get_device_paths(ctx, devices).context("Failed to get device paths")?; diff --git a/crates/trident/src/osimage/cosi/mod.rs b/crates/trident/src/osimage/cosi/mod.rs index 08871d926..f654fc5ca 100644 --- a/crates/trident/src/osimage/cosi/mod.rs +++ b/crates/trident/src/osimage/cosi/mod.rs @@ -85,7 +85,7 @@ impl Cosi { } /// Returns the ESP filesystem image. - pub(super) fn esp_filesystem(&self) -> Result { + pub(super) fn esp_filesystem<'a>(&'a self) -> Result, Error> { self.metadata .get_esp_filesystem() .map(|image| cosi_image_to_os_image_filesystem(&self.reader, image)) @@ -99,7 +99,7 @@ impl Cosi { } /// Returns an iterator over all images that are NOT the ESP filesystem image. - pub(super) fn filesystems(&self) -> impl Iterator { + pub(super) fn filesystems<'a>(&'a self) -> impl Iterator> { self.metadata .get_regular_filesystems() .map(|image| cosi_image_to_os_image_filesystem(&self.reader, image)) diff --git a/crates/trident/src/osimage/mod.rs b/crates/trident/src/osimage/mod.rs index 5c553828d..c33237708 100644 --- a/crates/trident/src/osimage/mod.rs +++ b/crates/trident/src/osimage/mod.rs @@ -137,7 +137,7 @@ impl OsImage { } /// Find the mount point which contains the given path. - pub(crate) fn path_to_filesystem(&self, path: &Path) -> Option { + pub(crate) fn path_to_filesystem<'a>(&'a self, path: &Path) -> Option> { self.filesystems() .filter(|fs| path.starts_with(&fs.mount_point)) .max_by_key(|fs| fs.mount_point.components().count()) @@ -153,7 +153,7 @@ impl OsImage { } /// Returns the ESP filesystem image. - pub(crate) fn esp_filesystem(&self) -> Result { + pub(crate) fn esp_filesystem<'a>(&'a self) -> Result, Error> { match &self.0 { OsImageInner::Cosi(cosi) => cosi.esp_filesystem(), #[cfg(test)] @@ -162,7 +162,9 @@ impl OsImage { } /// Returns an iterator over all images that are NOT the ESP filesystem image. - pub(crate) fn filesystems(&self) -> Box + '_> { + pub(crate) fn filesystems<'a>( + &'a self, + ) -> Box> + 'a> { match &self.0 { OsImageInner::Cosi(cosi) => Box::new(cosi.filesystems()), #[cfg(test)] @@ -171,7 +173,7 @@ impl OsImage { } /// Returns the root filesystem image. - pub(crate) fn root_filesystem(&self) -> Option { + pub(crate) fn root_filesystem<'a>(&'a self) -> Option> { self.filesystems() .find(|fs| fs.mount_point == Path::new(ROOT_MOUNT_POINT_PATH)) } diff --git a/crates/trident/src/subsystems/extensions/mod.rs b/crates/trident/src/subsystems/extensions/mod.rs index c2556c40b..30d3a03af 100644 --- a/crates/trident/src/subsystems/extensions/mod.rs +++ b/crates/trident/src/subsystems/extensions/mod.rs @@ -121,6 +121,7 @@ impl Subsystem for ExtensionsSubsystem { } impl ExtensionsSubsystem { + #[allow(unused)] fn populate_extensions( &mut self, ctx: &EngineContext, From 4e07b6970e5e369978dcfb7a7f5cec6aa342306e Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:35:18 -0700 Subject: [PATCH 2/8] Update crates/trident/src/osimage/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/trident/src/osimage/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/trident/src/osimage/mod.rs b/crates/trident/src/osimage/mod.rs index c33237708..b9dc5d460 100644 --- a/crates/trident/src/osimage/mod.rs +++ b/crates/trident/src/osimage/mod.rs @@ -137,7 +137,7 @@ impl OsImage { } /// Find the mount point which contains the given path. - pub(crate) fn path_to_filesystem<'a>(&'a self, path: &Path) -> Option> { + pub(crate) fn path_to_filesystem(&self, path: &Path) -> Option> { self.filesystems() .filter(|fs| path.starts_with(&fs.mount_point)) .max_by_key(|fs| fs.mount_point.components().count()) From 2e591c7edcdb4006c6198ff2db5579fcf9c763ff Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:35:32 -0700 Subject: [PATCH 3/8] Update crates/trident/src/osimage/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/trident/src/osimage/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/trident/src/osimage/mod.rs b/crates/trident/src/osimage/mod.rs index b9dc5d460..29c4fab7b 100644 --- a/crates/trident/src/osimage/mod.rs +++ b/crates/trident/src/osimage/mod.rs @@ -153,7 +153,7 @@ impl OsImage { } /// Returns the ESP filesystem image. - pub(crate) fn esp_filesystem<'a>(&'a self) -> Result, Error> { + pub(crate) fn esp_filesystem(&self) -> Result, Error> { match &self.0 { OsImageInner::Cosi(cosi) => cosi.esp_filesystem(), #[cfg(test)] From a5bb961c32b18f50340ad8565eb4eb66927b711c Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:35:45 -0700 Subject: [PATCH 4/8] Update crates/trident/src/osimage/cosi/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/trident/src/osimage/cosi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/trident/src/osimage/cosi/mod.rs b/crates/trident/src/osimage/cosi/mod.rs index f654fc5ca..7aef16627 100644 --- a/crates/trident/src/osimage/cosi/mod.rs +++ b/crates/trident/src/osimage/cosi/mod.rs @@ -99,7 +99,7 @@ impl Cosi { } /// Returns an iterator over all images that are NOT the ESP filesystem image. - pub(super) fn filesystems<'a>(&'a self) -> impl Iterator> { + pub(super) fn filesystems(&self) -> impl Iterator> { self.metadata .get_regular_filesystems() .map(|image| cosi_image_to_os_image_filesystem(&self.reader, image)) From cce01c845b1d2a41bf2326ecec75e72f597fd759 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:35:56 -0700 Subject: [PATCH 5/8] Update crates/trident/src/osimage/cosi/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/trident/src/osimage/cosi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/trident/src/osimage/cosi/mod.rs b/crates/trident/src/osimage/cosi/mod.rs index 7aef16627..af7e841d2 100644 --- a/crates/trident/src/osimage/cosi/mod.rs +++ b/crates/trident/src/osimage/cosi/mod.rs @@ -85,7 +85,7 @@ impl Cosi { } /// Returns the ESP filesystem image. - pub(super) fn esp_filesystem<'a>(&'a self) -> Result, Error> { + pub(super) fn esp_filesystem(&self) -> Result, Error> { self.metadata .get_esp_filesystem() .map(|image| cosi_image_to_os_image_filesystem(&self.reader, image)) From 135f2bb34669a10d94272f82192587d91c7a3afc Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:36:10 -0700 Subject: [PATCH 6/8] Update crates/trident/src/osimage/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/trident/src/osimage/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/trident/src/osimage/mod.rs b/crates/trident/src/osimage/mod.rs index 29c4fab7b..f7618b509 100644 --- a/crates/trident/src/osimage/mod.rs +++ b/crates/trident/src/osimage/mod.rs @@ -162,9 +162,9 @@ impl OsImage { } /// Returns an iterator over all images that are NOT the ESP filesystem image. - pub(crate) fn filesystems<'a>( - &'a self, - ) -> Box> + 'a> { + pub(crate) fn filesystems( + &self, + ) -> Box> + '_> { match &self.0 { OsImageInner::Cosi(cosi) => Box::new(cosi.filesystems()), #[cfg(test)] From 820ae6a27cd2feb1e1f91fe7699f9723270df1a8 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 13:36:44 -0700 Subject: [PATCH 7/8] Update crates/trident/src/osimage/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/trident/src/osimage/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/trident/src/osimage/mod.rs b/crates/trident/src/osimage/mod.rs index f7618b509..fe7a628d6 100644 --- a/crates/trident/src/osimage/mod.rs +++ b/crates/trident/src/osimage/mod.rs @@ -173,7 +173,7 @@ impl OsImage { } /// Returns the root filesystem image. - pub(crate) fn root_filesystem<'a>(&'a self) -> Option> { + pub(crate) fn root_filesystem(&self) -> Option> { self.filesystems() .find(|fs| fs.mount_point == Path::new(ROOT_MOUNT_POINT_PATH)) } From 0fd06ec7bf4be0bfe0ff150a17a4d48193c30b9f Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 27 Oct 2025 14:53:05 -0700 Subject: [PATCH 8/8] Formatting --- crates/trident/src/osimage/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/trident/src/osimage/mod.rs b/crates/trident/src/osimage/mod.rs index fe7a628d6..7a9e1d684 100644 --- a/crates/trident/src/osimage/mod.rs +++ b/crates/trident/src/osimage/mod.rs @@ -162,9 +162,7 @@ impl OsImage { } /// Returns an iterator over all images that are NOT the ESP filesystem image. - pub(crate) fn filesystems( - &self, - ) -> Box> + '_> { + pub(crate) fn filesystems(&self) -> Box> + '_> { match &self.0 { OsImageInner::Cosi(cosi) => Box::new(cosi.filesystems()), #[cfg(test)]