]> code.delx.au - refind/commitdiff
Added correct filesystem name detection to HFS+ driver.
authorsrs5694 <srs5694@users.sourceforge.net>
Sun, 20 Apr 2014 14:40:28 +0000 (10:40 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Sun, 20 Apr 2014 14:40:28 +0000 (10:40 -0400)
NEWS.txt
docs/refind/installing.html
filesystems/fsw_hfs.c
refind/main.c

index dbe119fdcdfaca7f3e6505aa933d42cbed41524e..b622b4bc99097ba1f2a078f78f5cce585962d94d 100644 (file)
--- 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.
index 31d62f59336a8e9f3b9de73a0b0ba0df34301d44..207eaad91ab45977deb87c5db8d96dbf432da8cf 100644 (file)
@@ -602,6 +602,8 @@ $ <b>ioreg -l -p IODeviceTree | grep firmware-abi</b>
 <h3>Installing rEFInd Manually Using an EFI Shell</h3>
 </a>
 
+<p class="sidebar"><b>Warning:</b> Do not attempt to use the procedure described in this section on a Macintosh. Macs have a strange EFI implementation that does not use the EFI variables that this procedure manipulates. Therefore, chances are this procedure simply won't work. It's conceivable that this procedure will actually cause problems, but I'm not curious enough to try it and risk damaging my Mac!</p>
+
 <p>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 <tt>bcfg</tt> 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.</p>
 
 <p>In addition to emergency situations, using <tt>bcfg</tt> can be desirable if <tt>efibootmgr</tt> 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 <a href="#naming">alternative names for rEFInd.</a></p>
index 27195680ac79a24b4449d9a32b5c7c54ae9bd4c0..deea0f8235014b585e2bb7e8bdd2de5bb472f573 100644 (file)
@@ -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,
index 2daffe0ed0924f44e07f9bdd4d2017fcc1398616..8b2412d2a8b0224023aa06a37d67789460896696 100644 (file)
@@ -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))