Skip to content

Commit cad290a

Browse files
committed
blsforme/entry: Enable a unique ID (u64) per entry
This is required for integration into moss, whereby a state has a *unique* loader configuration per filesystem state, so that we can enable a rollback mechanism. Signed-off-by: Ikey Doherty <[email protected]>
1 parent 2dc8f78 commit cad290a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

blsforme/src/entry.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ pub struct Entry<'a> {
2525
pub(crate) sysroot: Option<PathBuf>,
2626

2727
pub(crate) cmdline: Vec<CmdlineEntry>,
28+
29+
/// Unique state ID for this entry
30+
pub(crate) state_id: Option<u64>,
2831
}
2932

3033
impl<'a> Entry<'a> {
@@ -34,6 +37,7 @@ impl<'a> Entry<'a> {
3437
kernel,
3538
cmdline: vec![],
3639
sysroot: None,
40+
state_id: None,
3741
}
3842
}
3943

@@ -67,14 +71,27 @@ impl<'a> Entry<'a> {
6771
}
6872
}
6973

74+
/// With the given state ID
75+
/// Used by moss to link to the unique transaction ID on disk
76+
pub fn with_state_id(self, state_id: u64) -> Self {
77+
Self {
78+
state_id: Some(state_id),
79+
..self
80+
}
81+
}
82+
7083
/// Return an entry ID, suitable for `.conf` generation
7184
pub fn id(&self, schema: &Schema) -> String {
7285
// TODO: For BLS schema, grab something even uniquer (TM)
7386
let id = match schema {
7487
Schema::Legacy { os_release, .. } => os_release.name.clone(),
7588
Schema::Blsforme { os_release } => os_release.id.clone(),
7689
};
77-
format!("{id}-{}", &self.kernel.version)
90+
if let Some(state_id) = self.state_id {
91+
format!("{id}-{version}-{state_id}", version = &self.kernel.version)
92+
} else {
93+
format!("{id}-{version}", version = &self.kernel.version)
94+
}
7895
}
7996

8097
/// Generate an installed name for the kernel, used by bootloaders

0 commit comments

Comments
 (0)