@@ -148,12 +148,14 @@ int disk_open(int drv)
148148 r = disk_read (drv , GPT_SECTOR_SIZE * gpt_lba , GPT_SECTOR_SIZE , sector );
149149 if (r < 0 ) {
150150 wolfBoot_printf ("Disk read failed\r\n" );
151+ Drives [drv ].is_open = 0 ;
151152 return -1 ;
152153 }
153154
154155 /* Parse and validate GPT header */
155156 if (gpt_parse_header ((uint8_t * )sector , & ptable ) != 0 ) {
156157 wolfBoot_printf ("Invalid GPT header\r\n" );
158+ Drives [drv ].is_open = 0 ;
157159 return -1 ;
158160 }
159161
@@ -175,8 +177,10 @@ int disk_open(int drv)
175177 break ;
176178
177179 r = disk_read (drv , address , ptable .array_sz , entry_buf );
178- if (r < 0 )
180+ if (r < 0 ) {
181+ Drives [drv ].is_open = 0 ;
179182 return -1 ;
183+ }
180184
181185 if (gpt_parse_partition ((uint8_t * )entry_buf , ptable .array_sz ,
182186 & part_info ) == 0 ) {
@@ -204,12 +208,14 @@ int disk_open(int drv)
204208 /* Check MBR boot signature (0xAA55) */
205209 if (* boot_sig != GPT_MBR_BOOTSIG_VALUE ) {
206210 wolfBoot_printf ("No valid partition table found\r\n" );
211+ Drives [drv ].is_open = 0 ;
207212 return -1 ;
208213 }
209214
210215 wolfBoot_printf ("Found MBR partition table\r\n" );
211216 if (disk_open_mbr (& Drives [drv ], sector ) < 0 ) {
212217 wolfBoot_printf ("Failed to parse MBR\r\n" );
218+ Drives [drv ].is_open = 0 ;
213219 return -1 ;
214220 }
215221 }
0 commit comments