From 83e1f5a6803d47d7d6ef9bbd23e8467e5e4346e1 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sun, 6 Jul 2014 11:00:01 -0400 Subject: [PATCH] Display partition label, if available, for BIOS-mode boot from partition on Macs, when the filesystem is unreadable. --- NEWS.txt | 7 +++++ refind/lib.c | 74 ++++++++++++++++++++++++++------------------------- refind/main.c | 2 +- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index 87b248c..e90ecd5 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,13 @@ 0.8.3 (?/??/2014): ------------------ +- Added new icons for Clover boot loader and for Mythbuntu Linux + distribution. + +- rEFInd now displays the partition's label, when one is available, when + offering a BIOS-mode boot option for a partition with no filesystem + driver. This works only on Macs doing BIOS-mode booting. + - Removed GPLv2 code from the FSW core files. This was done because the Btrfs driver is derived from the GRUB Btrfs driver, which is licensed under the GPLv3. Ironically, the GPLv2 and GPLv3 are incompatible diff --git a/refind/lib.c b/refind/lib.c index 0570265..893f62c 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -751,42 +751,45 @@ static CHAR16 *SizeInIEEEUnits(UINT64 SizeInBytes) { // The calling function is responsible for freeing the memory allocated // for the name string. static CHAR16 *GetVolumeName(REFIT_VOLUME *Volume) { - EFI_FILE_SYSTEM_INFO *FileSystemInfoPtr; + EFI_FILE_SYSTEM_INFO *FileSystemInfoPtr = NULL; CHAR16 *FoundName = NULL; CHAR16 *SISize, *TypeName; - FileSystemInfoPtr = LibFileSystemInfo(Volume->RootDir); - if (FileSystemInfoPtr != NULL) { // we have filesystem information (size, label).... - if ((FileSystemInfoPtr->VolumeLabel != NULL) && (StrLen(FileSystemInfoPtr->VolumeLabel) > 0)) { - FoundName = StrDuplicate(FileSystemInfoPtr->VolumeLabel); - } - - // Special case: Old versions of the rEFInd HFS+ driver always returns label of "HFS+ volume", so wipe - // this so that we can build a new name that includes the size.... - if ((FoundName != NULL) && (StrCmp(FoundName, L"HFS+ volume") == 0) && (Volume->FSType == FS_TYPE_HFSPLUS)) { - MyFreePool(FoundName); - FoundName = NULL; - } // if rEFInd HFS+ driver suspected - - // If no filesystem name, try to use the partition name.... - if ((FoundName == NULL) && (Volume->PartName != NULL) && (StrLen(Volume->PartName) > 0) && - !IsIn(Volume->PartName, IGNORE_PARTITION_NAMES)) { - FoundName = StrDuplicate(Volume->PartName); - } // if use partition name - - // No filesystem or acceptable partition name, so use fs type and size - if (FoundName == NULL) { - FoundName = AllocateZeroPool(sizeof(CHAR16) * 256); - if (FoundName != NULL) { - SISize = SizeInIEEEUnits(FileSystemInfoPtr->VolumeSize); - SPrint(FoundName, 255, L"%s%s volume", SISize, FSTypeName(Volume->FSType)); - MyFreePool(SISize); - } // if allocated memory OK - } // if (FoundName == NULL) - - FreePool(FileSystemInfoPtr); - - } else { // fs driver not returning info; fall back on our own information.... + if (Volume->RootDir != NULL) { + FileSystemInfoPtr = LibFileSystemInfo(Volume->RootDir); + } + + if ((FileSystemInfoPtr != NULL) && (FileSystemInfoPtr->VolumeLabel != NULL) && + (StrLen(FileSystemInfoPtr->VolumeLabel) > 0)) { + FoundName = StrDuplicate(FileSystemInfoPtr->VolumeLabel); + } + + // Special case: Old versions of the rEFInd HFS+ driver always returns label of "HFS+ volume", so wipe + // this so that we can build a new name that includes the size.... + if ((FoundName != NULL) && (StrCmp(FoundName, L"HFS+ volume") == 0) && (Volume->FSType == FS_TYPE_HFSPLUS)) { + MyFreePool(FoundName); + FoundName = NULL; + } // if rEFInd HFS+ driver suspected + + // If no filesystem name, try to use the partition name.... + if ((FoundName == NULL) && (Volume->PartName != NULL) && (StrLen(Volume->PartName) > 0) && + !IsIn(Volume->PartName, IGNORE_PARTITION_NAMES)) { + FoundName = StrDuplicate(Volume->PartName); + } // if use partition name + + // No filesystem or acceptable partition name, so use fs type and size + if ((FoundName == NULL) && (FileSystemInfoPtr != NULL)) { + FoundName = AllocateZeroPool(sizeof(CHAR16) * 256); + if (FoundName != NULL) { + SISize = SizeInIEEEUnits(FileSystemInfoPtr->VolumeSize); + SPrint(FoundName, 255, L"%s%s volume", SISize, FSTypeName(Volume->FSType)); + MyFreePool(SISize); + } // if allocated memory OK + } // if (FoundName == NULL) + + MyFreePool(FileSystemInfoPtr); + + if (FoundName == NULL) { FoundName = AllocateZeroPool(sizeof(CHAR16) * 256); if (FoundName != NULL) { TypeName = FSTypeName(Volume->FSType); // NOTE: Don't free TypeName; function returns constant @@ -799,7 +802,6 @@ static CHAR16 *GetVolumeName(REFIT_VOLUME *Volume) { // TODO: Above could be improved/extended, in case filesystem name is not found, // such as: - // - use partition label // - use or add disk/partition number (e.g., "(hd0,2)") // Desperate fallback name.... @@ -942,6 +944,8 @@ VOID ScanVolume(REFIT_VOLUME *Volume) // Set volume icon based on .VolumeBadge icon or disk kind SetVolumeBadgeIcon(Volume); + Volume->VolName = GetVolumeName(Volume); + if (Volume->RootDir == NULL) { Volume->IsReadable = FALSE; return; @@ -949,8 +953,6 @@ VOID ScanVolume(REFIT_VOLUME *Volume) Volume->IsReadable = TRUE; } - Volume->VolName = GetVolumeName(Volume); - // get custom volume icons if present if (!Volume->VolIconImage) Volume->VolIconImage = egLoadIconAnyType(Volume->RootDir, L"", L".VolumeIcon", GlobalConfig.IconSizes[ICON_SIZE_BIG]); diff --git a/refind/main.c b/refind/main.c index 0032e16..dfe419d 100644 --- a/refind/main.c +++ b/refind/main.c @@ -169,7 +169,7 @@ static VOID AboutrEFInd(VOID) if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.8.2.3"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.8.2.4"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2014 Roderick W. Smith"); -- 2.39.2