]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
ShellPkg/Dp: Add null pointer check
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Map.c
1 /** @file
2 Main file for map shell level 2 command.
3
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
7
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #include "UefiShellLevel2CommandsLib.h"
19 #include <Protocol/SimpleFileSystem.h>
20 #include <Protocol/BlockIo.h>
21 #include <Library/DevicePathLib.h>
22 #include <Library/HandleParsingLib.h>
23 #include <Library/SortLib.h>
24
25 /**
26 Determine if a string has only numbers and letters.
27
28 This is useful for such things as Map names which can only be letters and numbers.
29
30 @param[in] String pointer to the string to analyze,
31 @param[in] Len Number of characters to analyze.
32
33 @retval TRUE String has only numbers and letters
34 @retval FALSE String has at least one other character.
35 **/
36 BOOLEAN
37 IsNumberLetterOnly(
38 IN CONST CHAR16 *String,
39 IN CONST UINTN Len
40 )
41 {
42 UINTN Count;
43 for (Count = 0 ; Count < Len && String != NULL && *String != CHAR_NULL ; String++,Count++) {
44 if (! ((*String >= L'a' && *String <= L'z') ||
45 (*String >= L'A' && *String <= L'Z') ||
46 (*String >= L'0' && *String <= L'9'))
47 ){
48 return (FALSE);
49 }
50 }
51 return (TRUE);
52 }
53
54 /**
55 Do a search in the Target delimited list.
56
57 @param[in] List The list to seatch in.
58 @param[in] MetaTarget The item to search for. MetaMatching supported.
59 @param[out] FullName Optional pointer to an allocated buffer containing
60 the match.
61 @param[in] Meta TRUE to use MetaMatching.
62 @param[in] SkipTrailingNumbers TRUE to allow for numbers after the MetaTarget.
63 @param[in] Target The single character that delimits list
64 items (";" normally).
65 **/
66 BOOLEAN
67 SearchList(
68 IN CONST CHAR16 *List,
69 IN CONST CHAR16 *MetaTarget,
70 OUT CHAR16 **FullName OPTIONAL,
71 IN CONST BOOLEAN Meta,
72 IN CONST BOOLEAN SkipTrailingNumbers,
73 IN CONST CHAR16 *Target
74
75 )
76 {
77 CHAR16 *TempList;
78 CONST CHAR16 *ListWalker;
79 BOOLEAN Result;
80 CHAR16 *TempSpot;
81
82 for (ListWalker = List , TempList = NULL
83 ; ListWalker != NULL && *ListWalker != CHAR_NULL
84 ;
85 ) {
86 TempList = StrnCatGrow(&TempList, NULL, ListWalker, 0);
87 ASSERT(TempList != NULL);
88 TempSpot = StrStr(TempList, Target);
89 if (TempSpot != NULL) {
90 *TempSpot = CHAR_NULL;
91 }
92
93 while (SkipTrailingNumbers && (ShellIsDecimalDigitCharacter(TempList[StrLen(TempList)-1]) || TempList[StrLen(TempList)-1] == L':')) {
94 TempList[StrLen(TempList)-1] = CHAR_NULL;
95 }
96
97 ListWalker = StrStr(ListWalker, Target);
98 while(ListWalker != NULL && *ListWalker == *Target) {
99 ListWalker++;
100 }
101 if (Meta) {
102 Result = gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)TempList, (CHAR16*)MetaTarget);
103 } else {
104 Result = (BOOLEAN)(StrCmp(TempList, MetaTarget)==0);
105 }
106 if (Result) {
107 if (FullName != NULL) {
108 *FullName = TempList;
109 } else {
110 FreePool(TempList);
111 }
112 return (TRUE);
113 }
114 FreePool(TempList);
115 TempList = NULL;
116 }
117
118 return (FALSE);
119 }
120
121 /**
122 Determine what type of device is represented and return it's string. The
123 string is in allocated memory and must be callee freed. The HII is is listed below.
124 The actual string cannot be determined.
125
126 @param[in] DevicePath The device to analyze.
127
128 @retval STR_MAP_MEDIA_UNKNOWN The media type is unknown.
129 @retval STR_MAP_MEDIA_HARDDISK The media is a hard drive.
130 @retval STR_MAP_MEDIA_CDROM The media is a CD ROM.
131 @retval STR_MAP_MEDIA_FLOPPY The media is a floppy drive.
132 **/
133 CHAR16*
134 GetDeviceMediaType (
135 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
136 )
137 {
138 ACPI_HID_DEVICE_PATH *Acpi;
139
140 //
141 // Parse the device path:
142 // Devicepath sub type mediatype
143 // MEDIA_HANRDDRIVE_DP -> Hard Disk
144 // MEDIA_CDROM_DP -> CD Rom
145 // Acpi.HID = 0X0604 -> Floppy
146 //
147 if (NULL == DevicePath) {
148 return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_UNKNOWN), NULL);
149 }
150
151 for (;!IsDevicePathEndType (DevicePath) ;DevicePath = NextDevicePathNode (DevicePath)) {
152 if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) {
153 switch (DevicePathSubType (DevicePath)) {
154 case MEDIA_HARDDRIVE_DP:
155 return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_HARDDISK), NULL);
156 case MEDIA_CDROM_DP:
157 return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_CDROM), NULL);
158 }
159 } else if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH) {
160 Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
161 if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
162 return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_FLOPPY), NULL);
163 }
164 }
165 }
166
167 return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_UNKNOWN), NULL);
168 }
169
170 /**
171 Function to detemine if a handle has removable storage.
172
173 @param[in] DevicePath DevicePath to test.
174
175 @retval TRUE The handle has removable storage.
176 @retval FALSE The handle does not have removable storage.
177 **/
178 BOOLEAN
179 IsRemoveableDevice (
180 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
181 )
182 {
183 if (NULL == DevicePath) {
184 return FALSE;
185 }
186
187 while (!IsDevicePathEndType (DevicePath)) {
188 if (DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) {
189 switch (DevicePathSubType (DevicePath)) {
190 case MSG_USB_DP:
191 case MSG_SCSI_DP:
192 return TRUE;
193 default:
194 return FALSE;
195 }
196 }
197 DevicePath = NextDevicePathNode (DevicePath);
198 }
199 return FALSE;
200 }
201
202 /**
203 Function to detemine if a something on the map list matches.
204
205 @param[in] MapList The pointer to the list to test.
206 @param[in] Specific The pointer to a specific name to test for.
207 @param[in] TypeString The pointer to the list of types.
208 @param[in] Normal Always show normal mappings.
209 @param[in] Consist Always show consistent mappings.
210
211 @retval TRUE The map should be displayed.
212 @retval FALSE The map should not be displayed.
213 **/
214 BOOLEAN
215 MappingListHasType(
216 IN CONST CHAR16 *MapList,
217 IN CONST CHAR16 *Specific,
218 IN CONST CHAR16 *TypeString,
219 IN CONST BOOLEAN Normal,
220 IN CONST BOOLEAN Consist
221 )
222 {
223 CHAR16 *NewSpecific;
224 RETURN_STATUS Status;
225 UINTN Length;
226
227 //
228 // specific has priority
229 //
230 if (Specific != NULL) {
231 Length = StrLen (Specific);
232 //
233 // Allocate enough buffer for Specific and potential ":"
234 //
235 NewSpecific = AllocatePool ((Length + 2) * sizeof(CHAR16));
236 if (NewSpecific == NULL){
237 return FALSE;
238 }
239 StrCpyS (NewSpecific, Length + 2, Specific);
240 if (Specific[Length - 1] != L':') {
241 Status = StrnCatS(NewSpecific, Length + 2, L":", StrLen(L":"));
242 if (EFI_ERROR (Status)) {
243 FreePool(NewSpecific);
244 return FALSE;
245 }
246 }
247
248 if (SearchList(MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
249 FreePool(NewSpecific);
250 return (TRUE);
251 }
252 FreePool(NewSpecific);
253 }
254 if ( Consist
255 && Specific == NULL
256 && (SearchList(MapList, L"HD*", NULL, TRUE, TRUE, L";")
257 ||SearchList(MapList, L"CD*", NULL, TRUE, TRUE, L";")
258 ||SearchList(MapList, L"F*", NULL, TRUE, TRUE, L";")
259 ||SearchList(MapList, L"FP*", NULL, TRUE, TRUE, L";"))){
260 return (TRUE);
261 }
262
263 if ( Normal
264 && Specific == NULL
265 && (SearchList(MapList, L"FS", NULL, FALSE, TRUE, L";")
266 ||SearchList(MapList, L"BLK", NULL, FALSE, TRUE, L";"))){
267 return (TRUE);
268 }
269
270 if (TypeString != NULL && SearchList(MapList, TypeString, NULL, TRUE, TRUE, L";")) {
271 return (TRUE);
272 }
273 return (FALSE);
274 }
275
276
277 /**
278 Display a single map line for device Handle if conditions are met.
279
280 @param[in] Verbose TRUE to display (extra) verbose information.
281 @param[in] Consist TRUE to display consistent mappings.
282 @param[in] Normal TRUE to display normal (not consist) mappings.
283 @param[in] TypeString pointer to string of filter types.
284 @param[in] SFO TRUE to display output in Standard Output Format.
285 @param[in] Specific pointer to string for specific map to display.
286 @param[in] Handle The handle to display from.
287
288 @retval EFI_SUCCESS The mapping was displayed.
289 **/
290 EFI_STATUS
291 PerformSingleMappingDisplay(
292 IN CONST BOOLEAN Verbose,
293 IN CONST BOOLEAN Consist,
294 IN CONST BOOLEAN Normal,
295 IN CONST CHAR16 *TypeString,
296 IN CONST BOOLEAN SFO,
297 IN CONST CHAR16 *Specific OPTIONAL,
298 IN CONST EFI_HANDLE Handle
299 )
300 {
301 EFI_DEVICE_PATH_PROTOCOL *DevPath;
302 EFI_DEVICE_PATH_PROTOCOL *DevPathCopy;
303 CONST CHAR16 *MapList;
304 CHAR16 *CurrentName;
305 CHAR16 *MediaType;
306 CHAR16 *DevPathString;
307 CHAR16 *TempSpot;
308 CHAR16 *Alias;
309 UINTN TempLen;
310 BOOLEAN Removable;
311 CONST CHAR16 *TempSpot2;
312
313 Alias = NULL;
314 TempSpot2 = NULL;
315 CurrentName = NULL;
316 DevPath = DevicePathFromHandle(Handle);
317 DevPathCopy = DevPath;
318 MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
319 if (MapList == NULL) {
320 return EFI_NOT_FOUND;
321 }
322
323 if (!MappingListHasType(MapList, Specific, TypeString, Normal, Consist)){
324 return EFI_NOT_FOUND;
325 }
326
327 if (Normal || !Consist) {
328 //
329 // need the Normal here since people can use both on command line. otherwise unused.
330 //
331
332 //
333 // Allocate a name
334 //
335 CurrentName = NULL;
336 CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
337 if (CurrentName == NULL) {
338 return (EFI_OUT_OF_RESOURCES);
339 }
340
341 //
342 // Chop off the other names that become "Alias(s)"
343 // leaving just the normal name
344 //
345 TempSpot = StrStr(CurrentName, L";");
346 if (TempSpot != NULL) {
347 *TempSpot = CHAR_NULL;
348 }
349 } else {
350 CurrentName = NULL;
351
352 //
353 // Skip the first name. This is the standard name.
354 //
355 TempSpot = StrStr(MapList, L";");
356 if (TempSpot != NULL) {
357 TempSpot++;
358 }
359 SearchList(TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
360 if (CurrentName == NULL) {
361 SearchList(TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
362 }
363 if (CurrentName == NULL) {
364 SearchList(TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
365 }
366 if (CurrentName == NULL) {
367 SearchList(TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
368 }
369 if (CurrentName == NULL) {
370 //
371 // We didnt find anything, so just the first one in the list...
372 //
373 CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
374 if (CurrentName == NULL) {
375 return (EFI_OUT_OF_RESOURCES);
376 }
377 TempSpot = StrStr(CurrentName, L";");
378 if (TempSpot != NULL) {
379 *TempSpot = CHAR_NULL;
380 }
381 } else {
382 Alias = StrnCatGrow(&Alias, 0, MapList, 0);
383 if (Alias == NULL) {
384 return EFI_OUT_OF_RESOURCES;
385 }
386 TempSpot = StrStr(Alias, CurrentName);
387 if (TempSpot != NULL) {
388 TempSpot2 = StrStr(TempSpot, L";");
389 if (TempSpot2 != NULL) {
390 TempSpot2++; // Move past ";" from CurrentName
391 CopyMem(TempSpot, TempSpot2, StrSize(TempSpot2));
392 } else {
393 *TempSpot = CHAR_NULL;
394 }
395 }
396 if (Alias[StrLen(Alias)-1] == L';') {
397 Alias[StrLen(Alias)-1] = CHAR_NULL;
398 }
399 }
400 }
401 DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
402 TempLen = StrLen(CurrentName);
403 if (!SFO) {
404 ShellPrintHiiEx (
405 -1,
406 -1,
407 NULL,
408 STRING_TOKEN (STR_MAP_ENTRY),
409 gShellLevel2HiiHandle,
410 CurrentName,
411 Alias!=NULL?Alias:(TempLen < StrLen(MapList)?MapList + TempLen+1:L""),
412 DevPathString
413 );
414 if (Verbose) {
415 //
416 // also print handle, media type, removable (y/n), and current directory
417 //
418 MediaType = GetDeviceMediaType(DevPath);
419 if ((TypeString != NULL &&MediaType != NULL && StrStr(TypeString, MediaType) != NULL) || TypeString == NULL) {
420 Removable = IsRemoveableDevice(DevPath);
421 TempSpot2 = ShellGetCurrentDir(CurrentName);
422 ShellPrintHiiEx (
423 -1,
424 -1,
425 NULL,
426 STRING_TOKEN (STR_MAP_ENTRY_VERBOSE),
427 gShellLevel2HiiHandle,
428 ConvertHandleToHandleIndex(Handle),
429 MediaType,
430 Removable?L"Yes":L"No",
431 TempSpot2
432 );
433 }
434 SHELL_FREE_NON_NULL(MediaType);
435 }
436 } else {
437 ShellPrintHiiEx (
438 -1,
439 -1,
440 NULL,
441 STRING_TOKEN (STR_MAP_SFO_MAPPINGS),
442 gShellLevel2HiiHandle,
443 CurrentName,
444 DevPathString,
445 Consist?L"":(TempLen < StrLen(MapList)?MapList + TempLen+1:L"")
446 );
447 }
448 SHELL_FREE_NON_NULL(DevPathString);
449 SHELL_FREE_NON_NULL(CurrentName);
450 SHELL_FREE_NON_NULL(Alias);
451 return EFI_SUCCESS;
452 }
453
454 /**
455 Delete Specific from the list of maps for device Handle.
456
457 @param[in] Specific The name to delete.
458 @param[in] Handle The device to look on.
459
460 @retval EFI_SUCCESS The delete was successful.
461 @retval EFI_NOT_FOUND Name was not a map on Handle.
462 **/
463 EFI_STATUS
464 PerformSingleMappingDelete(
465 IN CONST CHAR16 *Specific,
466 IN CONST EFI_HANDLE Handle
467 )
468 {
469 EFI_DEVICE_PATH_PROTOCOL *DevPath;
470 EFI_DEVICE_PATH_PROTOCOL *DevPathCopy;
471 CONST CHAR16 *MapList;
472 CHAR16 *CurrentName;
473
474 DevPath = DevicePathFromHandle(Handle);
475 DevPathCopy = DevPath;
476 MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
477 CurrentName = NULL;
478
479 if (MapList == NULL) {
480 return (EFI_NOT_FOUND);
481 }
482 //
483 // if there is a specific and its not on the list...
484 //
485 if (!SearchList(MapList, Specific, &CurrentName, TRUE, FALSE, L";")) {
486 return (EFI_NOT_FOUND);
487 }
488 return (gEfiShellProtocol->SetMap(NULL, CurrentName));
489 }
490
491 CONST CHAR16 Cd[] = L"cd*";
492 CONST CHAR16 Hd[] = L"hd*";
493 CONST CHAR16 Fp[] = L"fp*";
494 CONST CHAR16 AnyF[] = L"F*";
495 /**
496 Function to display mapping information to the user.
497
498 If Specific is specified then Consist and Normal will be ignored since information will
499 be printed for the specific item only.
500
501 @param[in] Verbose TRUE to display (extra) verbose information.
502 @param[in] Consist TRUE to display consistent mappings.
503 @param[in] Normal TRUE to display normal (not consist) mappings.
504 @param[in] TypeString Pointer to string of filter types.
505 @param[in] SFO TRUE to display output in Standard Output Format.
506 @param[in] Specific Pointer to string for specific map to display.
507 @param[in] Header TRUE to print the header block.
508
509 @retval SHELL_SUCCESS The display was printed.
510 @retval SHELL_INVALID_PARAMETER One of Consist or Normal must be TRUE if no Specific.
511
512 **/
513 SHELL_STATUS
514 PerformMappingDisplay(
515 IN CONST BOOLEAN Verbose,
516 IN CONST BOOLEAN Consist,
517 IN CONST BOOLEAN Normal,
518 IN CONST CHAR16 *TypeString,
519 IN CONST BOOLEAN SFO,
520 IN CONST CHAR16 *Specific OPTIONAL,
521 IN CONST BOOLEAN Header
522 )
523 {
524 EFI_STATUS Status;
525 EFI_HANDLE *HandleBuffer;
526 UINTN BufferSize;
527 UINTN LoopVar;
528 CHAR16 *Test;
529 BOOLEAN Found;
530
531 if (!Consist && !Normal && Specific == NULL && TypeString == NULL) {
532 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
533 return (SHELL_INVALID_PARAMETER);
534 }
535
536 if (TypeString != NULL) {
537 Test = (CHAR16*)Cd;
538 if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
539 Test = (CHAR16*)Hd;
540 if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
541 Test = (CHAR16*)Fp;
542 if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
543 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", TypeString);
544 return (SHELL_INVALID_PARAMETER);
545 }
546 } else if (Test == NULL) {
547 Test = (CHAR16*)AnyF;
548 }
549 }
550 } else {
551 Test = NULL;
552 }
553
554 if (Header) {
555 //
556 // Print the header
557 //
558 if (!SFO) {
559 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_HEADER), gShellLevel2HiiHandle);
560 } else {
561 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"map");
562 }
563 }
564
565 BufferSize = 0;
566 HandleBuffer = NULL;
567
568 //
569 // Look up all SimpleFileSystems in the platform
570 //
571 Status = gBS->LocateHandle(
572 ByProtocol,
573 &gEfiSimpleFileSystemProtocolGuid,
574 NULL,
575 &BufferSize,
576 HandleBuffer);
577 if (Status == EFI_BUFFER_TOO_SMALL) {
578 HandleBuffer = AllocateZeroPool(BufferSize);
579 if (HandleBuffer == NULL) {
580 return (SHELL_OUT_OF_RESOURCES);
581 }
582 Status = gBS->LocateHandle(
583 ByProtocol,
584 &gEfiSimpleFileSystemProtocolGuid,
585 NULL,
586 &BufferSize,
587 HandleBuffer);
588 }
589
590 //
591 // Get the map name(s) for each one.
592 //
593 for ( LoopVar = 0, Found = FALSE
594 ; LoopVar < (BufferSize / sizeof(EFI_HANDLE)) && HandleBuffer != NULL
595 ; LoopVar ++
596 ){
597 Status = PerformSingleMappingDisplay(
598 Verbose,
599 Consist,
600 Normal,
601 Test,
602 SFO,
603 Specific,
604 HandleBuffer[LoopVar]);
605 if (!EFI_ERROR(Status)) {
606 Found = TRUE;
607 }
608 }
609
610 //
611 // Look up all BlockIo in the platform
612 //
613 Status = gBS->LocateHandle(
614 ByProtocol,
615 &gEfiBlockIoProtocolGuid,
616 NULL,
617 &BufferSize,
618 HandleBuffer);
619 if (Status == EFI_BUFFER_TOO_SMALL) {
620 SHELL_FREE_NON_NULL(HandleBuffer);
621 HandleBuffer = AllocateZeroPool(BufferSize);
622 if (HandleBuffer == NULL) {
623 return (SHELL_OUT_OF_RESOURCES);
624 }
625 Status = gBS->LocateHandle(
626 ByProtocol,
627 &gEfiBlockIoProtocolGuid,
628 NULL,
629 &BufferSize,
630 HandleBuffer);
631 }
632 if (!EFI_ERROR(Status) && HandleBuffer != NULL) {
633 //
634 // Get the map name(s) for each one.
635 //
636 for ( LoopVar = 0
637 ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
638 ; LoopVar ++
639 ){
640 //
641 // Skip any that were already done...
642 //
643 if (gBS->OpenProtocol(
644 HandleBuffer[LoopVar],
645 &gEfiSimpleFileSystemProtocolGuid,
646 NULL,
647 gImageHandle,
648 NULL,
649 EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
650 continue;
651 }
652 Status = PerformSingleMappingDisplay(
653 Verbose,
654 Consist,
655 Normal,
656 Test,
657 SFO,
658 Specific,
659 HandleBuffer[LoopVar]);
660 if (!EFI_ERROR(Status)) {
661 Found = TRUE;
662 }
663 }
664 FreePool(HandleBuffer);
665 }
666 if (!Found) {
667 if (Specific != NULL) {
668 ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", Specific);
669 } else {
670 ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"map");
671 }
672 }
673 return (SHELL_SUCCESS);
674 }
675
676 /**
677 Perform a mapping display and parse for multiple types in the TypeString.
678
679 @param[in] Verbose TRUE to use verbose output.
680 @param[in] Consist TRUE to display consistent names.
681 @param[in] Normal TRUE to display normal names.
682 @param[in] TypeString An optional comma-delimited list of types.
683 @param[in] SFO TRUE to display in SFO format. See Spec.
684 @param[in] Specific An optional specific map name to display alone.
685
686 @retval SHELL_INVALID_PARAMETER A parameter was invalid.
687 @retval SHELL_SUCCESS The display was successful.
688 @sa PerformMappingDisplay
689 **/
690 SHELL_STATUS
691 PerformMappingDisplay2(
692 IN CONST BOOLEAN Verbose,
693 IN CONST BOOLEAN Consist,
694 IN CONST BOOLEAN Normal,
695 IN CONST CHAR16 *TypeString,
696 IN CONST BOOLEAN SFO,
697 IN CONST CHAR16 *Specific OPTIONAL
698 )
699 {
700 CONST CHAR16 *TypeWalker;
701 SHELL_STATUS ShellStatus;
702 CHAR16 *Comma;
703
704
705 if (TypeString == NULL) {
706 return (PerformMappingDisplay(Verbose, Consist, Normal, NULL, SFO, Specific, TRUE));
707 }
708 ShellStatus = SHELL_SUCCESS;
709 for (TypeWalker = TypeString ; TypeWalker != NULL && *TypeWalker != CHAR_NULL ;) {
710 Comma = StrStr(TypeWalker, L",");
711 if (Comma == NULL) {
712 if (ShellStatus == SHELL_SUCCESS) {
713 ShellStatus = PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
714 } else {
715 PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
716 }
717 break;
718 } else {
719 *Comma = CHAR_NULL;
720 if (ShellStatus == SHELL_SUCCESS) {
721 ShellStatus = PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
722 } else {
723 PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
724 }
725 *Comma = L',';
726 TypeWalker = Comma + 1;
727 }
728 }
729
730 return (ShellStatus);
731 }
732
733 /**
734 Delete a specific map.
735
736 @param[in] Specific The pointer to the name of the map to delete.
737
738 @retval EFI_INVALID_PARAMETER Specific was NULL.
739 @retval EFI_SUCCESS The operation was successful.
740 @retval EFI_NOT_FOUND Specific could not be found.
741 **/
742 EFI_STATUS
743 PerformMappingDelete(
744 IN CONST CHAR16 *Specific
745 )
746 {
747 EFI_STATUS Status;
748 EFI_HANDLE *HandleBuffer;
749 UINTN BufferSize;
750 UINTN LoopVar;
751 BOOLEAN Deleted;
752
753 if (Specific == NULL) {
754 return (EFI_INVALID_PARAMETER);
755 }
756
757 BufferSize = 0;
758 HandleBuffer = NULL;
759 Deleted = FALSE;
760
761 //
762 // Look up all SimpleFileSystems in the platform
763 //
764 Status = gBS->LocateHandle(
765 ByProtocol,
766 &gEfiDevicePathProtocolGuid,
767 NULL,
768 &BufferSize,
769 HandleBuffer);
770 if (Status == EFI_BUFFER_TOO_SMALL) {
771 HandleBuffer = AllocateZeroPool(BufferSize);
772 if (HandleBuffer == NULL) {
773 return (EFI_OUT_OF_RESOURCES);
774 }
775 Status = gBS->LocateHandle(
776 ByProtocol,
777 &gEfiDevicePathProtocolGuid,
778 NULL,
779 &BufferSize,
780 HandleBuffer);
781 }
782 if (EFI_ERROR(Status)) {
783 SHELL_FREE_NON_NULL(HandleBuffer);
784 return (Status);
785 }
786
787 if (HandleBuffer != NULL) {
788 //
789 // Get the map name(s) for each one.
790 //
791 for ( LoopVar = 0
792 ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
793 ; LoopVar ++
794 ){
795 if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
796 Deleted = TRUE;
797 }
798 }
799 }
800 //
801 // Look up all BlockIo in the platform
802 //
803 Status = gBS->LocateHandle(
804 ByProtocol,
805 &gEfiBlockIoProtocolGuid,
806 NULL,
807 &BufferSize,
808 HandleBuffer);
809 if (Status == EFI_BUFFER_TOO_SMALL) {
810 FreePool(HandleBuffer);
811 HandleBuffer = AllocateZeroPool(BufferSize);
812 if (HandleBuffer == NULL) {
813 return (EFI_OUT_OF_RESOURCES);
814 }
815 Status = gBS->LocateHandle(
816 ByProtocol,
817 &gEfiBlockIoProtocolGuid,
818 NULL,
819 &BufferSize,
820 HandleBuffer);
821 }
822 if (EFI_ERROR(Status)) {
823 SHELL_FREE_NON_NULL(HandleBuffer);
824 return (Status);
825 }
826
827 if (HandleBuffer != NULL) {
828 //
829 // Get the map name(s) for each one.
830 //
831 for ( LoopVar = 0
832 ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
833 ; LoopVar ++
834 ){
835 //
836 // Skip any that were already done...
837 //
838 if (gBS->OpenProtocol(
839 HandleBuffer[LoopVar],
840 &gEfiDevicePathProtocolGuid,
841 NULL,
842 gImageHandle,
843 NULL,
844 EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
845 continue;
846 }
847 if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
848 Deleted = TRUE;
849 }
850 }
851 }
852 SHELL_FREE_NON_NULL(HandleBuffer);
853 if (!Deleted) {
854 return (EFI_NOT_FOUND);
855 }
856 return (EFI_SUCCESS);
857 }
858
859 /**
860 function to add a mapping from mapping.
861
862 This function will get the device path associated with the mapping and call SetMap.
863
864 @param[in] Map The Map to add a mapping for
865 @param[in] SName The name of the new mapping
866
867 @retval SHELL_SUCCESS the mapping was added
868 @retval SHELL_INVALID_PARAMETER the device path for Map could not be retrieved.
869 @return Shell version of a return value from EfiShellProtocol->SetMap
870
871 **/
872 SHELL_STATUS
873 AddMappingFromMapping(
874 IN CONST CHAR16 *Map,
875 IN CONST CHAR16 *SName
876 )
877 {
878 CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
879 EFI_STATUS Status;
880 CHAR16 *NewSName;
881 RETURN_STATUS StrRetStatus;
882
883 NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
884 if (NewSName == NULL) {
885 return (SHELL_OUT_OF_RESOURCES);
886 }
887 if (NewSName[StrLen(NewSName)-1] != L':') {
888 StrRetStatus = StrnCatS(NewSName, (StrSize(SName) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
889 if (EFI_ERROR(StrRetStatus)) {
890 FreePool(NewSName);
891 return ((SHELL_STATUS) (StrRetStatus & (~MAX_BIT)));
892 }
893 }
894
895 if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
896 FreePool(NewSName);
897 return (SHELL_INVALID_PARAMETER);
898 }
899
900 DevPath = gEfiShellProtocol->GetDevicePathFromMap(Map);
901 if (DevPath == NULL) {
902 FreePool(NewSName);
903 return (SHELL_INVALID_PARAMETER);
904 }
905
906 Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
907 FreePool(NewSName);
908 if (EFI_ERROR(Status)) {
909 return (SHELL_DEVICE_ERROR);
910 }
911 return (SHELL_SUCCESS);
912 }
913
914 /**
915 function to add a mapping from an EFI_HANDLE.
916
917 This function will get the device path associated with the Handle and call SetMap.
918
919 @param[in] Handle The handle to add a mapping for
920 @param[in] SName The name of the new mapping
921
922 @retval SHELL_SUCCESS the mapping was added
923 @retval SHELL_INVALID_PARAMETER SName was not valid for a map name.
924 @return Shell version of a return value from either
925 gBS->OpenProtocol or EfiShellProtocol->SetMap
926
927 **/
928 SHELL_STATUS
929 AddMappingFromHandle(
930 IN CONST EFI_HANDLE Handle,
931 IN CONST CHAR16 *SName
932 )
933 {
934 EFI_DEVICE_PATH_PROTOCOL *DevPath;
935 EFI_STATUS Status;
936 CHAR16 *NewSName;
937 RETURN_STATUS StrRetStatus;
938
939 NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
940 if (NewSName == NULL) {
941 return (SHELL_OUT_OF_RESOURCES);
942 }
943 if (NewSName[StrLen(NewSName)-1] != L':') {
944 StrRetStatus = StrnCatS(NewSName, (StrSize(SName) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
945 if (EFI_ERROR(StrRetStatus)) {
946 FreePool(NewSName);
947 return ((SHELL_STATUS) (StrRetStatus & (~MAX_BIT)));
948 }
949 }
950
951 if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
952 FreePool(NewSName);
953 return (SHELL_INVALID_PARAMETER);
954 }
955
956 Status = gBS->OpenProtocol(
957 Handle,
958 &gEfiDevicePathProtocolGuid,
959 (VOID**)&DevPath,
960 gImageHandle,
961 NULL,
962 EFI_OPEN_PROTOCOL_GET_PROTOCOL
963 );
964 if (EFI_ERROR(Status)) {
965 FreePool(NewSName);
966 return (SHELL_DEVICE_ERROR);
967 }
968 Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
969 FreePool(NewSName);
970 if (EFI_ERROR(Status)) {
971 return (SHELL_DEVICE_ERROR);
972 }
973 return (SHELL_SUCCESS);
974 }
975
976 STATIC CONST SHELL_PARAM_ITEM MapParamList[] = {
977 {L"-d", TypeValue},
978 {L"-r", TypeFlag},
979 {L"-v", TypeFlag},
980 {L"-c", TypeFlag},
981 {L"-f", TypeFlag},
982 {L"-u", TypeFlag},
983 {L"-t", TypeValue},
984 {L"-sfo", TypeValue},
985 {NULL, TypeMax}
986 };
987
988 /**
989 The routine issues dummy read for every physical block device to cause
990 the BlockIo re-installed if media change happened.
991 **/
992 VOID
993 ProbeForMediaChange (
994 VOID
995 )
996 {
997 EFI_STATUS Status;
998 UINTN HandleCount;
999 EFI_HANDLE *Handles;
1000 EFI_BLOCK_IO_PROTOCOL *BlockIo;
1001 UINTN Index;
1002
1003 gBS->LocateHandleBuffer (
1004 ByProtocol,
1005 &gEfiBlockIoProtocolGuid,
1006 NULL,
1007 &HandleCount,
1008 &Handles
1009 );
1010 //
1011 // Probe for media change for every physical block io
1012 //
1013 for (Index = 0; Index < HandleCount; Index++) {
1014 Status = gBS->HandleProtocol (
1015 Handles[Index],
1016 &gEfiBlockIoProtocolGuid,
1017 (VOID **) &BlockIo
1018 );
1019 if (!EFI_ERROR (Status)) {
1020 if (!BlockIo->Media->LogicalPartition) {
1021 //
1022 // Per spec:
1023 // The function (ReadBlocks) must return EFI_NO_MEDIA or
1024 // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe
1025 // for changes in media state.
1026 //
1027 BlockIo->ReadBlocks (
1028 BlockIo,
1029 BlockIo->Media->MediaId,
1030 0,
1031 0,
1032 NULL
1033 );
1034 }
1035 }
1036 }
1037 }
1038
1039 /**
1040 Function for 'map' command.
1041
1042 @param[in] ImageHandle Handle to the Image (NULL if Internal).
1043 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
1044 **/
1045 SHELL_STATUS
1046 EFIAPI
1047 ShellCommandRunMap (
1048 IN EFI_HANDLE ImageHandle,
1049 IN EFI_SYSTEM_TABLE *SystemTable
1050 )
1051 {
1052 EFI_STATUS Status;
1053 LIST_ENTRY *Package;
1054 CHAR16 *ProblemParam;
1055 CONST CHAR16 *SName;
1056 CONST CHAR16 *Mapping;
1057 EFI_HANDLE MapAsHandle;
1058 SHELL_STATUS ShellStatus;
1059 BOOLEAN SfoMode;
1060 BOOLEAN ConstMode;
1061 BOOLEAN NormlMode;
1062 CONST CHAR16 *Param1;
1063 CONST CHAR16 *TypeString;
1064 UINTN TempStringLength;
1065
1066 ProblemParam = NULL;
1067 Mapping = NULL;
1068 SName = NULL;
1069 ShellStatus = SHELL_SUCCESS;
1070 MapAsHandle = NULL;
1071
1072 //
1073 // initialize the shell lib (we must be in non-auto-init...)
1074 //
1075 Status = ShellInitialize();
1076 ASSERT_EFI_ERROR(Status);
1077
1078 Status = CommandInit();
1079 ASSERT_EFI_ERROR(Status);
1080
1081 //
1082 // parse the command line
1083 //
1084 Status = ShellCommandLineParse (MapParamList, &Package, &ProblemParam, TRUE);
1085 if (EFI_ERROR(Status)) {
1086 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
1087 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"map", ProblemParam);
1088 FreePool(ProblemParam);
1089 ShellStatus = SHELL_INVALID_PARAMETER;
1090 } else {
1091 ASSERT(FALSE);
1092 }
1093 } else {
1094 //
1095 // check for "-?"
1096 //
1097 SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
1098 ConstMode = ShellCommandLineGetFlag(Package, L"-c");
1099 NormlMode = ShellCommandLineGetFlag(Package, L"-f");
1100 if (ShellCommandLineGetFlag(Package, L"-?")) {
1101 ASSERT(FALSE);
1102 } else if (ShellCommandLineGetRawValue(Package, 3) != NULL) {
1103 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"map");
1104 ShellStatus = SHELL_INVALID_PARAMETER;
1105 } else {
1106 //
1107 // Deleting a map name...
1108 //
1109 if (ShellCommandLineGetFlag(Package, L"-d")) {
1110 if ( ShellCommandLineGetFlag(Package, L"-r")
1111 || ShellCommandLineGetFlag(Package, L"-v")
1112 || ConstMode
1113 || NormlMode
1114 || ShellCommandLineGetFlag(Package, L"-u")
1115 || ShellCommandLineGetFlag(Package, L"-t")
1116 ){
1117 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"map");
1118 ShellStatus = SHELL_INVALID_PARAMETER;
1119 } else {
1120 SName = ShellCommandLineGetValue(Package, L"-d");
1121 if (SName != NULL) {
1122 Status = PerformMappingDelete(SName);
1123 if (EFI_ERROR(Status)) {
1124 if (Status == EFI_ACCESS_DENIED) {
1125 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
1126 ShellStatus = SHELL_ACCESS_DENIED;
1127 } else if (Status == EFI_NOT_FOUND) {
1128 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", SName);
1129 ShellStatus = SHELL_INVALID_PARAMETER;
1130 } else {
1131 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
1132 ShellStatus = SHELL_UNSUPPORTED;
1133 }
1134 }
1135 } else {
1136 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
1137 ShellStatus = SHELL_INVALID_PARAMETER;
1138 }
1139 }
1140 } else if ( ShellCommandLineGetFlag(Package, L"-r")
1141 // || ShellCommandLineGetFlag(Package, L"-v")
1142 || ConstMode
1143 || NormlMode
1144 || ShellCommandLineGetFlag(Package, L"-u")
1145 || ShellCommandLineGetFlag(Package, L"-t")
1146 ){
1147 ProbeForMediaChange ();
1148 if ( ShellCommandLineGetFlag(Package, L"-r")) {
1149 //
1150 // Do the reset
1151 //
1152 Status = ShellCommandCreateInitialMappingsAndPaths();
1153 if (EFI_ERROR(Status)) {
1154 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
1155 ShellStatus = SHELL_UNSUPPORTED;
1156 }
1157 }
1158 if ( ShellStatus == SHELL_SUCCESS && ShellCommandLineGetFlag(Package, L"-u")) {
1159 //
1160 // Do the Update
1161 //
1162 Status = ShellCommandUpdateMapping ();
1163 if (EFI_ERROR(Status)) {
1164 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
1165 ShellStatus = SHELL_UNSUPPORTED;
1166 }
1167 }
1168 if (ShellStatus == SHELL_SUCCESS) {
1169 Param1 = ShellCommandLineGetRawValue(Package, 1);
1170 TypeString = ShellCommandLineGetValue(Package, L"-t");
1171 if (!ConstMode
1172 &&!NormlMode
1173 &&TypeString == NULL
1174 ) {
1175 //
1176 // now do the display...
1177 //
1178 ShellStatus = PerformMappingDisplay(
1179 ShellCommandLineGetFlag(Package, L"-v"),
1180 TRUE,
1181 TRUE,
1182 NULL,
1183 SfoMode,
1184 Param1,
1185 TRUE
1186 );
1187 } else {
1188 //
1189 // now do the display...
1190 //
1191 ShellStatus = PerformMappingDisplay2(
1192 ShellCommandLineGetFlag(Package, L"-v"),
1193 ConstMode,
1194 NormlMode,
1195 TypeString,
1196 SfoMode,
1197 Param1
1198 );
1199 }
1200 }
1201 } else {
1202 //
1203 // adding or displaying (there were no flags)
1204 //
1205 SName = ShellCommandLineGetRawValue(Package, 1);
1206 Mapping = ShellCommandLineGetRawValue(Package, 2);
1207 if ( SName == NULL
1208 && Mapping == NULL
1209 ){
1210 //
1211 // display only since no flags
1212 //
1213 ShellStatus = PerformMappingDisplay(
1214 ShellCommandLineGetFlag(Package, L"-v"),
1215 TRUE,
1216 TRUE,
1217 NULL,
1218 SfoMode,
1219 NULL,
1220 TRUE
1221 );
1222 } else if ( SName == NULL
1223 || Mapping == NULL
1224 ){
1225 //
1226 // Display only the one specified
1227 //
1228 ShellStatus = PerformMappingDisplay(
1229 FALSE,
1230 FALSE,
1231 FALSE,
1232 NULL,
1233 SfoMode,
1234 SName, // note the variable here...
1235 TRUE
1236 );
1237 } else {
1238 if (ShellIsHexOrDecimalNumber(Mapping, TRUE, FALSE)) {
1239 MapAsHandle = ConvertHandleIndexToHandle(ShellStrToUintn(Mapping));
1240 } else {
1241 MapAsHandle = NULL;
1242 }
1243 if (MapAsHandle == NULL && Mapping[StrLen(Mapping)-1] != L':') {
1244 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
1245 ShellStatus = SHELL_INVALID_PARAMETER;
1246 } else {
1247 TempStringLength = StrLen(SName);
1248 if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
1249 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
1250 ShellStatus = SHELL_INVALID_PARAMETER;
1251 }
1252
1253 if (ShellStatus == SHELL_SUCCESS) {
1254 if (MapAsHandle != NULL) {
1255 ShellStatus = AddMappingFromHandle(MapAsHandle, SName);
1256 } else {
1257 ShellStatus = AddMappingFromMapping(Mapping, SName);
1258 }
1259
1260 if (ShellStatus != SHELL_SUCCESS) {
1261 switch (ShellStatus) {
1262 case SHELL_ACCESS_DENIED:
1263 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
1264 break;
1265 case SHELL_INVALID_PARAMETER:
1266 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
1267 break;
1268 case SHELL_DEVICE_ERROR:
1269 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
1270 break;
1271 default:
1272 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
1273 }
1274 } else {
1275 //
1276 // now do the display...
1277 //
1278 ShellStatus = PerformMappingDisplay(
1279 FALSE,
1280 FALSE,
1281 FALSE,
1282 NULL,
1283 SfoMode,
1284 SName,
1285 TRUE
1286 );
1287 } // we were sucessful so do an output
1288 }
1289 } // got a valid map target
1290 } // got 2 variables
1291 } // we are adding a mapping
1292 } // got valid parameters
1293 }
1294
1295 //
1296 // free the command line package
1297 //
1298 ShellCommandLineFreeVarList (Package);
1299
1300 return (ShellStatus);
1301 }
1302