From f821c7cc272769499d6e4cc62a515ddd48fc8a8a Mon Sep 17 00:00:00 2001 From: vit9696 Date: Wed, 22 May 2019 17:59:51 +0300 Subject: [PATCH] OcBootManagementLib: Dirty HFS ScanPolicy support --- Include/Library/OcBootManagementLib.h | 22 ++++++++++++++++++- .../OcBootManagementLib/OcBootManagementLib.c | 22 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Include/Library/OcBootManagementLib.h b/Include/Library/OcBootManagementLib.h index 2cab38dd..30ba0afb 100755 --- a/Include/Library/OcBootManagementLib.h +++ b/Include/Library/OcBootManagementLib.h @@ -108,6 +108,11 @@ OcFreeBootEntries ( **/ #define OC_SCAN_ALLOW_FS_APFS BIT8 +/** + Allow scanning HFS filesystems. +**/ +#define OC_SCAN_ALLOW_FS_HFS BIT9 + /** Allow scanning SATA devices. **/ @@ -148,10 +153,25 @@ OcFreeBootEntries ( **/ #define OC_SCAN_ALLOW_DEVICE_SDCARD BIT23 +/** + All device bits used by OC_SCAN_DEVICE_LOCK. +**/ +#define OC_SCAN_DEVICE_BITS ( \ + OC_SCAN_ALLOW_DEVICE_SATA | OC_SCAN_ALLOW_DEVICE_SASEX | \ + OC_SCAN_ALLOW_DEVICE_SCSI | OC_SCAN_ALLOW_DEVICE_NVME | \ + OC_SCAN_ALLOW_DEVICE_ATAPI | OC_SCAN_ALLOW_DEVICE_USB | \ + OC_SCAN_ALLOW_DEVICE_FIREWIRE | OC_SCAN_ALLOW_DEVICE_SDCARD) + +/** + All device bits used by OC_SCAN_DEVICE_LOCK. +**/ +#define OC_SCAN_FILE_SYSTEM_BITS ( \ + OC_SCAN_ALLOW_FS_APFS | OC_SCAN_ALLOW_FS_HFS) + /** By default allow booting from APFS from internal drives. **/ -#define OC_SCAN_DEFAULT_POLICY ( \ +#define OC_SCAN_DEFAULT_POLICY ( \ OC_SCAN_FILE_SYSTEM_LOCK | OC_SCAN_DEVICE_LOCK | \ OC_SCAN_ALLOW_FS_APFS | OC_SCAN_ALLOW_DEVICE_SATA | \ OC_SCAN_ALLOW_DEVICE_SASEX | OC_SCAN_ALLOW_DEVICE_SCSI | \ diff --git a/Library/OcBootManagementLib/OcBootManagementLib.c b/Library/OcBootManagementLib/OcBootManagementLib.c index f0b7c7f0..cde1f40b 100644 --- a/Library/OcBootManagementLib/OcBootManagementLib.c +++ b/Library/OcBootManagementLib/OcBootManagementLib.c @@ -152,6 +152,28 @@ InternalCheckScanPolicy ( } } + // + // FIXME: This is even worse but works for testing the concept purposes. + // Current logic is blessed but not APFS. + // + if ((Policy & OC_SCAN_ALLOW_FS_HFS) != 0 && EFI_ERROR (Status)) { + BufferSize = 0; + Status = Root->GetInfo (Root, &gAppleApfsVolumeInfoGuid, &BufferSize, NULL); + if (Status != EFI_BUFFER_TOO_SMALL) { + BufferSize = 0; + Status = Root->GetInfo (Root, &gAppleBlessedSystemFileInfoGuid, &BufferSize, NULL); + if (Status == EFI_BUFFER_TOO_SMALL) { + Status = EFI_SUCCESS; + } else { + BufferSize = 0; + Status = Root->GetInfo (Root, &gAppleBlessedSystemFolderInfoGuid, &BufferSize, NULL); + if (Status == EFI_BUFFER_TOO_SMALL) { + Status = EFI_SUCCESS; + } + } + } + } + Root->Close (Root); if (EFI_ERROR (Status)) {