]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/Disk/Partition/Dxe/Mbr.c
Fixed bug in partition driver:
[mirror_edk2.git] / EdkModulePkg / Universal / Disk / Partition / Dxe / Mbr.c
index 07e3cbe4591e295ca62961aded6611121f8560af..ce6b0d535388adda8f6cfebf6c6e0c37dd99e43f 100644 (file)
@@ -30,7 +30,6 @@ Abstract:
 --*/\r
 \r
 #include "Partition.h"\r
-#include "Mbr.h"\r
 \r
 BOOLEAN\r
 PartitionValidMbr (\r
@@ -109,7 +108,7 @@ Returns:
   return MbrValid;\r
 }\r
 \r
-BOOLEAN\r
+EFI_STATUS\r
 PartitionInstallMbrChildHandles (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   Handle,\r
@@ -130,8 +129,9 @@ Arguments:
   DevicePath - Parent Device Path\r
 \r
 Returns:\r
-  EFI_SUCCESS - If a child handle was added\r
-  other       - A child handle was not added\r
+  EFI_SUCCESS       - If a child handle was added\r
+  EFI_MEDIA_CHANGED - Media changed Detected\r
+       !EFI_SUCCESS      - Not found MBR partition.\r
 \r
 --*/\r
 {\r
@@ -141,13 +141,13 @@ Returns:
   UINTN                     Index;\r
   HARDDRIVE_DEVICE_PATH     HdDev;\r
   HARDDRIVE_DEVICE_PATH     ParentHdDev;\r
-  BOOLEAN                   Found;\r
+  EFI_STATUS                Found;\r
   UINT32                    PartitionNumber;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode;\r
   EFI_DEVICE_PATH_PROTOCOL  *LastDevicePathNode;\r
 \r
   Mbr             = NULL;\r
-  Found           = FALSE;\r
+  Found           = EFI_NOT_FOUND;\r
 \r
   Mbr             = AllocatePool (BlockIo->Media->BlockSize);\r
   if (Mbr == NULL) {\r
@@ -162,6 +162,7 @@ Returns:
                       Mbr\r
                       );\r
   if (EFI_ERROR (Status) || !PartitionValidMbr (Mbr, BlockIo->Media->LastBlock)) {\r
+    Found = Status;\r
     goto Done;\r
   }\r
   //\r
@@ -209,7 +210,7 @@ Returns:
         continue;\r
       }\r
 \r
-      if (Mbr->Partition[Index].OSIndicator == 0xEE) {\r
+      if (Mbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION) {\r
         //\r
         // This is the guard MBR for the GPT. If you ever see a GPT disk with zero partitions you can get here.\r
         //  We can not produce an MBR BlockIo for this device as the MBR spans the GPT headers. So formating \r
@@ -238,7 +239,7 @@ Returns:
                 );\r
 \r
       if (!EFI_ERROR (Status)) {\r
-        Found = TRUE;\r
+        Found = EFI_SUCCESS;\r
       }\r
     }\r
   } else {\r
@@ -258,6 +259,7 @@ Returns:
                           Mbr\r
                           );\r
       if (EFI_ERROR (Status)) {\r
+        Found = Status;\r
         goto Done;\r
       }\r
 \r
@@ -265,6 +267,11 @@ Returns:
         break;\r
       }\r
 \r
+      if ((Mbr->Partition[0].OSIndicator == EXTENDED_DOS_PARTITION) ||\r
+          (Mbr->Partition[0].OSIndicator == EXTENDED_WINDOWS_PARTITION)) {\r
+        ExtMbrStartingLba = UNPACK_UINT32 (Mbr->Partition[0].StartingLBA);\r
+        continue;\r
+      }\r
       HdDev.PartitionNumber = PartitionNumber ++;\r
       HdDev.PartitionStart  = UNPACK_UINT32 (Mbr->Partition[0].StartingLBA) + ExtMbrStartingLba + ParentHdDev.PartitionStart;\r
       HdDev.PartitionSize   = UNPACK_UINT32 (Mbr->Partition[0].SizeInLBA);\r
@@ -291,11 +298,11 @@ Returns:
                 (BOOLEAN) (Mbr->Partition[0].OSIndicator == EFI_PARTITION)\r
                 );\r
       if (!EFI_ERROR (Status)) {\r
-        Found = TRUE;\r
+        Found = EFI_SUCCESS;\r
       }\r
 \r
-      if (Mbr->Partition[1].OSIndicator != EXTENDED_DOS_PARTITION &&\r
-          Mbr->Partition[1].OSIndicator != EXTENDED_WINDOWS_PARTITION\r
+      if ((Mbr->Partition[1].OSIndicator != EXTENDED_DOS_PARTITION) &&\r
+          (Mbr->Partition[1].OSIndicator != EXTENDED_WINDOWS_PARTITION)\r
           ) {\r
         break;\r
       }\r