1313static void partition_split_mmc (const char * base_name , const char * name ,
1414 uint32_t num_blocks , bool end )
1515{
16- struct partition_entry * base , * split ;
16+ struct partition_entry * backup , * base , * split ;
1717 int index = partition_get_index (base_name );
1818
1919 if (index == INVALID_PTN ) {
@@ -29,6 +29,15 @@ static void partition_split_mmc(const char *base_name, const char *name,
2929 return ;
3030 }
3131
32+ backup = partition_allocate ();
33+ if (backup ) {
34+ memcpy (backup , base , sizeof (* backup ));
35+ snprintf ((char * )backup -> name , sizeof (backup -> name ), "real_%s" , base_name );
36+ } else {
37+ dprintf (CRITICAL , "Too many partitions, cannot backup %s partition entry\n" ,
38+ base_name );
39+ }
40+
3241 split = partition_allocate ();
3342 if (split ) {
3443 memcpy (split , base , sizeof (* split ));
@@ -67,6 +76,16 @@ static void partition_split_flash(struct ptable *ptable, const char *base_name,
6776 return ;
6877 }
6978
79+ if (ptable_size (ptable ) < MAX_PTABLE_PARTS ) {
80+ char backup_name [MAX_PTENTRY_NAME ];
81+ snprintf (backup_name , sizeof (backup_name ), "real_%s" , base_name );
82+ ptable_add (ptable , backup_name , base -> start , base -> length ,
83+ base -> flags , base -> type , base -> perm );
84+ } else {
85+ dprintf (CRITICAL , "Too many partitions, cannot backup %s partition entry\n" ,
86+ base_name );
87+ }
88+
7089 if (ptable_size (ptable ) < MAX_PTABLE_PARTS ) {
7190 unsigned start = base -> start ;
7291 if (end )
0 commit comments