]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PartitionDxe: Some ISO images cannot be recognized properly
authorHao Wu <hao.a.wu@intel.com>
Fri, 11 Mar 2016 07:55:36 +0000 (15:55 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 29 Mar 2016 05:35:30 +0000 (13:35 +0800)
Some ISO images cannot be recognized properly when they are on media whose
block size is not 2048 bytes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c

index 22384499c56a05f125a65373db3c999b014affc2..2af38429dd3a20f10242a0725b7ea755ad24914f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Decode an El Torito formatted CD-ROM\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -183,7 +183,7 @@ PartitionInstallElToritoChildHandles (
       }\r
 \r
       SubBlockSize  = 512;\r
-      SectorCount   = Catalog->Boot.SectorCount * (SIZE_2KB / Media->BlockSize);\r
+      SectorCount   = Catalog->Boot.SectorCount;\r
 \r
       switch (Catalog->Boot.MediaType) {\r
 \r
@@ -233,15 +233,15 @@ PartitionInstallElToritoChildHandles (
         //\r
         // When the SectorCount < 2, set the Partition as the whole CD.\r
         //\r
-        if (VolSpaceSize > (Media->LastBlock + 1)) {\r
-          CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba + 1);\r
+        if (VolSpaceSize * (SIZE_2KB / Media->BlockSize) > (Media->LastBlock + 1)) {\r
+          CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + 1);\r
         } else {\r
-          CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba);\r
+          CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba) * (SIZE_2KB / Media->BlockSize);\r
         }\r
       } else {\r
         CdDev.PartitionSize = DivU64x32 (\r
                                 MultU64x32 (\r
-                                  SectorCount,\r
+                                  SectorCount * (SIZE_2KB / Media->BlockSize),\r
                                   SubBlockSize\r
                                   ) + Media->BlockSize - 1,\r
                                 Media->BlockSize\r
@@ -258,7 +258,7 @@ PartitionInstallElToritoChildHandles (
                 DevicePath,\r
                 (EFI_DEVICE_PATH_PROTOCOL *) &CdDev,\r
                 Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),\r
-                MultU64x32 (Catalog->Boot.Lba + CdDev.PartitionSize - 1, SIZE_2KB / Media->BlockSize),\r
+                Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1,\r
                 SubBlockSize,\r
                 FALSE\r
                 );\r