]> code.delx.au - refind/blobdiff - refind/lib.c
Version 0.7.0 release with misc. filesystem driver improvements.
[refind] / refind / lib.c
index bf2c2ef27b38e60f79a4840f5cf5abc7d930c124..5960f365fd7034ccf3491013d595fb601916dc80 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- * Modifications copyright (c) 2012 Roderick W. Smith
+ * Modifications copyright (c) 2012-2013 Roderick W. Smith
  * 
  * Modifications distributed under the terms of the GNU General Public
  * License (GPL) version 3 (GPLv3), a copy of which must be distributed
  * with this source code or binaries made from it.
- * 
+ *
  */
 
 #include "global.h"
@@ -48,6 +48,7 @@
 #include "screen.h"
 #include "../include/refit_call_wrapper.h"
 #include "../include/RemovableMedia.h"
+//#include "../include/UsbMass.h"
 
 #ifdef __MAKEWITH_GNUEFI
 #define EfiReallocatePool ReallocatePool
@@ -72,6 +73,7 @@ EFI_DEVICE_PATH EndDevicePath[] = {
 #define REISERFS_SUPER_MAGIC_STRING      "ReIsErFs"
 #define REISER2FS_SUPER_MAGIC_STRING     "ReIsEr2Fs"
 #define REISER2FS_JR_SUPER_MAGIC_STRING  "ReIsEr3Fs"
+#define BTRFS_SIGNATURE                  "_BHRfS_M"
 
 // variables
 
@@ -92,9 +94,6 @@ UINTN            VolumesCount = 0;
 // and identify its boot loader, and hence probable BIOS-mode OS installation
 #define SAMPLE_SIZE 69632 /* 68 KiB -- ReiserFS superblock begins at 64 KiB */
 
-// Default names for volume badges (mini-icon to define disk type) and icons
-#define VOLUME_BADGE_NAMES L".VolumeBadge.icns,.VolumeBadge.png"
-#define VOLUME_ICON_NAMES L".VolumeIcon.icns,.VolumeIcon.png"
 
 // functions
 
@@ -409,6 +408,9 @@ static CHAR16 *FSTypeName(IN UINT32 TypeCode) {
       case FS_TYPE_REISERFS:
          retval = L" ReiserFS";
          break;
+      case FS_TYPE_BTRFS:
+         retval = L" Btrfs";
+         break;
       case FS_TYPE_ISO9660:
          retval = L" ISO-9660";
          break;
@@ -460,6 +462,12 @@ static UINT32 IdentifyFilesystemType(IN UINT8 *Buffer, IN UINTN BufferSize) {
          } // if
       } // search for ReiserFS magic
 
+      if (BufferSize >= (65536 + 64 + 8)) {
+         MagicString = (char*) (Buffer + 65536 + 64);
+         if (CompareMem(MagicString, BTRFS_SIGNATURE, 8) == 0)
+            return FS_TYPE_BTRFS;
+      } // search for Btrfs magic
+
       if (BufferSize >= (1024 + 2)) {
          Magic16 = (UINT16*) (Buffer + 1024);
          if ((*Magic16 == HFSPLUS_MAGIC1) || (*Magic16 == HFSPLUS_MAGIC2)) {
@@ -469,7 +477,7 @@ static UINT32 IdentifyFilesystemType(IN UINT8 *Buffer, IN UINTN BufferSize) {
    } // if (Buffer != NULL)
 
    return FoundType;
-}
+} // UINT32 IdentifyFilesystemType()
 
 static VOID ScanVolumeBootcode(REFIT_VOLUME *Volume, BOOLEAN *Bootable)
 {
@@ -1153,13 +1161,15 @@ EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry,
             LastBufferSize = BufferSize;
         }
         if (EFI_ERROR(Status)) {
-            FreePool(Buffer);
+            MyFreePool(Buffer);
+            Buffer = NULL;
             break;
         }
 
         // check for end of listing
         if (BufferSize == 0) {    // end of directory listing
-            FreePool(Buffer);
+            MyFreePool(Buffer);
+            Buffer = NULL;
             break;
         }
 
@@ -1275,7 +1285,6 @@ BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR
             while (KeepGoing && (OnePattern = FindCommaDelimited(FilePattern, i++)) != NULL) {
                if (MetaiMatch(DirIter->LastFileInfo->FileName, OnePattern))
                    KeepGoing = FALSE;
-//               Print(L"%s did%s match %s\n", DirIter->LastFileInfo->FileName, KeepGoing ? L" not" : L"", OnePattern);
             } // while
             // else continue loop
         } else
@@ -1430,7 +1439,7 @@ VOID MergeStrings(IN OUT CHAR16 **First, IN CHAR16 *Second, CHAR16 AddChar) {
 CHAR16 *FindExtension(IN CHAR16 *Path) {
    CHAR16     *Extension;
    BOOLEAN    Found = FALSE, FoundSlash = FALSE;
-   UINTN       i;
+   INTN       i;
 
    Extension = AllocateZeroPool(sizeof(CHAR16));
    if (Path) {