Skip to content

Commit

Permalink
OcAppleDiskImageLib: Fix ScanPolicy clash with DMG loading
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Aug 22, 2020
1 parent 5eb9d36 commit 7b53fa7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
10 changes: 7 additions & 3 deletions Include/Acidanthera/Library/OcApfsLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,28 @@ OcApfsConfigure (
Connect APFS driver to partitions on media handle.
@param[in] Handle Media handle (disk).
@param[in] VerifyPolicy Apply ScanPolicy rules.
@retval EFI_SUCCESS if the device was connected.
**/
EFI_STATUS
OcApfsConnectParentDevice (
IN EFI_HANDLE Handle OPTIONAL
IN EFI_HANDLE Handle OPTIONAL,
IN BOOLEAN VerifyPolicy
);

/**
Connect APFS driver to a device at handle.
@param[in] Handle Device handle (APFS container).
@param[in] Handle Device handle (APFS container).
@param[in] VerifyPolicy Apply ScanPolicy rules.
@retval EFI_SUCCESS if the device was connected.
**/
EFI_STATUS
OcApfsConnectDevice (
IN EFI_HANDLE Handle
IN EFI_HANDLE Handle,
IN BOOLEAN VerifyPolicy
);

/**
Expand Down
20 changes: 13 additions & 7 deletions Library/OcApfsLib/OcApfsConnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ OcApfsConfigure (

EFI_STATUS
OcApfsConnectDevice (
IN EFI_HANDLE Handle
IN EFI_HANDLE Handle,
IN BOOLEAN VerifyPolicy
)
{
EFI_STATUS Status;
Expand Down Expand Up @@ -477,8 +478,11 @@ OcApfsConnectDevice (
// - Which have non-POT block size.
//
if (BlockIo->Media == NULL
|| !BlockIo->Media->LogicalPartition
|| BlockIo->Media->BlockSize == 0
|| !BlockIo->Media->LogicalPartition) {
return EFI_UNSUPPORTED;
}

if (BlockIo->Media->BlockSize == 0
|| (BlockIo->Media->BlockSize & (BlockIo->Media->BlockSize - 1)) != 0) {
DEBUG ((
DEBUG_INFO,
Expand All @@ -492,10 +496,12 @@ OcApfsConnectDevice (
//
// Filter out handles, which do not respect OpenCore policy.
//
Status = ApfsCheckOpenCoreScanPolicy (Handle);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCJS: Cannot connect, Policy error - %r\n", Status));
return Status;
if (VerifyPolicy) {
Status = ApfsCheckOpenCoreScanPolicy (Handle);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCJS: Cannot connect, Policy error - %r\n", Status));
return Status;
}
}

//
Expand Down
10 changes: 6 additions & 4 deletions Library/OcApfsLib/OcApfsLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ApfsNewPartitionArrived (
&Handle
);
if (!EFI_ERROR (Status)) {
OcApfsConnectDevice (Handle);
OcApfsConnectDevice (Handle, TRUE);
} else {
break;
}
Expand Down Expand Up @@ -87,7 +87,8 @@ ApfsMonitorNewPartitions (

EFI_STATUS
OcApfsConnectParentDevice (
IN EFI_HANDLE Handle OPTIONAL
IN EFI_HANDLE Handle OPTIONAL,
IN BOOLEAN VerifyPolicy
)
{
EFI_STATUS Status;
Expand Down Expand Up @@ -147,7 +148,8 @@ OcApfsConnectParentDevice (
}

Status2 = OcApfsConnectDevice (
HandleBuffer[Index]
HandleBuffer[Index],
VerifyPolicy
);
if (!EFI_ERROR (Status2)) {
Status = Status2;
Expand Down Expand Up @@ -176,5 +178,5 @@ OcApfsConnectDevices (
}
}

return OcApfsConnectParentDevice (NULL);
return OcApfsConnectParentDevice (NULL, TRUE);
}
2 changes: 1 addition & 1 deletion Library/OcAppleDiskImageLib/OcAppleDiskImageBlockIo.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ OcAppleDiskImageInstallBlockIo (

Status = gBS->ConnectController (BlockIoHandle, NULL, NULL, TRUE);
if (!EFI_ERROR (Status)) {
OcApfsConnectParentDevice (BlockIoHandle);
OcApfsConnectParentDevice (BlockIoHandle, FALSE);
} else {
DEBUG ((DEBUG_INFO, "OCDI: Failed to connect DMG handle %r\n", Status));

Expand Down

0 comments on commit 7b53fa7

Please sign in to comment.