]> code.delx.au - refind/commitdiff
Tweaks to disc-eject functionality.
authorsrs5694 <srs5694@users.sourceforge.net>
Sat, 19 May 2012 05:31:28 +0000 (01:31 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Sat, 19 May 2012 05:31:28 +0000 (01:31 -0400)
NEWS.txt
refind/lib.c
refind/lib.h
refind/menu.c

index b1334020cda2fc7c5a40308e1ba1bf9288ea51f7..84e1371cbbb0e34ed035cfdaf3eaac5e548be998 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,8 +1,10 @@
 0.3.6 (?/??/2012):
 ------------------
 
-- Added new feature to eject CDs (and other removable media): Press F12
-  to eject all such media.
+- Added new feature to eject CDs (and other removable media): Press F12 to
+  eject all such media. This function works only on some Macs, though (it
+  relies on an Apple-specific EFI extension, and this extension isn't even
+  implemented on all Macs, much less on UEFI-based PCs).
 
 - Fixed a problem that could cause GRUB 2 to fail to read its configuration
   file when launched from rEFInd.
index 2735fea54172624867e037100c740f4cce020ffd..be95e0c23d703f2058b39466a3582d3dab1eb0fe 100644 (file)
@@ -1281,16 +1281,17 @@ CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index) {
 
 static EFI_GUID AppleRemovableMediaGuid = APPLE_REMOVABLE_MEDIA_PROTOCOL_GUID;
 
-// Eject all removable media
-VOID EjectMedia(VOID) {
+// Eject all removable media.
+// Returns TRUE if any media were ejected, FALSE otherwise.
+BOOLEAN EjectMedia(VOID) {
    EFI_STATUS                      Status;
-   UINTN                           HandleIndex, HandleCount = 0;
+   UINTN                           HandleIndex, HandleCount = 0, Ejected = 0;
    EFI_HANDLE                      *Handles, Handle;
    APPLE_REMOVABLE_MEDIA_PROTOCOL  *Ejectable;
 
    Status = LibLocateHandle(ByProtocol, &AppleRemovableMediaGuid, NULL, &HandleCount, &Handles);
    if (EFI_ERROR(Status) || HandleCount == 0)
-      return; // probably not an Apple system
+      return (FALSE); // probably not an Apple system
 
    for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
       Handle = Handles[HandleIndex];
@@ -1298,6 +1299,9 @@ VOID EjectMedia(VOID) {
       if (EFI_ERROR(Status))
          continue;
       Status = refit_call1_wrapper(Ejectable->Eject, Ejectable);
+      if (!EFI_ERROR(Status))
+         Ejected++;
    }
    FreePool(Handles);
+   return (Ejected > 0);
 } // VOID EjectMedia()
index d502f8a9c24fe86f13eecdbc56aeaecad8d261a6..f7e9eda964eac71282481e255496c78a0dfdd92a 100644 (file)
@@ -105,6 +105,6 @@ CHAR16 *FindPath(IN CHAR16* FullPath);
 CHAR16 *FindNumbers(IN CHAR16 *InString);
 CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index);
 
-VOID EjectMedia(VOID);
+BOOLEAN EjectMedia(VOID);
 
 #endif
\ No newline at end of file
index 1ed2aa9999220e43db473d95c60dde9903aca39e..d35cd11c4ab46d71a18007cab2f874f7f83c4818 100644 (file)
@@ -461,9 +461,10 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
             case SCAN_F10:
                 egScreenShot();
                 break;
-                       case 0x0016: // F12
-                               EjectMedia();
-                               break;
+            case 0x0016: // F12
+               if (EjectMedia())
+                  MenuExit = MENU_EXIT_ESCAPE;
+               break;
         }
         switch (key.UnicodeChar) {
             case CHAR_LINEFEED: