@@ -13,6 +13,8 @@ use crate::dir::{
1313 gen3:: { CPD_MAGIC_BYTES , CodePartitionDirectory } ,
1414} ;
1515use crate :: part:: fpt:: FTPR ;
16+ use crate :: part:: gen2:: DirPartition ;
17+ use crate :: part:: gen3:: CPDPartition ;
1618use crate :: part:: part:: Partition ;
1719use crate :: part:: {
1820 fpt:: { FPT , MIN_FPT_SIZE } ,
@@ -69,26 +71,50 @@ impl FPTArea {
6971 }
7072 }
7173
72- pub fn check_ftpr_sig ( & self ) -> Result < ( ) , String > {
74+ pub fn check_dir_sigs ( & self ) -> Vec < ( String , Result < ( ) , String > ) > {
7375 match & self . partitions {
7476 Partitions :: Gen2 ( parts) => {
75- if let Some ( ftpr) = parts. iter ( ) . find ( |p| p. entry ( ) . name ( ) == FTPR ) {
76- match ftpr {
77- Gen2Partition :: Dir ( dir) => dir. check_signature ( ) ,
78- _ => Err ( "FTPR partition not recognized as directory" . into ( ) ) ,
79- }
77+ let dirs = parts
78+ . iter ( )
79+ . filter_map ( |p| match p {
80+ Gen2Partition :: Dir ( d) => Some ( d. clone ( ) ) ,
81+ _ => None ,
82+ } )
83+ . collect :: < Vec < DirPartition > > ( ) ;
84+ dirs. iter ( )
85+ . map ( |d| ( d. entry . name ( ) , d. check_signature ( ) ) )
86+ . collect ( )
87+ }
88+ Partitions :: Gen3 ( parts) => {
89+ let dirs = parts
90+ . iter ( )
91+ . filter_map ( |p| match p {
92+ Gen3Partition :: Dir ( d) => Some ( d. clone ( ) ) ,
93+ _ => None ,
94+ } )
95+ . collect :: < Vec < CPDPartition > > ( ) ;
96+ dirs. iter ( )
97+ . map ( |d| ( d. entry . name ( ) , d. check_signature ( ) ) )
98+ . collect ( )
99+ }
100+ _ => vec ! [ ] ,
101+ }
102+ }
103+
104+ pub fn check_ftpr_presence ( & self ) -> Result < ( ) , String > {
105+ match & self . partitions {
106+ Partitions :: Gen2 ( parts) => {
107+ if parts. iter ( ) . find ( |p| p. entry ( ) . name ( ) == FTPR ) . is_some ( ) {
108+ Ok ( ( ) )
80109 } else {
81- Err ( "FTPR partition not found" . into ( ) )
110+ Err ( "not found" . into ( ) )
82111 }
83112 }
84113 Partitions :: Gen3 ( parts) => {
85- if let Some ( ftpr) = parts. iter ( ) . find ( |p| p. entry ( ) . name ( ) == FTPR ) {
86- match ftpr {
87- Gen3Partition :: Dir ( dir) => dir. check_signature ( ) ,
88- _ => Err ( "FTPR partition not recognized as directory" . into ( ) ) ,
89- }
114+ if parts. iter ( ) . find ( |p| p. entry ( ) . name ( ) == FTPR ) . is_some ( ) {
115+ Ok ( ( ) )
90116 } else {
91- Err ( "FTPR partition not found" . into ( ) )
117+ Err ( "not found" . into ( ) )
92118 }
93119 }
94120 _ => Err ( "not recognized as ME generation 2 or 3" . into ( ) ) ,
0 commit comments