From 32b3a5ad581fafc5c06493accc0202326ae6d362 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sun, 20 Apr 2014 10:40:28 -0400 Subject: [PATCH] Added correct filesystem name detection to HFS+ driver. --- NEWS.txt | 2 ++ docs/refind/installing.html | 2 ++ filesystems/fsw_hfs.c | 39 ++++++++++++++++++++++++++++--------- refind/main.c | 3 ++- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index dbe119f..b622b4b 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -11,6 +11,8 @@ - Fixed bug in install.sh that could cause it to display error messages if the dmraid utility was not installed. +- The HFS+ driver now reports a correct volume name. + - Fixed some EFI filesystem driver bugs that could cause lockups under some circumstances. These bugs could affect any of the filesystem drivers. diff --git a/docs/refind/installing.html b/docs/refind/installing.html index 31d62f5..207eaad 100644 --- a/docs/refind/installing.html +++ b/docs/refind/installing.html @@ -602,6 +602,8 @@ $ ioreg -l -p IODeviceTree | grep firmware-abi

Installing rEFInd Manually Using an EFI Shell

+ +

If you can't currently boot any OS (say, because a firmware update has wiped your NVRAM entries), you may find it convenient to install rEFInd using an EFI version 2 shell. Unfortunately, the bcfg command described here is not available in the EFI version 1 shell, and the version 2 shell is unusable on many firmware implementations prior to 2.3.1. Thus, this procedure won't work for all systems.

In addition to emergency situations, using bcfg can be desirable if efibootmgr or other OS-hosted tools don't do the job. This happens under VirtualBox, for instance. An alternative in such cases can be to use alternative names for rEFInd.

diff --git a/filesystems/fsw_hfs.c b/filesystems/fsw_hfs.c index 2719568..deea0f8 100644 --- a/filesystems/fsw_hfs.c +++ b/filesystems/fsw_hfs.c @@ -221,7 +221,9 @@ static fsw_status_t fsw_hfs_volume_mount(struct fsw_hfs_volume *vol) fsw_u32 blockno; struct fsw_string s; HFSMasterDirectoryBlock* mdb; -// UINTN i; + fsw_u32 firstLeafNum; + fsw_u64 catfOffset; + fsw_u8 cbuff[sizeof (BTNodeDescriptor) + sizeof (HFSPlusCatalogKey)]; rv = FSW_UNSUPPORTED; @@ -259,8 +261,6 @@ static fsw_status_t fsw_hfs_volume_mount(struct fsw_hfs_volume *vol) } else if (signature == kHFSSigWord) // 'BD' { -// HFSMasterDirectoryBlock* mdb = (HFSMasterDirectoryBlock*)buffer; -//VolumeName = mdb->drVN 28bytes if (be16_to_cpu(mdb->drEmbedSigWord) == kHFSPlusSigWord) { DPRINT("found HFS+ inside HFS, untested\n"); @@ -343,12 +343,33 @@ static fsw_status_t fsw_hfs_volume_mount(struct fsw_hfs_volume *vol) vol->catalog_tree.root_node = be32_to_cpu (tree_header.rootNode); vol->catalog_tree.node_size = be16_to_cpu (tree_header.nodeSize); -// /* get volume name */ -// s.type = FSW_STRING_TYPE_ISO88591; -// s.size = s.len = kHFSMaxVolumeNameChars; -// s.data = vol->catalog_tree.file->g.name.data; -// status = fsw_strdup_coerce(&vol->g.label, vol->g.host_string_type, &s); -// CHECK(status); + //nms42 + /* Take Volume Name before tree_header overwritten */ + firstLeafNum = be32_to_cpu(tree_header.firstLeafNode); + catfOffset = firstLeafNum * vol->catalog_tree.node_size; + + r = fsw_hfs_read_file(vol->catalog_tree.file, catfOffset, sizeof (cbuff), cbuff); + + if (r == sizeof (cbuff)) + { + BTNodeDescriptor* btnd; + HFSPlusCatalogKey* ck; + + btnd = (BTNodeDescriptor*) cbuff; + ck = (HFSPlusCatalogKey*) (cbuff + sizeof(BTNodeDescriptor)); + if (btnd->kind == kBTLeafNode && be32_to_cpu (ck->parentID) == kHFSRootParentID) + { + struct fsw_string vn; + + vn.type = FSW_STRING_TYPE_UTF16_BE; + vn.len = be16_to_cpu (ck->nodeName.length); + vn.size = vn.len * sizeof (fsw_u16); + vn.data = ck->nodeName.unicode; + fsw_strfree (&vol->g.label); + status = fsw_strdup_coerce(&vol->g.label, vol->g.host_string_type, &vn); + CHECK(status); + } // if + } // if /* Read extents overflow file */ r = fsw_hfs_read_file(vol->extents_tree.file, diff --git a/refind/main.c b/refind/main.c index 2daffe0..8b2412d 100644 --- a/refind/main.c +++ b/refind/main.c @@ -1354,7 +1354,8 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { // check for Microsoft boot loader/menu if (ShouldScan(Volume, L"EFI\\Microsoft\\Boot")) { StrCpy(FileName, L"EFI\\Microsoft\\Boot\\bkpbootmgfw.efi"); - if (FileExists(Volume->RootDir, FileName) && !FilenameIn(Volume, Directory, L"bkpbootmgfw.efi", GlobalConfig.DontScanFiles)) { + if (FileExists(Volume->RootDir, FileName) && !FilenameIn(Volume, Directory, L"bkpbootmgfw.efi", + GlobalConfig.DontScanFiles)) { AddLoaderEntry(FileName, L"Microsoft EFI boot (Boot Repair backup)", Volume); FoundBRBackup = TRUE; if (DuplicatesFallback(Volume, FileName)) -- 2.39.2