]> code.delx.au - refind/commitdiff
Improved BIOS-bootable detection code
authorsrs5694 <srs5694@users.sourceforge.net>
Sun, 29 Apr 2012 20:13:57 +0000 (16:13 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Sun, 29 Apr 2012 20:13:57 +0000 (16:13 -0400)
BUILDING.txt
Make.common
NEWS.txt
docs/refind/drivers.html
refind/lib.c
refind/main.c

index 1c4809953cc54f282eb438714f9ee4dd5cb79a66..3dcad8d2c6836527adeb9abd88ee8331d81ba69a 100644 (file)
@@ -103,6 +103,17 @@ remove "local" from those paths, and perhaps change references to "lib" to
 out-of-date GNU-EFI implementations that will not work with rEFInd 0.2.7
 and later.
 
+When I tried to compile rEFInd under Ubuntu 12.04 (i386), even with a
+locally-compiled GNU-EFI 3.0p, I got errors like this:
+
+main.o: In function `StartLegacy.isra.0':
+main.c:(.text+0x8b1): undefined reference to `__stack_chk_fail_local'
+lib.o: In function `ScanVolumeBootcode.part.3':
+lib.c:(.text+0xf2f): undefined reference to `__stack_chk_fail_local'
+lib.o: In function `ScanExtendedPartition.isra.4':
+
+The solution was to recompile GNU-EFI 3.0p with the -fno-stack-protector
+GCC flag. In GNU-EFI, this can be added to the CFLAGS line in Make.common.
 
 Installing rEFInd
 =================
index 3f6f85faf395dd48624495380acfcbcd0b4c79ff..edfe4602753629e0b1082f4f75b52d96fdfe7984 100644 (file)
@@ -15,7 +15,7 @@ CPPFLAGS        = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -DCONFIG_
 
 OPTIMFLAGS      = -O2 -fno-strict-aliasing
 DEBUGFLAGS      = -Wall
-CFLAGS          = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
+CFLAGS          = $(ARCH3264) $(OPTIMFLAGS) -fno-stack-protector -fpic -fshort-wchar $(DEBUGFLAGS)
 ASFLAGS         = $(ARCH3264)
 LDFLAGS         = -nostdlib -znocombreloc
 
index 8805b75a28273cf9e4bc83c54cd5995e52b19ddd..173d904b829b38137e5d7897d3b025d76fe03fc9 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,3 +1,13 @@
+0.3.2 (?/??/2012):
+------------------
+
+- Added detection "recipe" for GRUB 2's BIOS Boot Partition.
+
+- Fixed bogus detection of ESPs created by Linux's mkdosfs utility or
+  Windows as  bootable partitions when "scanfor" includes BIOS scanning
+  options.
+
+
 0.3.1 (4/27/2012):
 ------------------
 
index 6d1a4bea36102bc31f83537aec27203315806fc6..40ee0e5d9c22695222552a00436f12fff5e81cbc 100644 (file)
@@ -112,7 +112,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <p>To the best of my knowledge, the best reason to want EFI driver support in rEFInd is to provide access to filesystems. Although EFI filesystem driver choices are currently limited, those that are available can help to improve your installation and configuration options, particularly if you've found yourself "boxed in" by awkward installation or bugs, such as the dinky ESP that Ubuntu creates by default or the bug that prevents a Linux kernel with <a href="efistub.html">EFI stub loader support</a> from booting from the ESP of at least some Macs.</p>
 
-<p>As a side note, using the ISO-9660 driver might help you keep the size of a custom Linux boot CD/DVD down to a reasonable value. This is because EFI systems normally boot from optical discs by reading a FAT image file in El Torito format and treating that file as an ESP. If you need to store the kernel both in that file and directly in the ISO-9660 filesystem (to maintain bootability on BIOS systems), that can represent an unwanted extra space requirement. Placing rEFInd and an ISO-9660 driver in the FAT image file should enable you to store the kernel on the disc only once. Note, however, that this is theoretical; I've not yet tried creating a bootable disc in this way. Also, some EFI implementations include ISO-9660 drivers, so you might not need a separate ISO-9660 driver if you're building a disc for a particular computer.</p>
+<p>As a side note, using an ISO-9660 driver can theoretically help you keep the size of a custom Linux boot CD/DVD down to a reasonable value. This is because EFI systems normally boot from optical discs by reading a FAT image file in El Torito format and treating that file as an ESP. If you need to store the kernel both in that file and directly in the ISO-9660 filesystem (to maintain bootability on BIOS systems), that can represent an unwanted extra space requirement. Placing rEFInd and an ISO-9660 driver in the FAT image file should enable you to store the kernel on the disc only once. Unfortunately, my attempts to get this to work have failed to date. When the ISO-9660 driver is loaded from the El Torito image, my test systems seem to allow only one of the two filesystems (the El Torito image's FAT filesystem or the optical disc's ISO-9660 filesystem) to be active; load one and the other goes away. Also, some EFI implementations include ISO-9660 drivers, so you might not need a separate ISO-9660 driver if you're building a disc for a particular computer.</p>
 
 <h2>Finding and Installing EFI Drivers</h2>
 
@@ -122,7 +122,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <li><b><a href="http://refit.sourceforge.net">rEFIt's ext2fs and ReiserFS drivers</a></b>&mdash;You can gain read-only access to ext2fs, ext3fs, and ReiserFS volumes with these drivers. You can use the binaries in the <tt>refit-bin-0.14/efi/tools/drivers</tt> directory of the binary package directly on a Mac. On a UEFI-based PC, though, you'll need to break the Mac-style "fat" binary into its 32- and 64-bit components. You can use my <a href="http://www.rodsbooks.com/thin/index.html"><tt>thin</tt></a> program for this job.</li>
 
-<li><b><a href="https://sourceforge.net/projects/cloverefiboot/">Clover EFI's ISO-9660, ext2fs, and HFS+ drivers</a></b>&mdash;This project is an offshoot of TianoCore, the main UEFI project. It's primarily a Hackintosh boot loader, but it includes drivers for <a href="http://cloverefiboot.svn.sourceforge.net/viewvc/cloverefiboot/VBoxFsDxe/">ISO-9660, ext2fs, and HFS+;</a> however, building them requires a fair amount of expertise. You can find a compile script for the ISO-9660 driver <a href="https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/tianocore_uefi/iso9660_virtualbox_x86_64_udk_linux_compile.sh">here,</a> and a compiled ISO-9660 binary <a href="http://dl.dropbox.com/u/9710721/VBoxIso9600.efi">here.</a> I haven't yet tested the compiled binary, much less tried to compile the source code.</li>
+<li><b><a href="https://sourceforge.net/projects/cloverefiboot/">Clover EFI's ISO-9660, ext2fs, and HFS+ drivers</a></b>&mdash;This project is an offshoot of TianoCore, the main UEFI project. It's primarily a Hackintosh boot loader, but it includes drivers for <a href="http://cloverefiboot.svn.sourceforge.net/viewvc/cloverefiboot/VBoxFsDxe/">ISO-9660, ext2fs, and HFS+;</a> however, building them requires a fair amount of expertise. You can find a compile script for the ISO-9660 driver <a href="https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/tianocore_uefi/iso9660_virtualbox_x86_64_udk_linux_compile.sh">here,</a> and a compiled ISO-9660 binary <a href="http://dl.dropbox.com/u/9710721/VBoxIso9600.efi">here.</a> The compiled binary has worked in a brief test; however, it didn't give access to the ISO-9660 filesystem when it was loaded from an El Torito image the ISO-9660 filesystem held.</li>
 
 <li><b><a href="http://www.osx86.net/view/2571-clover_v2_r384__efi_bootloader_pkg_+_gpt_efi_tools.html">Clover's EFI Tools package</a></b>&mdash;This osx86.net thread includes links to a package called <tt>EFI_Tools_Clover_v2_r384_EFI_x32_x64_EN.zip</tt>, which holds an OS X application (a directory with a <tt>.app</tt> extension, as seen from other platforms) with a number of drivers in the <tt>Contents/Resources/EFI/drivers64</tt> directory (and an equivalent for 32-bit binaries). Some of these, such as keyboard drivers, are unlikely to be useful unless your system is badly broken as delivered. Three that caught my eye, however, are <tt>VBoxExt2-64.efi</tt>, <tt>NTFS-64.efi</tt>, and <tt>VBoxIso9600-64.efi</tt>.</li>
 
@@ -132,7 +132,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <p>Most of these cross-project drivers appear to be related. For instance, the ISO-9660 drivers are both based on code written by Christoph Phisterer for rEFIt (although he doesn't seem to have finished and released it in binary form himself).</p>
 
-<p>As you can see, pickings are rather slim. Nonetheless, they are useful for certain purposes. The options could increase in the future, too. Source code to a wide variety of filesystems is available in GRUB Legacy, GRUB 2, Linux, various BSD kernels, and in other projects. Sooner or later somebody's likely to begin porting those drivers to EFI. If you do so, or if you know of additional EFI drivers, please <a href="mailto:rodsmith@rodsbooks.com">tell me about it,</a> so I can share the information here. Likewise if you know of a source for other EFI drivers&mdash;say, for a video card or disk controller card.</p>
+<p>As you can see, pickings are rather slim. Nonetheless, the drivers that exist are useful for certain purposes. The options could increase in the future, too. Source code to a wide variety of filesystems is available in GRUB Legacy, GRUB 2, Linux, various BSD kernels, and in other projects. Sooner or later somebody's likely to begin porting those drivers to EFI. If you do so, or if you know of additional EFI drivers, please <a href="mailto:rodsmith@rodsbooks.com">tell me about it,</a> so I can share the information here. Likewise if you know of a source for other EFI drivers&mdash;say, for a video card or disk controller card.</p>
 
 <p class="sidebar"><b>Warning:</b> <i>Do not</i> place EFI program files in your driver directories! Unfortunately, EFI uses the same <tt>.efi</tt> filename extension to identify both EFI program files and EFI drivers. Therefore, rEFInd can't distinguish between the two prior to loading them, and if you place program files in a drivers directory, rEFInd will run the EFI program file when it does its driver scan.</p>
 
index fde385f46a595bf8227d3879735bfebc0451ea35..c7c5734b877a31bbfa81825bdbe65421b88ecf1f 100644 (file)
@@ -366,6 +366,14 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
             Volume->OSIconName = L"grub,linux";
             Volume->OSName = L"Linux";
 
+        // GRUB in BIOS boot partition:
+        } else if (FindMem(SectorBuffer, 512, "Geom\0Read\0 Error", 16) >= 0) {
+            Volume->HasBootCode = TRUE;
+            Volume->OSIconName = L"grub,linux";
+            Volume->OSName = L"Linux";
+            Volume->VolName = L"BIOS Boot Partition";
+            *Bootable = TRUE;
+
         } else if ((*((UINT32 *)(SectorBuffer + 502)) == 0 &&
                     *((UINT32 *)(SectorBuffer + 506)) == 50000 &&
                     *((UINT16 *)(SectorBuffer + 510)) == 0xaa55) ||
@@ -435,7 +443,16 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
               Volume->OSName, Volume->OSIconName);
 #endif
 
-        if (FindMem(SectorBuffer, 512, "Non-system disk", 15) >= 0)   // dummy FAT boot sector
+        // dummy FAT boot sector (created by OS X's newfs_msdos)
+        if (FindMem(SectorBuffer, 512, "Non-system disk", 15) >= 0)
+            Volume->HasBootCode = FALSE;
+
+        // dummy FAT boot sector (created by Linux's mkdosfs)
+        if (FindMem(SectorBuffer, 512, "This is not a bootable disk", 27) >= 0)
+            Volume->HasBootCode = FALSE;
+
+        // dummy FAT boot sector (created by Windows)
+        if (FindMem(SectorBuffer, 512, "Press any key to restart", 24) >= 0)
             Volume->HasBootCode = FALSE;
 
         // check for MBR partition table
@@ -461,7 +478,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
     }
 }
 
-// default volume icon based on disk kind
+// default volume badge icon based on disk kind
 static VOID ScanVolumeDefaultIcon(IN OUT REFIT_VOLUME *Volume)
 {
     switch (Volume->DiskKind) {
index 572f36aa1214e42c38ebf331f856791eec11df6a..6bdc3a16880528a09767c05a8276f457036503b7 100644 (file)
@@ -104,7 +104,7 @@ static VOID AboutrEFInd(VOID)
 {
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.3.1");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.3.1.2");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
@@ -1110,7 +1110,7 @@ static VOID ScanLegacyVolume(REFIT_VOLUME *Volume, UINTN VolumeIndex) {
          Volume->BlockIOOffset == 0 &&
          Volume->OSName == NULL)
          // this is a whole disk (MBR) entry; hide if we have entries for partitions
-      HideIfOthersFound = TRUE;
+         HideIfOthersFound = TRUE;
    }
    if (HideIfOthersFound) {
       // check for other bootable entries on the same disk