public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: devel@edk2.groups.io
Cc: Hao A Wu <hao.a.wu@intel.com>, Ray Ni <ray.ni@intel.com>,
	Jian J Wang <jian.j.wang@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH] MdeModulePkg/PartitionDxe: Seperate the Udf handler
Date: Wed, 24 Jun 2020 13:56:10 +0800	[thread overview]
Message-ID: <20200624055610.13984-1-zhichao.gao@intel.com> (raw)

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823

Some linux iso like Redhat would contain both MBR info in the first
512 bytes and volume info at the beginning of 32KB offset.
But the partition driver would only choose one of the GPT, MBR, and
UDF(el torito compatible) to install the partition. That would lose
one info for such linux ISO during one connect. And UDF(el torito
compatible) is not conflicted with MBR/GPT. So partition driver should
check UDF and MBR/GPT separately.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
 .../Universal/Disk/PartitionDxe/Partition.c   | 52 +++++++++++++------
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index d1c878ad2e..562490db4f 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -5,7 +5,7 @@
   MBR, and GPT partition schemes are supported.
 
 Copyright (c) 2018 Qualcomm Datacenter Technologies, Inc.
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -39,7 +39,6 @@ EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
 PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
   PartitionInstallGptChildHandles,
   PartitionInstallMbrChildHandles,
-  PartitionInstallUdfChildHandles,
   NULL
 };
 
@@ -189,6 +188,8 @@ PartitionDriverBindingStart (
 {
   EFI_STATUS                Status;
   EFI_STATUS                OpenStatus;
+  EFI_STATUS                UdfStatus;
+  EFI_STATUS                GptMbrStatus;
   EFI_BLOCK_IO_PROTOCOL     *BlockIo;
   EFI_BLOCK_IO2_PROTOCOL    *BlockIo2;
   EFI_DISK_IO_PROTOCOL      *DiskIo;
@@ -300,26 +301,47 @@ PartitionDriverBindingStart (
   if (BlockIo->Media->MediaPresent ||
       (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {
     //
-    // Try for GPT, then legacy MBR partition types, and then UDF and El Torito.
-    // If the media supports a given partition type install child handles to
-    // represent the partitions described by the media.
+    // Try for UDF (El TOrito compatible) and GPT/MBR partition types.
+    // If the media supports a given partition type, it would install child handles
+    // to represent the partitions described by the media.
+    // Notes: GPT is conflicted with MBR. It would only install one of them to describe
+    // the partition. UDF (or El Torito) can exist with MBR, so need to check it along with
+    // GPT/MBR.
     //
+    UdfStatus = PartitionInstallUdfChildHandles (
+                  This,
+                  ControllerHandle,
+                  DiskIo,
+                  DiskIo2,
+                  BlockIo,
+                  BlockIo2,
+                  ParentDevicePath
+                  );
+
     Routine = &mPartitionDetectRoutineTable[0];
     while (*Routine != NULL) {
-      Status = (*Routine) (
-                   This,
-                   ControllerHandle,
-                   DiskIo,
-                   DiskIo2,
-                   BlockIo,
-                   BlockIo2,
-                   ParentDevicePath
-                   );
-      if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA) {
+      GptMbrStatus = (*Routine) (
+                        This,
+                        ControllerHandle,
+                        DiskIo,
+                        DiskIo2,
+                        BlockIo,
+                        BlockIo2,
+                        ParentDevicePath
+                        );
+      if (!EFI_ERROR (GptMbrStatus) || GptMbrStatus == EFI_MEDIA_CHANGED || GptMbrStatus == EFI_NO_MEDIA) {
         break;
       }
       Routine++;
     }
+
+    if (!EFI_ERROR (UdfStatus) || !EFI_ERROR (GptMbrStatus)) {
+      Status = EFI_SUCCESS;
+    } else if (UdfStatus == EFI_MEDIA_CHANGED || GptMbrStatus == EFI_MEDIA_CHANGED) {
+      Status = EFI_MEDIA_CHANGED;
+    } else if (UdfStatus == EFI_NO_MEDIA || GptMbrStatus == EFI_NO_MEDIA) {
+      Status = EFI_NO_MEDIA;
+    }
   }
   //
   // In the case that the driver is already started (OpenStatus == EFI_ALREADY_STARTED),
-- 
2.21.0.windows.1


             reply	other threads:[~2020-06-24  5:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24  5:56 Gao, Zhichao [this message]
2020-06-24  8:32 ` [PATCH] MdeModulePkg/PartitionDxe: Seperate the Udf handler Ni, Ray
2020-06-24 11:57   ` [edk2-devel] " Laszlo Ersek
2020-06-25  0:21     ` Ni, Ray
2020-06-25  9:02       ` Laszlo Ersek
2020-06-29  1:47         ` Gao, Zhichao
2020-06-29  2:42           ` Ni, Ray
2020-06-29  5:23             ` Gao, Zhichao
2020-07-02  9:42           ` Laszlo Ersek
2020-07-06  2:55             ` Gao, Zhichao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624055610.13984-1-zhichao.gao@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox