From 2b17cbb8e38cd8fcbca11fe3751ca96f20d19788 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sat, 21 Apr 2012 00:58:01 -0400 Subject: [PATCH] Misc. small cleanups. --- docs/refind/drivers.html | 2 +- docs/refind/todo.html | 4 ++++ refind/lib.c | 38 ++++++++++++++++++++++---------------- refind/main.c | 24 ++++++++---------------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/docs/refind/drivers.html b/docs/refind/drivers.html index 5846704..8f09ae5 100644 --- a/docs/refind/drivers.html +++ b/docs/refind/drivers.html @@ -121,7 +121,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

  • rEFIt's ext2fs and ReiserFS drivers—You can gain read-only access to ext2fs, ext3fs, and ReiserFS volumes with these drivers. You can use the binaries in the refit-bin-0.14/efi/tools/drivers 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 thin program for this job.
  • -
  • Clover EFI's ISO-9660, ext2fs, and HFS+ drivers—This project is an offshoot of TianoCore, the main UEFI project. It's primarily a Hackintosh boot loader, but it includes drivers for ISO-9660, ext2fs, and HFS+; however, building them requires a fair amount of expertise. You can find a compile script for the ISO-9660 driver here, and a compiled ISO-9660 binary here. I haven't yet tested the compiled binary, much less tried to compile the source code.
  • +
  • Clover EFI's ISO-9660, ext2fs, and HFS+ drivers—This project is an offshoot of TianoCore, the main UEFI project. It's primarily a Hackintosh boot loader, but it includes drivers for ISO-9660, ext2fs, and HFS+; however, building them requires a fair amount of expertise. You can find a compile script for the ISO-9660 driver here, and a compiled ISO-9660 binary here. I haven't yet tested the compiled binary, much less tried to compile the source code.
  • Clover's EFI Tools package—This osx86.net thread includes links to a package called EFI_Tools_Clover_v2_r384_EFI_x32_x64_EN.zip, which holds an OS X application (a directory with a .app extension, as seen from other platforms) with a number of drivers in the Contents/Resources/EFI/drivers64 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 VBoxExt2-64.efi, NTFS-64.efi, and VBoxIso9600-64.efi.
  • diff --git a/docs/refind/todo.html b/docs/refind/todo.html index 4a30c17..21e0738 100644 --- a/docs/refind/todo.html +++ b/docs/refind/todo.html @@ -127,6 +127,10 @@ them on the project's Sourceforge page). For more information on designing theme
  • Returning from a program (such as an EFI shell or a boot loader that fails) produces an error message about a failure when "(re)opening our installation volume" on some computers. (Among mine, only a 32-bit Mac Mini produces this message.) In some cases, rEFInd then hangs. I don't fully understand its cause or why it doesn't appear on most systems. This needs investigating and fixing.
  • +
  • The Gigabyte Hybrid EFI has a bug that causes the allegedly case-insensitive StriCmp() function to perform a case-sensitive comparison. This causes any number of bugs in file matching. For instance: Changing the case of icon filename extensions (or various other parts of icon filenames) causes icons to be replaced by ugly "generic" ones; rEFInd sometimes appears in its own menu (the firmware sometimes returns an all-caps version of the filename, but other times returns the filename with the correct case, causing a mismatch if the path includes lowercase elements); and boot loaders will not be detected if their filenames use uppercase .EFI extensions. Some of these problems can be overcome by converting both strings to be compared to one case before doing the comparison, but others aren't so easy, since I think StriCmp() is being called internally to the EFI. In any event, it'd be nice to fix some of these problems. OTOH, this is a workaround for a bug on just one EFI implementation, and a dismal one at that, so I'm inclined to just let it go.
  • + +
  • I've received queries about rEFInd's ability to work with Apple's whole-disk encryption scheme that's new with OS X 10.7. Unfortunately, I lack the hardware to test this.
  • +
  • The Page Up and Page Down keys work in a rather strange way—a result of an admittedly quick fix on my part to a problem with a data structure that makes implementation of scrolling harder than it ought to be.
  • I'd like to find a way to enable users to enter customizations for boot options and then save them to the refind.conf file.
  • diff --git a/refind/lib.c b/refind/lib.c index 81b71ad..d19e21e 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -77,28 +77,38 @@ static VOID UninitVolumes(VOID); // self recognition stuff // -// Converts forward slashes to backslashes and removes duplicate slashes. +// Converts forward slashes to backslashes, removes duplicate slashes, and +// removes slashes from both the start and end of the pathname. // Necessary because some (buggy?) EFI implementations produce "\/" strings -// in pathnames and because some user inputs can produce duplicate directory -// separators +// in pathnames, because some user inputs can produce duplicate directory +// separators, and because we want consistent start and end slashes for +// directory comparisons. A special case: If the PathName refers to root, +// return "/", since some firmware implementations flake out if this +// isn't present. VOID CleanUpPathNameSlashes(IN OUT CHAR16 *PathName) { CHAR16 *NewName; - UINTN i, j = 0; + UINTN i, FinalChar = 0; BOOLEAN LastWasSlash = FALSE; - NewName = AllocateZeroPool(sizeof(CHAR16) * (StrLen(PathName) + 1)); + NewName = AllocateZeroPool(sizeof(CHAR16) * (StrLen(PathName) + 2)); if (NewName != NULL) { for (i = 0; i < StrLen(PathName); i++) { if ((PathName[i] == L'/') || (PathName[i] == L'\\')) { - if (!LastWasSlash) - NewName[j++] = L'\\'; + if ((!LastWasSlash) && (FinalChar != 0)) + NewName[FinalChar++] = L'\\'; LastWasSlash = TRUE; } else { - NewName[j++] = PathName[i]; + NewName[FinalChar++] = PathName[i]; LastWasSlash = FALSE; } // if/else } // for - NewName[j] = 0; + NewName[FinalChar] = 0; + if ((FinalChar > 0) && (NewName[FinalChar - 1] == L'\\')) + NewName[--FinalChar] = 0; + if (FinalChar == 0) { + NewName[0] = L'\\'; + NewName[1] = 0; + } // Copy the transformed name back.... StrCpy(PathName, NewName); FreePool(NewName); @@ -109,7 +119,6 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle) { EFI_STATUS Status; CHAR16 *DevicePathAsString; - UINTN i; SelfImageHandle = ImageHandle; Status = refit_call3_wrapper(BS->HandleProtocol, SelfImageHandle, &LoadedImageProtocol, (VOID **) &SelfLoadedImage); @@ -119,12 +128,9 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle) // find the current directory DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath); CleanUpPathNameSlashes(DevicePathAsString); - if (DevicePathAsString != NULL) { - for (i = StrLen(DevicePathAsString); (i > 0) && (DevicePathAsString[i] != '\\'); i--) ; - DevicePathAsString[i] = 0; - } else - DevicePathAsString[0] = 0; - SelfDirPath = StrDuplicate(DevicePathAsString); + if (SelfDirPath != NULL) + FreePool(SelfDirPath); + SelfDirPath = FindPath(DevicePathAsString); FreePool(DevicePathAsString); return FinishInitRefitLib(); diff --git a/refind/main.c b/refind/main.c index 0196aab..12d2b8f 100644 --- a/refind/main.c +++ b/refind/main.c @@ -55,7 +55,7 @@ // // variables -#define MACOSX_LOADER_PATH L"\\System\\Library\\CoreServices\\boot.efi" +#define MACOSX_LOADER_PATH L"System\\Library\\CoreServices\\boot.efi" #if defined (EFIX64) #define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\shellx64.efi" #elif defined (EFI32) @@ -615,7 +615,7 @@ LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN Entry = InitializeLoaderEntry(NULL); if (Entry != NULL) { Entry->Title = StrDuplicate(LoaderTitle); - Entry->me.Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath + 1, Volume->VolName); + Entry->me.Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath, Volume->VolName); Entry->me.Row = 0; Entry->me.BadgeImage = Volume->VolBadgeImage; Entry->LoaderPath = StrDuplicate(LoaderPath); @@ -636,18 +636,11 @@ static VOID ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path) EFI_STATUS Status; REFIT_DIR_ITER DirIter; EFI_FILE_INFO *DirEntry; - CHAR16 FileName[256], *SelfPath; - UINTN i = 0; + CHAR16 *FileName; - // Skip past leading slashes, which are sometimes (but not always) included - // in SelfDirPath, to get a path that's known to never include this feature. - while ((SelfDirPath != NULL) && (SelfDirPath[i] == L'\\')) { - i++; - } - SelfPath = &SelfDirPath[i]; // NOTE: *DO NOT* call FreePool() on SelfPath!!! - - if (!SelfPath || !Path || ((StriCmp(Path, SelfPath) == 0) && Volume != SelfVolume) || - (StriCmp(Path, SelfPath) != 0)) { + FileName = AllocateZeroPool(256 * sizeof(CHAR16)); + if ((!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && Volume != SelfVolume) || + (StriCmp(Path, SelfDirPath) != 0)) && FileName) { // look through contents of the directory DirIterOpen(Volume->RootDir, Path, &DirIter); while (DirIterNext(&DirIter, 2, L"*.efi", &DirEntry)) { @@ -690,13 +683,13 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { } // check for XOM - StrCpy(FileName, L"\\System\\Library\\CoreServices\\xom.efi"); + StrCpy(FileName, L"System\\Library\\CoreServices\\xom.efi"); if (FileExists(Volume->RootDir, FileName)) { AddLoaderEntry(FileName, L"Windows XP (XoM)", Volume); } // check for Microsoft boot loader/menu - StrCpy(FileName, L"\\EFI\\Microsoft\\Boot\\Bootmgfw.efi"); + StrCpy(FileName, L"EFI\\Microsoft\\Boot\\Bootmgfw.efi"); if (FileExists(Volume->RootDir, FileName)) { AddLoaderEntry(FileName, L"Microsoft EFI boot", Volume); } @@ -1224,7 +1217,6 @@ static VOID LoadDrivers(VOID) // load drivers from the "drivers" subdirectory of rEFInd's home directory Directory = StrDuplicate(SelfDirPath); MergeStrings(&Directory, L"drivers", L'\\'); -// SPrint(DirName, 255, L"%s\\drivers", SelfDirPath); NumFound += ScanDriverDir(Directory); // Scan additional user-specified driver directories.... -- 2.39.2