Skip to content

Commit c8c36f8

Browse files
committed
implement relocation option for clean command
Signed-off-by: Daniel Maslowski <info@orangecms.org>
1 parent 74da030 commit c8c36f8

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/clean.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
use intel_fw::me::ME;
2+
use log::warn;
23

3-
pub fn clean(me: &ME, data: &mut [u8]) -> Result<Vec<u8>, String> {
4+
pub struct Options {
5+
pub relocate: bool,
6+
}
7+
8+
pub fn clean(me: &ME, data: &mut [u8], options: Options) -> Result<Vec<u8>, String> {
49
let mut new_me = me.clone();
510
new_me.fpt_area.clean();
11+
if options.relocate {
12+
if let Err(e) = new_me.fpt_area.relocate_partitions() {
13+
warn!("Could not relocate: {e}")
14+
}
15+
}
616
let cleaned = new_me.fpt_area.to_vec();
717
let size = cleaned.len();
818
data[me.base..me.base + size].copy_from_slice(&cleaned);

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ fn main() {
179179
let Ok(me) = me_res else {
180180
return;
181181
};
182-
match clean::clean(&me, &mut data) {
182+
let opts = clean::Options { relocate };
183+
match clean::clean(&me, &mut data, opts) {
183184
Ok(data) => {
184185
if let Some(out_file) = output {
185186
let mut file = fs::File::create(out_file).unwrap();

0 commit comments

Comments
 (0)