File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,34 @@ impl Partitions {
125125 }
126126 }
127127
128+ pub fn relocate ( & mut self , part_name : & str , offset : u32 ) -> Result < ( ) , String > {
129+ * self = match self {
130+ Partitions :: Gen2 ( parts) => {
131+ let p = parts. iter_mut ( ) . find ( |p| p. entry ( ) . name ( ) == part_name) ;
132+ if let Some ( p) = p {
133+ if let Err ( e) = p. relocate ( offset) {
134+ return Err ( format ! ( "Cannot relocate partition: {e}" ) ) ;
135+ }
136+ }
137+ Partitions :: Gen2 ( parts. to_vec ( ) )
138+ }
139+ Partitions :: Gen3 ( parts) => {
140+ let p = parts. iter_mut ( ) . find ( |p| p. entry ( ) . name ( ) == part_name) ;
141+ if let Some ( p) = p {
142+ if let Err ( e) = p. relocate ( offset) {
143+ return Err ( format ! ( "Cannot relocate partition: {e}" ) ) ;
144+ }
145+ }
146+ Partitions :: Gen3 ( parts. to_vec ( ) )
147+ }
148+ Partitions :: Unknown ( parts) => {
149+ let parts = parts. to_vec ( ) ;
150+ Partitions :: Unknown ( parts)
151+ }
152+ } ;
153+ Ok ( ( ) )
154+ }
155+
128156 pub fn to_vec ( & self ) -> Vec < u8 > {
129157 fn copy_parts ( parts : & Vec < & dyn Partition > , data : & mut Vec < u8 > ) {
130158 for p in parts {
You can’t perform that action at this time.
0 commit comments