summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2013-11-21 22:51:52 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-11-21 22:51:52 +0000
commit64a5bae21fd84cc808170c4f0169435807959051 (patch)
treec6871d9ae54df9e68c21db50abfdf44a8da5f8bb /ShellPkg/Library
parentc37e0f16be2f36af9cc7ff7a304c1c94d6c3b7f6 (diff)
downloadedk2-platforms-64a5bae21fd84cc808170c4f0169435807959051.tar.xz
ShellPkg: Correctly support "map -c"
When “map –c” is run, the mapped items should be displayed with the consistent name as the one listed to the left and all other names listed as “alias(s)” Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Chris Phillips <chrisp@hp.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14881 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c91
1 files changed, 78 insertions, 13 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index bd004beaaf..590dbf79e3 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
@@ -397,10 +397,14 @@ PerformSingleMappingDisplay(
CHAR16 *MediaType;
CHAR16 *DevPathString;
CHAR16 *TempSpot;
+ CHAR16 *Alias;
UINTN TempLen;
BOOLEAN Removable;
CONST CHAR16 *TempSpot2;
+ Alias = NULL;
+ TempSpot2 = NULL;
+ CurrentName = NULL;
DevPath = DevicePathFromHandle(Handle);
DevPathCopy = DevPath;
MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
@@ -412,14 +416,74 @@ PerformSingleMappingDisplay(
return EFI_NOT_FOUND;
}
- CurrentName = NULL;
- CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
- if (CurrentName == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- TempSpot = StrStr(CurrentName, L";");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
+ if (Normal) {
+ //
+ // Allocate a name
+ //
+ CurrentName = NULL;
+ CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
+ if (CurrentName == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+
+ //
+ // Chop off the other names that become "Alias(s)"
+ // leaving just the normal name
+ //
+ TempSpot = StrStr(CurrentName, L";");
+ if (TempSpot != NULL) {
+ *TempSpot = CHAR_NULL;
+ }
+ } else if (Consist) {
+ CurrentName = NULL;
+
+ //
+ // Skip the first name. This is the standard name.
+ //
+ TempSpot = StrStr(MapList, L";");
+ if (TempSpot != NULL) {
+ TempSpot++;
+ }
+ SearchList(TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
+ if (CurrentName == NULL) {
+ SearchList(TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
+ }
+ if (CurrentName == NULL) {
+ SearchList(TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
+ }
+ if (CurrentName == NULL) {
+ SearchList(TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
+ }
+ if (CurrentName == NULL) {
+ //
+ // We didnt find anything, so just the first one in the list...
+ //
+ CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
+ if (CurrentName == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ TempSpot = StrStr(CurrentName, L";");
+ if (TempSpot != NULL) {
+ *TempSpot = CHAR_NULL;
+ }
+ } else {
+ Alias = StrnCatGrow(&Alias, 0, MapList, 0);
+ TempSpot = StrStr(Alias, CurrentName);
+ if (TempSpot != NULL) {
+ TempSpot2 = StrStr(TempSpot, L";");
+ if (TempSpot2 != NULL) {
+ TempSpot2++; // Move past ";" from CurrentName
+ CopyMem(TempSpot, TempSpot2, StrSize(TempSpot2));
+ } else {
+ *TempSpot = CHAR_NULL;
+ }
+ }
+ if (Alias[StrLen(Alias)-1] == L';') {
+ Alias[StrLen(Alias)-1] = CHAR_NULL;
+ }
+ }
+ } else {
+ CurrentName = NULL;
}
DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
if (!SFO) {
@@ -431,7 +495,7 @@ PerformSingleMappingDisplay(
STRING_TOKEN (STR_MAP_ENTRY),
gShellLevel2HiiHandle,
CurrentName,
- TempLen < StrLen(MapList)?MapList + TempLen+1:L"",
+ Alias!=NULL?Alias:(TempLen < StrLen(MapList)?MapList + TempLen+1:L""),
DevPathString
);
if (Verbose) {
@@ -454,7 +518,7 @@ PerformSingleMappingDisplay(
TempSpot2
);
}
- FreePool(MediaType);
+ SHELL_FREE_NON_NULL(MediaType);
}
} else {
TempLen = StrLen(CurrentName);
@@ -466,11 +530,12 @@ PerformSingleMappingDisplay(
gShellLevel2HiiHandle,
CurrentName,
DevPathString,
- TempLen < StrLen(MapList)?MapList + TempLen+1:L""
+ Consist?L"":(TempLen < StrLen(MapList)?MapList + TempLen+1:L"")
);
}
- FreePool(DevPathString);
- FreePool(CurrentName);
+ SHELL_FREE_NON_NULL(DevPathString);
+ SHELL_FREE_NON_NULL(CurrentName);
+ SHELL_FREE_NON_NULL(Alias);
return EFI_SUCCESS;
}