mirror of https://github.com/acidanthera/audk.git
Cd - add more input verification.
Cp - support "\" as root of drive indicator. Load - invert "-nc" to not connect. Ls - ignore archive file attribute. Map - add more input verification. fix add by handle. Mv - support overwrite question. support "\" as root of drive indicator. Parse - add comments. Rm - add comments. TimeDate - add more input verification. add comments. Vol - add new command. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11426 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2398d9b1d7
commit
b54fd049bd
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for attrib shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -192,14 +192,20 @@ ShellCommandRunCd (
|
|||
} else {
|
||||
Drive = StrCpy(Drive, Param1);
|
||||
Path = StrStr(Drive, L":");
|
||||
*(++Path) = CHAR_NULL;
|
||||
ASSERT(Path != NULL);
|
||||
if (*(Path+1) == CHAR_NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
} else {
|
||||
*(Path+1) = CHAR_NULL;
|
||||
if (Path == Drive + StrLen(Drive)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
} else {
|
||||
Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);
|
||||
Status = gEfiShellProtocol->SetCurDir(Drive, Path+2);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_PRINT), gShellLevel2HiiHandle, ShellGetCurrentDir(Drive));
|
||||
}
|
||||
}
|
||||
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
|
||||
Status = SHELL_NOT_FOUND;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for cp shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -14,7 +14,23 @@
|
|||
|
||||
#include "UefiShellLevel2CommandsLib.h"
|
||||
|
||||
// this is later in the file.
|
||||
/**
|
||||
Function to take a list of files to copy and a destination location and do
|
||||
the verification and copying of those files to that location. This function
|
||||
will report any errors to the user and halt.
|
||||
|
||||
@param[in] FileList A LIST_ENTRY* based list of files to move.
|
||||
@param[in] DestDir The destination location.
|
||||
@param[in] SilentMode TRUE to eliminate screen output.
|
||||
@param[in] RecursiveMode TRUE to copy directories.
|
||||
@param[in] Resp The response to the overwrite query (if always).
|
||||
|
||||
@retval SHELL_SUCCESS the files were all moved.
|
||||
@retval SHELL_INVALID_PARAMETER a parameter was invalid
|
||||
@retval SHELL_SECURITY_VIOLATION a security violation ocurred
|
||||
@retval SHELL_WRITE_PROTECTED the destination was write protected
|
||||
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
ValidateAndCopyFiles(
|
||||
|
@ -89,7 +105,7 @@ CopySingleFile(
|
|||
//
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (Response == NULL && !SilentMode) {
|
||||
Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_CP_PROMPT), gShellLevel2HiiHandle, &Response);
|
||||
Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
|
||||
}
|
||||
//
|
||||
// possibly return based on response
|
||||
|
@ -191,8 +207,11 @@ CopySingleFile(
|
|||
The key is to have this function called ONLY once. this allows for the parameter
|
||||
verification to happen correctly.
|
||||
|
||||
@param[in] FileList A LIST_ENTRY* based list of files to move
|
||||
@param[in] DestDir the destination location
|
||||
@param[in] FileList A LIST_ENTRY* based list of files to move.
|
||||
@param[in] DestDir The destination location.
|
||||
@param[in] SilentMode TRUE to eliminate screen output.
|
||||
@param[in] RecursiveMode TRUE to copy directories.
|
||||
@param[in] Resp The response to the overwrite query (if always).
|
||||
|
||||
@retval SHELL_SUCCESS the files were all moved.
|
||||
@retval SHELL_INVALID_PARAMETER a parameter was invalid
|
||||
|
@ -257,7 +276,7 @@ ValidateAndCopyFiles(
|
|||
}
|
||||
|
||||
NewSize = StrSize(DestDir);
|
||||
NewSize += StrSize(Node->FileName);
|
||||
NewSize += StrSize(Node->FullName);
|
||||
NewSize += StrSize(Cwd);
|
||||
if (NewSize > PathLen) {
|
||||
PathLen = NewSize;
|
||||
|
@ -285,7 +304,7 @@ ValidateAndCopyFiles(
|
|||
|
||||
HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_CP_OUTPUT), NULL);
|
||||
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
|
||||
DestPath = AllocatePool(PathLen);
|
||||
DestPath = AllocateZeroPool(PathLen);
|
||||
|
||||
if (DestPath == NULL || HiiOutput == NULL || HiiResultOk == NULL) {
|
||||
SHELL_FREE_NON_NULL(DestPath);
|
||||
|
@ -317,7 +336,7 @@ ValidateAndCopyFiles(
|
|||
if (FileList->Link.ForwardLink == FileList->Link.BackLink // 1 item
|
||||
&& EFI_ERROR(ShellIsDirectory(DestDir)) // not an existing directory
|
||||
) {
|
||||
ASSERT(StrStr(DestDir, L":") == NULL);
|
||||
if (StrStr(DestDir, L":") == NULL) {
|
||||
//
|
||||
// simple copy of a single file
|
||||
//
|
||||
|
@ -328,6 +347,9 @@ ValidateAndCopyFiles(
|
|||
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
|
||||
}
|
||||
StrCat(DestPath, DestDir);
|
||||
} else {
|
||||
StrCpy(DestPath, DestDir);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// we have multiple files or a directory in the DestDir
|
||||
|
@ -415,6 +437,18 @@ ValidateAndCopyFiles(
|
|||
return (ShellStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
Validate and if successful copy all the files from the list into
|
||||
destination directory.
|
||||
|
||||
@param[in] FileList The list of files to copy.
|
||||
@param[in] DestDir The directory to copy files to.
|
||||
@param[in] SilentMode TRUE to eliminate screen output.
|
||||
@param[in] RecursiveMode TRUE to copy directories.
|
||||
|
||||
@retval SHELL_INVALID_PARAMETER A parameter was invalid.
|
||||
@retval SHELL_SUCCESS The operation was successful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
ProcessValidateAndCopyFiles(
|
||||
|
@ -437,7 +471,6 @@ ProcessValidateAndCopyFiles(
|
|||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
ShellCloseFileMetaArg(&List);
|
||||
} else if (List != NULL) {
|
||||
ASSERT(List != NULL);
|
||||
ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL);
|
||||
ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL);
|
||||
FileInfo = NULL;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for attrib shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -248,9 +248,9 @@ ShellCommandRunLoad (
|
|||
// once we have an error preserve that value, but finish the loop.
|
||||
//
|
||||
if (EFI_ERROR(Status)) {
|
||||
LoadDriver(Node->FullName, ShellCommandLineGetFlag(Package, L"-nc"));
|
||||
LoadDriver(Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-nc")==FALSE));
|
||||
} else {
|
||||
Status = LoadDriver(Node->FullName, ShellCommandLineGetFlag(Package, L"-nc"));
|
||||
Status = LoadDriver(Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-nc")==FALSE));
|
||||
}
|
||||
} // for loop for multi-open
|
||||
if (EFI_ERROR(Status)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for ls shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -234,7 +234,7 @@ PrintLsOutput(
|
|||
//
|
||||
// exact match on all bits
|
||||
//
|
||||
if ( Node->Info->Attribute != Attribs) {
|
||||
if ( (Node->Info->Attribute|EFI_FILE_ARCHIVE) != (Attribs|EFI_FILE_ARCHIVE)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ PrintLsOutput(
|
|||
}
|
||||
|
||||
if (Rec){
|
||||
DirectoryName = AllocatePool(LongestPath + 2*sizeof(CHAR16));
|
||||
DirectoryName = AllocateZeroPool(LongestPath + 2*sizeof(CHAR16));
|
||||
if (DirectoryName == NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
|
@ -417,7 +417,7 @@ ShellCommandRunLs (
|
|||
UINTN Count;
|
||||
CHAR16 *FullPath;
|
||||
UINTN Size;
|
||||
EFI_TIME theTime;
|
||||
EFI_TIME TheTime;
|
||||
BOOLEAN SfoMode;
|
||||
|
||||
Size = 0;
|
||||
|
@ -532,7 +532,7 @@ ShellCommandRunLs (
|
|||
ASSERT(FullPath == NULL);
|
||||
StrnCatGrow(&FullPath, NULL, L"*", 0);
|
||||
}
|
||||
Status = gRT->GetTime(&theTime, NULL);
|
||||
Status = gRT->GetTime(&TheTime, NULL);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
|
@ -543,7 +543,7 @@ ShellCommandRunLs (
|
|||
FullPath,
|
||||
TRUE,
|
||||
Count,
|
||||
(INT16)(theTime.TimeZone==2047?0:theTime.TimeZone)
|
||||
(INT16)(TheTime.TimeZone==2047?0:TheTime.TimeZone)
|
||||
);
|
||||
if (ShellStatus == SHELL_NOT_FOUND) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_FILES), gShellLevel2HiiHandle);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for map shell level 2 command.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -19,6 +19,48 @@
|
|||
#include <Library/HandleParsingLib.h>
|
||||
#include <Library/SortLib.h>
|
||||
|
||||
/**
|
||||
Determine if a string has only numbers and letters.
|
||||
|
||||
This is useful for such things as Map names which can only be letters and numbers.
|
||||
|
||||
@param[in] String pointer to the string to analyze,
|
||||
@param[in] Len Number of characters to analyze.
|
||||
|
||||
@retval TRUE String has only numbers and letters
|
||||
@retval FALSE String has at least one other character.
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsNumberLetterOnly(
|
||||
IN CONST CHAR16 *String,
|
||||
IN CONST UINTN Len
|
||||
)
|
||||
{
|
||||
UINTN Count;
|
||||
for (Count = 0 ; Count < Len && String != NULL && *String != CHAR_NULL ; String++,Count++) {
|
||||
if (! ((*String >= L'a' && *String <= L'z') ||
|
||||
(*String >= L'A' && *String <= L'Z') ||
|
||||
(*String >= L'0' && *String <= L'9'))
|
||||
){
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
Do a search in the Target delimited list.
|
||||
|
||||
@param[in] List The list to seatch in.
|
||||
@param[in] MetaTarget The item to search for. MetaMatching supported.
|
||||
@param[out] FullName Optional pointer to an allocated buffer containing
|
||||
the match.
|
||||
@param[in] Meta TRUE to use MetaMatching.
|
||||
@param[in] SkipTrailingNumbers TRUE to allow for numbers after the MetaTarget.
|
||||
@param[in] Target The single character that delimits list
|
||||
items (";" normally).
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SearchList(
|
||||
|
@ -75,6 +117,11 @@ SearchList(
|
|||
return (FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
Add mappings for any devices without one. Do not change any existing maps.
|
||||
|
||||
@retval EFI_SUCCESS The operation was successful.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UpdateMapping (
|
||||
|
@ -109,7 +156,7 @@ UpdateMapping (
|
|||
//
|
||||
// Get all Device Paths
|
||||
//
|
||||
DevicePathList = AllocatePool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
|
||||
DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
|
||||
ASSERT(DevicePathList != NULL);
|
||||
|
||||
for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
|
||||
|
@ -172,6 +219,18 @@ UpdateMapping (
|
|||
return (Status);
|
||||
}
|
||||
|
||||
/**
|
||||
Determine what type of device is represented and return it's string. The
|
||||
string is in allocated memory and must be callee freed. The HII is is listed below.
|
||||
The actual string cannot be determined.
|
||||
|
||||
@param[in] DevicePath The device to analyze.
|
||||
|
||||
@retval STR_MAP_MEDIA_UNKNOWN The media type is unknown.
|
||||
@retval STR_MAP_MEDIA_HARDDISK The media is a hard drive.
|
||||
@retval STR_MAP_MEDIA_CDROM The media is a CD ROM.
|
||||
@retval STR_MAP_MEDIA_FLOPPY The media is a floppy drive.
|
||||
**/
|
||||
CHAR16*
|
||||
EFIAPI
|
||||
GetDeviceMediaType (
|
||||
|
@ -265,18 +324,27 @@ MappingListHasType(
|
|||
IN CONST BOOLEAN Consist
|
||||
)
|
||||
{
|
||||
CHAR16 *NewSpecific;
|
||||
//
|
||||
// specific has priority
|
||||
//
|
||||
if ( Specific != NULL
|
||||
&& SearchList(MapList, Specific, NULL, TRUE, FALSE, L";")) {
|
||||
return (TRUE);
|
||||
if (Specific != NULL) {
|
||||
NewSpecific = AllocateZeroPool(StrSize(Specific) + sizeof(CHAR16));
|
||||
StrCpy(NewSpecific, Specific);
|
||||
if (NewSpecific[StrLen(NewSpecific)-1] != L':') {
|
||||
StrCat(NewSpecific, L":");
|
||||
}
|
||||
|
||||
if (SearchList(MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
|
||||
FreePool(NewSpecific);
|
||||
return (TRUE);
|
||||
}
|
||||
FreePool(NewSpecific);
|
||||
}
|
||||
if ( Consist
|
||||
&& (SearchList(MapList, L"HD*", NULL, TRUE, TRUE, L";")
|
||||
||SearchList(MapList, L"CD*", NULL, TRUE, TRUE, L";")
|
||||
||SearchList(MapList, L"F*", NULL, TRUE, TRUE, L";")
|
||||
||SearchList(MapList, L"AnyF*", NULL, TRUE, TRUE, L";")
|
||||
||SearchList(MapList, L"FP*", NULL, TRUE, TRUE, L";"))){
|
||||
return (TRUE);
|
||||
}
|
||||
|
@ -294,7 +362,20 @@ MappingListHasType(
|
|||
}
|
||||
|
||||
|
||||
VOID
|
||||
/**
|
||||
Display a single map line for device Handle if conditions are met.
|
||||
|
||||
@param[in] Verbose TRUE to display (extra) verbose information.
|
||||
@param[in] Consist TRUE to display consistent mappings.
|
||||
@param[in] Normal TRUE to display normal (not consist) mappings.
|
||||
@param[in] TypeString pointer to string of filter types.
|
||||
@param[in] SFO TRUE to display output in Standard Output Format.
|
||||
@param[in] Specific pointer to string for specific map to display.
|
||||
@param[in] Handle The handle to display from.
|
||||
|
||||
@retval EFI_SUCCESS The mapping was displayed.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PerformSingleMappingDisplay(
|
||||
IN CONST BOOLEAN Verbose,
|
||||
|
@ -321,11 +402,11 @@ PerformSingleMappingDisplay(
|
|||
DevPathCopy = DevPath;
|
||||
MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
|
||||
if (MapList == NULL) {
|
||||
return;
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!MappingListHasType(MapList, Specific, TypeString, Normal, Consist)){
|
||||
return;
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
CurrentName = NULL;
|
||||
|
@ -384,9 +465,18 @@ PerformSingleMappingDisplay(
|
|||
}
|
||||
FreePool(DevPathString);
|
||||
FreePool(CurrentName);
|
||||
return;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Delete Specific from the list of maps for device Handle.
|
||||
|
||||
@param[in] Specific The name to delete.
|
||||
@param[in] Handle The device to look on.
|
||||
|
||||
@retval EFI_SUCCESS The delete was successful.
|
||||
@retval EFI_NOT_FOUND Name was not a map on Handle.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PerformSingleMappingDelete(
|
||||
|
@ -416,6 +506,10 @@ PerformSingleMappingDelete(
|
|||
return (gEfiShellProtocol->SetMap(NULL, CurrentName));
|
||||
}
|
||||
|
||||
CONST CHAR16 Cd[] = L"cd*";
|
||||
CONST CHAR16 Hd[] = L"hd*";
|
||||
CONST CHAR16 Fp[] = L"fp*";
|
||||
CONST CHAR16 AnyF[] = L"F*";
|
||||
/**
|
||||
Function to display mapping information to the user.
|
||||
|
||||
|
@ -433,10 +527,6 @@ PerformSingleMappingDelete(
|
|||
@retval SHELL_INVALID_PARAMETER one of Consist or Normal must be TRUE if no Specific
|
||||
|
||||
**/
|
||||
CONST CHAR16 Cd[] = L"cd*";
|
||||
CONST CHAR16 Hd[] = L"hd*";
|
||||
CONST CHAR16 Fp[] = L"fp*";
|
||||
CONST CHAR16 F[] = L"F*";
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
PerformMappingDisplay(
|
||||
|
@ -454,6 +544,7 @@ PerformMappingDisplay(
|
|||
UINTN BufferSize;
|
||||
UINTN LoopVar;
|
||||
CHAR16 *Test;
|
||||
BOOLEAN Found;
|
||||
|
||||
if (!Consist && !Normal && Specific == NULL && TypeString == NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle);
|
||||
|
@ -471,7 +562,7 @@ PerformMappingDisplay(
|
|||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
} else if (Test == NULL) {
|
||||
Test = (CHAR16*)F;
|
||||
Test = (CHAR16*)AnyF;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -497,33 +588,31 @@ PerformMappingDisplay(
|
|||
//
|
||||
Status = gBS->LocateHandle(
|
||||
ByProtocol,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&gEfiSimpleFileSystemProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
HandleBuffer);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
HandleBuffer = AllocatePool(BufferSize);
|
||||
HandleBuffer = AllocateZeroPool(BufferSize);
|
||||
if (HandleBuffer == NULL) {
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
Status = gBS->LocateHandle(
|
||||
ByProtocol,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&gEfiSimpleFileSystemProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
HandleBuffer);
|
||||
}
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
ASSERT(HandleBuffer != NULL);
|
||||
|
||||
//
|
||||
// Get the map name(s) for each one.
|
||||
//
|
||||
for ( LoopVar = 0
|
||||
for ( LoopVar = 0, Found = FALSE
|
||||
; LoopVar < (BufferSize / sizeof(EFI_HANDLE))
|
||||
; LoopVar ++
|
||||
){
|
||||
PerformSingleMappingDisplay(
|
||||
Status = PerformSingleMappingDisplay(
|
||||
Verbose,
|
||||
Consist,
|
||||
Normal,
|
||||
|
@ -531,6 +620,9 @@ PerformMappingDisplay(
|
|||
SFO,
|
||||
Specific,
|
||||
HandleBuffer[LoopVar]);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Found = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -544,7 +636,7 @@ PerformMappingDisplay(
|
|||
HandleBuffer);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
FreePool(HandleBuffer);
|
||||
HandleBuffer = AllocatePool(BufferSize);
|
||||
HandleBuffer = AllocateZeroPool(BufferSize);
|
||||
if (HandleBuffer == NULL) {
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
@ -568,14 +660,14 @@ PerformMappingDisplay(
|
|||
//
|
||||
if (gBS->OpenProtocol(
|
||||
HandleBuffer[LoopVar],
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&gEfiSimpleFileSystemProtocolGuid,
|
||||
NULL,
|
||||
gImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
PerformSingleMappingDisplay(
|
||||
Status = PerformSingleMappingDisplay(
|
||||
Verbose,
|
||||
Consist,
|
||||
Normal,
|
||||
|
@ -583,12 +675,32 @@ PerformMappingDisplay(
|
|||
SFO,
|
||||
Specific,
|
||||
HandleBuffer[LoopVar]);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Found = TRUE;
|
||||
}
|
||||
}
|
||||
FreePool(HandleBuffer);
|
||||
}
|
||||
if (!Found) {
|
||||
ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, Specific);
|
||||
}
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
Perform a mapping display and parse for multiple types in the TypeString.
|
||||
|
||||
@param[in] Verbose TRUE to use verbose output.
|
||||
@param[in] Consist TRUE to display consistent names.
|
||||
@param[in] Normal TRUE to display normal names.
|
||||
@param[in] TypeString An optional comma-delimited list of types.
|
||||
@param[in] SFO TRUE to display in SFO format. See Spec.
|
||||
@param[in] Specific An optional specific map name to display alone.
|
||||
|
||||
@retval SHELL_INVALID_PARAMETER A parameter was invalid.
|
||||
@retval SHELL_SUCCESS The display was successful.
|
||||
@sa PerformMappingDisplay
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
PerformMappingDisplay2(
|
||||
|
@ -633,6 +745,15 @@ PerformMappingDisplay2(
|
|||
return (ShellStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
Delete a specific map.
|
||||
|
||||
@param[in] Specific The pointer to the name of the map to delete.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Specific was NULL.
|
||||
@retval EFI_SUCCESS The operation was successful.
|
||||
@retval EFI_NOT_FOUND Specific could not be found.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PerformMappingDelete(
|
||||
|
@ -663,7 +784,7 @@ PerformMappingDelete(
|
|||
&BufferSize,
|
||||
HandleBuffer);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
HandleBuffer = AllocatePool(BufferSize);
|
||||
HandleBuffer = AllocateZeroPool(BufferSize);
|
||||
if (HandleBuffer == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
@ -703,7 +824,7 @@ PerformMappingDelete(
|
|||
HandleBuffer);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
FreePool(HandleBuffer);
|
||||
HandleBuffer = AllocatePool(BufferSize);
|
||||
HandleBuffer = AllocateZeroPool(BufferSize);
|
||||
if (HandleBuffer == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
@ -773,54 +894,33 @@ AddMappingFromMapping(
|
|||
{
|
||||
CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||
EFI_STATUS Status;
|
||||
CHAR16 *NewSName;
|
||||
|
||||
if (StrStr(SName, L"*") != NULL
|
||||
||StrStr(SName, L"?") != NULL
|
||||
||StrStr(SName, L"[") != NULL
|
||||
||StrStr(SName, L"]") != NULL) {
|
||||
NewSName = AllocateZeroPool(StrSize(SName) + sizeof(CHAR16));
|
||||
StrCpy(NewSName, SName);
|
||||
if (NewSName[StrLen(NewSName)-1] != L':') {
|
||||
StrCat(NewSName, L":");
|
||||
}
|
||||
|
||||
if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
|
||||
FreePool(NewSName);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
DevPath = gEfiShellProtocol->GetDevicePathFromMap(Map);
|
||||
if (DevPath == NULL) {
|
||||
FreePool(NewSName);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Status = gEfiShellProtocol->SetMap(DevPath, SName);
|
||||
Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
|
||||
FreePool(NewSName);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return (SHELL_DEVICE_ERROR);
|
||||
}
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
function to determine if a string has only numbers and letters
|
||||
|
||||
This is useful for such things as Map names which can only be letters and numbers
|
||||
|
||||
@param[in] String pointer to the string to analyze
|
||||
|
||||
@retval TRUE String has only numbers and letters
|
||||
@retval FALSE String has at least one other character.
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsNumberLetterOnly(
|
||||
IN CONST CHAR16 *String
|
||||
)
|
||||
{
|
||||
while(String != NULL && *String != CHAR_NULL) {
|
||||
if (! ((*String >= L'a' && *String <= L'z') ||
|
||||
(*String >= L'A' && *String <= L'Z') ||
|
||||
(*String >= L'0' && *String <= L'9'))
|
||||
){
|
||||
return (FALSE);
|
||||
}
|
||||
String++;
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
function to add a mapping from an EFI_HANDLE.
|
||||
|
||||
|
@ -844,8 +944,16 @@ AddMappingFromHandle(
|
|||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||
EFI_STATUS Status;
|
||||
CHAR16 *NewSName;
|
||||
|
||||
if (!IsNumberLetterOnly(SName)) {
|
||||
NewSName = AllocateZeroPool(StrSize(SName) + sizeof(CHAR16));
|
||||
StrCpy(NewSName, SName);
|
||||
if (NewSName[StrLen(NewSName)-1] != L':') {
|
||||
StrCat(NewSName, L":");
|
||||
}
|
||||
|
||||
if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
|
||||
FreePool(NewSName);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
|
@ -858,9 +966,11 @@ AddMappingFromHandle(
|
|||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
FreePool(NewSName);
|
||||
return (SHELL_DEVICE_ERROR);
|
||||
}
|
||||
Status = gEfiShellProtocol->SetMap(DevPath, SName);
|
||||
Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
|
||||
FreePool(NewSName);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return (SHELL_DEVICE_ERROR);
|
||||
}
|
||||
|
@ -897,7 +1007,7 @@ ShellCommandRunMap (
|
|||
CHAR16 *ProblemParam;
|
||||
CONST CHAR16 *SName;
|
||||
CONST CHAR16 *Mapping;
|
||||
EFI_HANDLE MappingAsHandle;
|
||||
EFI_HANDLE MapAsHandle;
|
||||
CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||
SHELL_STATUS ShellStatus;
|
||||
BOOLEAN SfoMode;
|
||||
|
@ -905,13 +1015,14 @@ ShellCommandRunMap (
|
|||
BOOLEAN NormlMode;
|
||||
CONST CHAR16 *Param1;
|
||||
CONST CHAR16 *TypeString;
|
||||
UINTN TempStringLength;
|
||||
|
||||
ProblemParam = NULL;
|
||||
Mapping = NULL;
|
||||
SName = NULL;
|
||||
DevPath = NULL;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
MappingAsHandle = NULL;
|
||||
MapAsHandle = NULL;
|
||||
|
||||
//
|
||||
// initialize the shell lib (we must be in non-auto-init...)
|
||||
|
@ -1082,19 +1193,31 @@ ShellCommandRunMap (
|
|||
);
|
||||
} else {
|
||||
if (ShellIsHexOrDecimalNumber(Mapping, TRUE, FALSE)) {
|
||||
MappingAsHandle = ConvertHandleIndexToHandle(StrHexToUintn(Mapping));
|
||||
MapAsHandle = ConvertHandleIndexToHandle(ShellStrToUintn(Mapping));
|
||||
} else {
|
||||
MappingAsHandle = NULL;
|
||||
MapAsHandle = NULL;
|
||||
}
|
||||
if (MappingAsHandle == NULL && Mapping[StrLen(Mapping)-1] != L':') {
|
||||
if (MapAsHandle == NULL && Mapping[StrLen(Mapping)-1] != L':') {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Mapping);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
if (MappingAsHandle != NULL) {
|
||||
ShellStatus = AddMappingFromHandle(MappingAsHandle, SName);
|
||||
if (MapAsHandle != NULL) {
|
||||
TempStringLength = StrLen(SName);
|
||||
if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, SName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ShellStatus = AddMappingFromHandle(MapAsHandle, SName);
|
||||
}
|
||||
} else {
|
||||
TempStringLength = StrLen(SName);
|
||||
if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, SName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ShellStatus = AddMappingFromMapping(Mapping, SName);
|
||||
}
|
||||
}
|
||||
if (ShellStatus != SHELL_SUCCESS) {
|
||||
switch (ShellStatus) {
|
||||
case SHELL_ACCESS_DENIED:
|
||||
|
@ -1103,6 +1226,9 @@ ShellCommandRunMap (
|
|||
case SHELL_INVALID_PARAMETER:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle);
|
||||
break;
|
||||
case SHELL_DEVICE_ERROR:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, Mapping);
|
||||
break;
|
||||
default:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, ShellStatus|MAX_BIT);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for mv shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -116,12 +116,13 @@ IsValidMove(
|
|||
|
||||
if the result is sucessful the caller must free *DestPathPointer.
|
||||
|
||||
@param[in] DestDir The original path to the destination
|
||||
@param[in,out] DestPathPointer a pointer to the callee allocated final path.
|
||||
@param[in] DestDir The original path to the destination.
|
||||
@param[in,out] DestPathPointer A pointer to the callee allocated final path.
|
||||
@param[in] Cwd A pointer to the current working directory.
|
||||
|
||||
@retval EFI_INVALID_PARAMETR the DestDir could not be resolved to a location
|
||||
@retval EFI_INVALID_PARAMETR the DestDir could be resolved to more than 1 location
|
||||
@retval EFI_SUCCESS the operation was sucessful
|
||||
@retval EFI_INVALID_PARAMETR The DestDir could not be resolved to a location.
|
||||
@retval EFI_INVALID_PARAMETR The DestDir could be resolved to more than 1 location.
|
||||
@retval EFI_SUCCESS The operation was sucessful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
|
@ -140,6 +141,17 @@ GetDestinationLocation(
|
|||
|
||||
DestList = NULL;
|
||||
DestPath = NULL;
|
||||
|
||||
if (StrStr(DestDir, L"\\") == DestDir) {
|
||||
DestPath = AllocateZeroPool(StrSize(Cwd));
|
||||
if (DestPath == NULL) {
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
StrCpy(DestPath, Cwd);
|
||||
while (ChopLastSlash(DestPath)) ;
|
||||
*DestPathPointer = DestPath;
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
//
|
||||
// get the destination path
|
||||
//
|
||||
|
@ -211,6 +223,7 @@ GetDestinationLocation(
|
|||
will report any errors to the user and continue to move the rest of the files.
|
||||
|
||||
@param[in] FileList A LIST_ENTRY* based list of files to move
|
||||
@param[out] Resp pointer to response from question. Pass back on looped calling
|
||||
@param[in] DestDir the destination location
|
||||
|
||||
@retval SHELL_SUCCESS the files were all moved.
|
||||
|
@ -223,6 +236,7 @@ SHELL_STATUS
|
|||
EFIAPI
|
||||
ValidateAndMoveFiles(
|
||||
IN CONST EFI_SHELL_FILE_INFO *FileList,
|
||||
OUT VOID **Resp,
|
||||
IN CONST CHAR16 *DestDir
|
||||
)
|
||||
{
|
||||
|
@ -237,12 +251,15 @@ ValidateAndMoveFiles(
|
|||
CHAR16 *TempLocation;
|
||||
UINTN NewSize;
|
||||
UINTN Length;
|
||||
VOID *Response;
|
||||
SHELL_FILE_HANDLE DestHandle;
|
||||
|
||||
ASSERT(FileList != NULL);
|
||||
ASSERT(DestDir != NULL);
|
||||
|
||||
DestPath = NULL;
|
||||
Cwd = ShellGetCurrentDir(NULL);
|
||||
Response = *Resp;
|
||||
|
||||
//
|
||||
// Get and validate the destination location
|
||||
|
@ -251,6 +268,7 @@ ValidateAndMoveFiles(
|
|||
if (ShellStatus != SHELL_SUCCESS) {
|
||||
return (ShellStatus);
|
||||
}
|
||||
DestPath = CleanPath(DestPath);
|
||||
|
||||
HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);
|
||||
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
|
||||
|
@ -325,9 +343,45 @@ ValidateAndMoveFiles(
|
|||
StrCat(NewFileInfo->FileName, Node->FileName);
|
||||
}
|
||||
NewFileInfo->Size = sizeof(EFI_FILE_INFO) + StrSize(NewFileInfo->FileName);
|
||||
|
||||
ShellPrintEx(-1, -1, HiiOutput, Node->FullName, NewFileInfo->FileName);
|
||||
|
||||
if (!EFI_ERROR(ShellFileExists(NewFileInfo->FileName))) {
|
||||
if (Response == NULL) {
|
||||
ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
|
||||
}
|
||||
switch (*(SHELL_PROMPT_RESPONSE*)Response) {
|
||||
case ShellPromptResponseNo:
|
||||
FreePool(NewFileInfo);
|
||||
continue;
|
||||
case ShellPromptResponseCancel:
|
||||
*Resp = Response;
|
||||
//
|
||||
// indicate to stop everything
|
||||
//
|
||||
FreePool(NewFileInfo);
|
||||
FreePool(DestPath);
|
||||
FreePool(HiiOutput);
|
||||
FreePool(HiiResultOk);
|
||||
return (SHELL_ABORTED);
|
||||
case ShellPromptResponseAll:
|
||||
*Resp = Response;
|
||||
break;
|
||||
case ShellPromptResponseYes:
|
||||
FreePool(Response);
|
||||
break;
|
||||
default:
|
||||
FreePool(Response);
|
||||
FreePool(NewFileInfo);
|
||||
FreePool(DestPath);
|
||||
FreePool(HiiOutput);
|
||||
FreePool(HiiResultOk);
|
||||
return SHELL_ABORTED;
|
||||
}
|
||||
Status = ShellOpenFileByName(NewFileInfo->FileName, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
|
||||
ShellDeleteFile(&DestHandle);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Perform the move operation
|
||||
//
|
||||
|
@ -336,7 +390,6 @@ ValidateAndMoveFiles(
|
|||
//
|
||||
// Free the info object we used...
|
||||
//
|
||||
ASSERT (NewFileInfo != NULL);
|
||||
FreePool(NewFileInfo);
|
||||
|
||||
//
|
||||
|
@ -373,6 +426,12 @@ ValidateAndMoveFiles(
|
|||
return (ShellStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
Function for 'mv' command.
|
||||
|
||||
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
||||
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
ShellCommandRunMv (
|
||||
|
@ -387,11 +446,13 @@ ShellCommandRunMv (
|
|||
UINTN ParamCount;
|
||||
UINTN LoopCounter;
|
||||
EFI_SHELL_FILE_INFO *FileList;
|
||||
VOID *Response;
|
||||
|
||||
ProblemParam = NULL;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
ParamCount = 0;
|
||||
FileList = NULL;
|
||||
Response = NULL;
|
||||
|
||||
//
|
||||
// initialize the shell lib (we must be in non-auto-init...)
|
||||
|
@ -444,20 +505,20 @@ ShellCommandRunMv (
|
|||
//
|
||||
// ValidateAndMoveFiles will report errors to the screen itself
|
||||
//
|
||||
ShellStatus = ValidateAndMoveFiles(FileList, ShellGetCurrentDir(NULL));
|
||||
ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
///@todo make sure this works with error half way through and continues...
|
||||
for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount && ShellStatus == SHELL_SUCCESS ; LoopCounter++) {
|
||||
for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount ; LoopCounter++) {
|
||||
if (ShellGetExecutionBreakFlag()) {
|
||||
break;
|
||||
}
|
||||
Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
||||
if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, 1));
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, LoopCounter));
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
} else {
|
||||
//
|
||||
|
@ -465,9 +526,9 @@ ShellCommandRunMv (
|
|||
// Only change ShellStatus if it's sucessful
|
||||
//
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
ShellStatus = ValidateAndMoveFiles(FileList, ShellCommandLineGetRawValue(Package, ParamCount));
|
||||
ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
|
||||
} else {
|
||||
ValidateAndMoveFiles(FileList, ShellCommandLineGetRawValue(Package, ParamCount));
|
||||
ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
|
||||
}
|
||||
}
|
||||
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
|
||||
|
@ -491,6 +552,8 @@ ShellCommandRunMv (
|
|||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL(Response);
|
||||
|
||||
if (ShellGetExecutionBreakFlag()) {
|
||||
return (SHELL_ABORTED);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for Parse shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -14,6 +14,19 @@
|
|||
|
||||
#include "UefiShellLevel2CommandsLib.h"
|
||||
|
||||
/**
|
||||
Do the actual parsing of the file. the file should be SFO output from a
|
||||
shell command or a similar format.
|
||||
|
||||
@param[in] FileName The filename to open.
|
||||
@param[in] TableName The name of the table to find.
|
||||
@param[in] ColumnIndex The column number to get.
|
||||
@param[in] TableNameInstance Which instance of the table to get (row).
|
||||
@param[in] ShellCommandInstance Which instance of the command to get.
|
||||
|
||||
@retval SHELL_NOT_FOUND The requested instance was not found.
|
||||
@retval SHELL_SUCCESS The operation was successful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
PerformParsing(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for attrib shell level 2 function.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -19,6 +19,14 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
|||
{NULL, TypeMax}
|
||||
};
|
||||
|
||||
/**
|
||||
Determine if a directory has no files in it.
|
||||
|
||||
@param[in] FileHandle The EFI_HANDLE to the directory.
|
||||
|
||||
@retval TRUE The directory has no files (or directories).
|
||||
@retval FALSE The directory has at least 1 file or directory in it.
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsDirectoryEmpty (
|
||||
|
@ -45,6 +53,17 @@ IsDirectoryEmpty (
|
|||
return (RetVal);
|
||||
}
|
||||
|
||||
/**
|
||||
Delete a node and all nodes under it (including sub directories).
|
||||
|
||||
@param[in] Node The node to start deleting with.
|
||||
@param[in] Quiet TRUE to print no messages.
|
||||
|
||||
@retval SHELL_SUCCESS The operation was successful.
|
||||
@retval SHELL_ACCESS_DENIED A file was read only.
|
||||
@retval SHELL_ABORTED The abort message was received.
|
||||
@retval SHELL_DEVICE_ERROR A device error occured reading this Node.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
CascadeDelete(
|
||||
|
@ -126,7 +145,7 @@ CascadeDelete(
|
|||
}
|
||||
|
||||
//
|
||||
// We cant allow for the warning here!
|
||||
// We cant allow for the warning here! (Dont use EFI_ERROR Macro).
|
||||
//
|
||||
if (Status != EFI_SUCCESS){
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR), gShellLevel2HiiHandle, Status);
|
||||
|
@ -137,6 +156,13 @@ CascadeDelete(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Determins if a Node is a valid delete target. Will prevent deleting the root directory.
|
||||
|
||||
@param[in] List RESERVED. Not used.
|
||||
@param[in] Node The node to analyze.
|
||||
@param[in] Package RESERVED. Not used.
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsValidDeleteTarget(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Main file for time, timezone, and date shell level 2 and shell level 3 functions.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -14,18 +14,18 @@
|
|||
|
||||
#include "UefiShellLevel2CommandsLib.h"
|
||||
|
||||
INT16
|
||||
EFIAPI
|
||||
AbsVal(
|
||||
INT16 v
|
||||
)
|
||||
{
|
||||
if (v>0) {
|
||||
return (v);
|
||||
}
|
||||
return ((INT16)(-v));
|
||||
}
|
||||
/**
|
||||
Determine if String is a valid representation for a time or date.
|
||||
|
||||
@param[in] String The pointer to the string to test.
|
||||
@param[in] Char The delimeter character.
|
||||
@param[in] Min The minimum value allowed.
|
||||
@param[in] Max The maximum value allowed.
|
||||
@param[in] MinusOk Whether negative numbers are permitted.
|
||||
|
||||
@retval TRUE String is a valid representation.
|
||||
@retval FALSE String is invalid.
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
InternalIsTimeLikeString (
|
||||
|
@ -75,6 +75,16 @@ InternalIsTimeLikeString (
|
|||
return (TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
Verify that the DateString is valid and if so set that as the current
|
||||
date.
|
||||
|
||||
@param[in] DateString The pointer to a string representation of the date.
|
||||
|
||||
@retval SHELL_INVALID_PARAMETER DateString was NULL.
|
||||
@retval SHELL_INVALID_PARAMETER DateString was mis-formatted.
|
||||
@retval SHELL_SUCCESS The operation was successful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
CheckAndSetDate (
|
||||
|
@ -83,7 +93,9 @@ CheckAndSetDate (
|
|||
{
|
||||
EFI_TIME TheTime;
|
||||
EFI_STATUS Status;
|
||||
CONST CHAR16 *Walker;
|
||||
CHAR16 *DateStringCopy;
|
||||
CHAR16 *Walker;
|
||||
CHAR16 *Walker1;
|
||||
|
||||
if (!InternalIsTimeLikeString(DateString, L'/', 2, 2, FALSE)) {
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
|
@ -92,25 +104,41 @@ CheckAndSetDate (
|
|||
Status = gRT->GetTime(&TheTime, NULL);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
|
||||
Walker = DateString;
|
||||
DateStringCopy = NULL;
|
||||
DateStringCopy = StrnCatGrow(&DateStringCopy, NULL, DateString, 0);
|
||||
if (DateStringCopy == NULL) {
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
Walker = DateStringCopy;
|
||||
|
||||
TheTime.Month = 0xFF;
|
||||
TheTime.Day = 0xFF;
|
||||
TheTime.Year = 0xFFFF;
|
||||
|
||||
TheTime.Month = (UINT8)StrDecimalToUintn (Walker);
|
||||
Walker = StrStr(Walker, L"/");
|
||||
if (Walker != NULL && *Walker == L'/') {
|
||||
Walker = Walker + 1;
|
||||
Walker1 = StrStr(Walker, L"/");
|
||||
if (Walker1 != NULL && *Walker1 == L'/') {
|
||||
*Walker1 = CHAR_NULL;
|
||||
}
|
||||
|
||||
TheTime.Month = (UINT8)ShellStrToUintn (Walker);
|
||||
if (Walker1 != NULL) {
|
||||
Walker = Walker1 + 1;
|
||||
}
|
||||
Walker1 = StrStr(Walker, L"/");
|
||||
if (Walker1 != NULL && *Walker1 == L'/') {
|
||||
*Walker1 = CHAR_NULL;
|
||||
}
|
||||
if (Walker != NULL && Walker[0] != CHAR_NULL) {
|
||||
TheTime.Day = (UINT8)StrDecimalToUintn (Walker);
|
||||
Walker = StrStr(Walker, L"/");
|
||||
if (Walker != NULL && *Walker == L'/') {
|
||||
Walker = Walker + 1;
|
||||
TheTime.Day = (UINT8)ShellStrToUintn (Walker);
|
||||
if (Walker1 != NULL) {
|
||||
Walker = Walker1 + 1;
|
||||
}
|
||||
Walker1 = StrStr(Walker, L"/");
|
||||
if (Walker1 != NULL && *Walker1 == L'/') {
|
||||
*Walker1 = CHAR_NULL;
|
||||
}
|
||||
if (Walker != NULL && Walker[0] != CHAR_NULL) {
|
||||
TheTime.Year = (UINT16)StrDecimalToUintn (Walker);
|
||||
TheTime.Year = (UINT16)ShellStrToUintn (Walker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,6 +269,18 @@ STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
|
|||
{NULL, TypeMax}
|
||||
};
|
||||
|
||||
/**
|
||||
Verify that the TimeString is valid and if so set that as the current
|
||||
time.
|
||||
|
||||
@param[in] TimeString The pointer to a string representation of the time.
|
||||
@param[in] Tz The value to set for TimeZone.
|
||||
@param[in] Daylight The value to set for Daylight.
|
||||
|
||||
@retval SHELL_INVALID_PARAMETER TimeString was NULL.
|
||||
@retval SHELL_INVALID_PARAMETER TimeString was mis-formatted.
|
||||
@retval SHELL_SUCCESS The operation was successful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
CheckAndSetTime (
|
||||
|
@ -251,7 +291,9 @@ CheckAndSetTime (
|
|||
{
|
||||
EFI_TIME TheTime;
|
||||
EFI_STATUS Status;
|
||||
CONST CHAR16 *Walker;
|
||||
CHAR16 *TimeStringCopy;
|
||||
CHAR16 *Walker1;
|
||||
CHAR16 *Walker2;
|
||||
|
||||
if (TimeString != NULL && !InternalIsTimeLikeString(TimeString, L':', 1, 2, FALSE)) {
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
|
@ -259,30 +301,40 @@ CheckAndSetTime (
|
|||
|
||||
Status = gRT->GetTime(&TheTime, NULL);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
TimeStringCopy = NULL;
|
||||
TimeStringCopy = StrnCatGrow(&TimeStringCopy, NULL, TimeString, 0);
|
||||
|
||||
if (TimeString != NULL) {
|
||||
Walker = TimeString;
|
||||
Walker1 = TimeStringCopy;
|
||||
TheTime.Hour = 0xFF;
|
||||
TheTime.Minute = 0xFF;
|
||||
|
||||
TheTime.Hour = (UINT8)StrDecimalToUintn (Walker);
|
||||
Walker = StrStr(Walker, L":");
|
||||
if (Walker != NULL && *Walker == L':') {
|
||||
Walker = Walker + 1;
|
||||
Walker2 = StrStr(Walker1, L":");
|
||||
if (Walker2 != NULL && *Walker2 == L':') {
|
||||
*Walker2 = CHAR_NULL;
|
||||
}
|
||||
if (Walker != NULL && Walker[0] != CHAR_NULL) {
|
||||
TheTime.Minute = (UINT8)StrDecimalToUintn (Walker);
|
||||
Walker = StrStr(Walker, L":");
|
||||
if (Walker != NULL && *Walker == L':') {
|
||||
Walker = Walker + 1;
|
||||
TheTime.Hour = (UINT8)ShellStrToUintn (Walker1);
|
||||
if (Walker2 != NULL) {
|
||||
Walker1 = Walker2 + 1;
|
||||
}
|
||||
if (Walker != NULL && Walker[0] != CHAR_NULL) {
|
||||
TheTime.Second = (UINT8)StrDecimalToUintn (Walker);
|
||||
Walker2 = StrStr(Walker1, L":");
|
||||
if (Walker2 != NULL && *Walker2 == L':') {
|
||||
*Walker2 = CHAR_NULL;
|
||||
}
|
||||
if (Walker1 != NULL && Walker1[0] != CHAR_NULL) {
|
||||
TheTime.Minute = (UINT8)ShellStrToUintn (Walker1);
|
||||
if (Walker2 != NULL) {
|
||||
Walker1 = Walker2 + 1;
|
||||
}
|
||||
if (Walker1 != NULL && Walker1[0] != CHAR_NULL) {
|
||||
TheTime.Second = (UINT8)ShellStrToUintn (Walker1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Tz >= -1440 && Tz <= 1440)||(Tz == 2047)) {
|
||||
FreePool(TimeStringCopy);
|
||||
|
||||
if ((Tz >= -1440 && Tz <= 1440)||(Tz == 0x7FF)) {
|
||||
TheTime.TimeZone = Tz;
|
||||
}
|
||||
if (Daylight <= 3 && Daylight != 2) {
|
||||
|
@ -376,7 +428,7 @@ ShellCommandRunTime (
|
|||
if (TheTime.TimeZone == 2047) {
|
||||
TzMinutes = 0;
|
||||
} else {
|
||||
TzMinutes = AbsVal(TheTime.TimeZone) % 60;
|
||||
TzMinutes = (ABS(TheTime.TimeZone)) % 60;
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (
|
||||
|
@ -389,7 +441,7 @@ ShellCommandRunTime (
|
|||
TheTime.Minute,
|
||||
TheTime.Second,
|
||||
TheTime.TimeZone==2047?L" ":(TheTime.TimeZone > 0?L"-":L"+"),
|
||||
TheTime.TimeZone==2047?0:AbsVal(TheTime.TimeZone) / 60,
|
||||
TheTime.TimeZone==2047?0:(ABS(TheTime.TimeZone)) / 60,
|
||||
TzMinutes
|
||||
);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel2HiiHandle);
|
||||
|
@ -397,7 +449,7 @@ ShellCommandRunTime (
|
|||
if (TheTime.TimeZone == 2047) {
|
||||
TzMinutes = 0;
|
||||
} else {
|
||||
TzMinutes = AbsVal(TheTime.TimeZone) % 60;
|
||||
TzMinutes = (ABS(TheTime.TimeZone)) % 60;
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (
|
||||
|
@ -410,18 +462,18 @@ ShellCommandRunTime (
|
|||
TheTime.Minute,
|
||||
TheTime.Second,
|
||||
TheTime.TimeZone==2047?L" ":(TheTime.TimeZone > 0?L"-":L"+"),
|
||||
TheTime.TimeZone==2047?0:AbsVal(TheTime.TimeZone) / 60,
|
||||
TheTime.TimeZone==2047?0:(ABS(TheTime.TimeZone)) / 60,
|
||||
TzMinutes
|
||||
);
|
||||
switch (TheTime.Daylight) {
|
||||
case 0:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DSTNA), gShellLevel2HiiHandle);
|
||||
break;
|
||||
case EFI_TIME_ADJUST_DAYLIGHT:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DSTST), gShellLevel2HiiHandle);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST1), gShellLevel2HiiHandle);
|
||||
break;
|
||||
case EFI_TIME_IN_DAYLIGHT:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DSTDT), gShellLevel2HiiHandle);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST2), gShellLevel2HiiHandle);
|
||||
break;
|
||||
case EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST3), gShellLevel2HiiHandle);
|
||||
break;
|
||||
default:
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);
|
||||
|
@ -436,9 +488,9 @@ ShellCommandRunTime (
|
|||
//
|
||||
if ((TempLocation = ShellCommandLineGetValue(Package, L"-tz")) != NULL) {
|
||||
if (TempLocation[0] == L'-') {
|
||||
Tz = (INT16)(0 - StrDecimalToUintn(++TempLocation));
|
||||
Tz = (INT16)(0 - ShellStrToUintn(++TempLocation));
|
||||
} else {
|
||||
Tz = (INT16)StrDecimalToUintn(TempLocation);
|
||||
Tz = (INT16)ShellStrToUintn(TempLocation);
|
||||
}
|
||||
if (!(Tz >= -1440 && Tz <= 1440) && Tz != 2047) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"-d");
|
||||
|
@ -452,7 +504,7 @@ ShellCommandRunTime (
|
|||
}
|
||||
TempLocation = ShellCommandLineGetValue(Package, L"-d");
|
||||
if (TempLocation != NULL) {
|
||||
Daylight = (UINT8)StrDecimalToUintn(TempLocation);
|
||||
Daylight = (UINT8)ShellStrToUintn(TempLocation);
|
||||
if (Daylight != 0 && Daylight != 1 && Daylight != 3) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"-d");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
|
@ -539,8 +591,18 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
|
|||
{-720 , STRING_TOKEN (STR_TIMEZONE_P12)},
|
||||
{-780 , STRING_TOKEN (STR_TIMEZONE_P13)},
|
||||
{-840 , STRING_TOKEN (STR_TIMEZONE_P14)}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
Verify that the TimeZoneString is valid and if so set that as the current
|
||||
timezone.
|
||||
|
||||
@param[in] TimeZoneString The pointer to a string representation of the timezone.
|
||||
|
||||
@retval SHELL_INVALID_PARAMETER TimeZoneString was NULL.
|
||||
@retval SHELL_INVALID_PARAMETER TimeZoneString was mis-formatted.
|
||||
@retval SHELL_SUCCESS The operation was successful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
CheckAndSetTimeZone (
|
||||
|
@ -549,7 +611,9 @@ CheckAndSetTimeZone (
|
|||
{
|
||||
EFI_TIME TheTime;
|
||||
EFI_STATUS Status;
|
||||
CONST CHAR16 *Walker;
|
||||
CHAR16 *TimeZoneCopy;
|
||||
CHAR16 *Walker;
|
||||
CHAR16 *Walker2;
|
||||
UINTN LoopVar;
|
||||
|
||||
if (TimeZoneString == NULL) {
|
||||
|
@ -563,21 +627,26 @@ CheckAndSetTimeZone (
|
|||
Status = gRT->GetTime(&TheTime, NULL);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
|
||||
Walker = TimeZoneString;
|
||||
if (*Walker == L'-') {
|
||||
TheTime.TimeZone = (INT16)((StrDecimalToUintn (++Walker)) * 60);
|
||||
} else {
|
||||
TheTime.TimeZone = (INT16)((StrDecimalToUintn (Walker)) * -60);
|
||||
TimeZoneCopy = NULL;
|
||||
TimeZoneCopy = StrnCatGrow(&TimeZoneCopy, NULL, TimeZoneString, 0);
|
||||
Walker = TimeZoneCopy;
|
||||
Walker2 = StrStr(Walker, L":");
|
||||
if (Walker2 != NULL && *Walker2 == L':') {
|
||||
*Walker2 = CHAR_NULL;
|
||||
}
|
||||
Walker = StrStr(Walker, L":");
|
||||
if (Walker != NULL && *Walker == L':') {
|
||||
Walker = Walker + 1;
|
||||
if (*Walker == L'-') {
|
||||
TheTime.TimeZone = (INT16)((ShellStrToUintn (++Walker)) * 60);
|
||||
} else {
|
||||
TheTime.TimeZone = (INT16)((ShellStrToUintn (Walker)) * -60);
|
||||
}
|
||||
if (Walker2 != NULL) {
|
||||
Walker = Walker2 + 1;
|
||||
}
|
||||
if (Walker != NULL && Walker[0] != CHAR_NULL) {
|
||||
if (TheTime.TimeZone < 0) {
|
||||
TheTime.TimeZone = (INT16)(TheTime.TimeZone - (UINT8)StrDecimalToUintn (Walker));
|
||||
TheTime.TimeZone = (INT16)(TheTime.TimeZone - (UINT8)ShellStrToUintn (Walker));
|
||||
} else {
|
||||
TheTime.TimeZone = (INT16)(TheTime.TimeZone + (UINT8)StrDecimalToUintn (Walker));
|
||||
TheTime.TimeZone = (INT16)(TheTime.TimeZone + (UINT8)ShellStrToUintn (Walker));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,6 +662,8 @@ CheckAndSetTimeZone (
|
|||
}
|
||||
}
|
||||
|
||||
FreePool(TimeZoneCopy);
|
||||
|
||||
if (!EFI_ERROR(Status)){
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
@ -716,7 +787,7 @@ ShellCommandRunTimeZone (
|
|||
if (TheTime.TimeZone == 2047) {
|
||||
TzMinutes = 0;
|
||||
} else {
|
||||
TzMinutes = AbsVal(TheTime.TimeZone) % 60;
|
||||
TzMinutes = (ABS(TheTime.TimeZone)) % 60;
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (
|
||||
|
@ -726,7 +797,7 @@ ShellCommandRunTimeZone (
|
|||
STRING_TOKEN(STR_TIMEZONE_SIMPLE),
|
||||
gShellLevel2HiiHandle,
|
||||
TheTime.TimeZone==2047?0:(TheTime.TimeZone > 0?L"-":L"+"),
|
||||
TheTime.TimeZone==2047?0:AbsVal(TheTime.TimeZone) / 60,
|
||||
TheTime.TimeZone==2047?0:(ABS(TheTime.TimeZone)) / 60,
|
||||
TzMinutes);
|
||||
}
|
||||
Found = TRUE;
|
||||
|
@ -740,7 +811,7 @@ ShellCommandRunTimeZone (
|
|||
if (TheTime.TimeZone == 2047) {
|
||||
TzMinutes = 0;
|
||||
} else {
|
||||
TzMinutes = AbsVal(TheTime.TimeZone) % 60;
|
||||
TzMinutes = (ABS(TheTime.TimeZone)) % 60;
|
||||
}
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
|
@ -749,7 +820,7 @@ ShellCommandRunTimeZone (
|
|||
STRING_TOKEN(STR_TIMEZONE_SIMPLE),
|
||||
gShellLevel2HiiHandle,
|
||||
TheTime.TimeZone==2047?0:(TheTime.TimeZone > 0?L"-":L"+"),
|
||||
TheTime.TimeZone==2047?0:AbsVal(TheTime.TimeZone) / 60,
|
||||
TheTime.TimeZone==2047?0:(ABS(TheTime.TimeZone)) / 60,
|
||||
TzMinutes);
|
||||
if (ShellCommandLineGetFlag(Package, L"-f")) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_TIMEZONE_NI), gShellLevel2HiiHandle);
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
rm,
|
||||
reset,
|
||||
set,
|
||||
timezone*
|
||||
timezone*,
|
||||
vol
|
||||
|
||||
* functions are non-interactive only
|
||||
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -40,6 +41,11 @@ CONST EFI_GUID gShellLevel2HiiGuid = \
|
|||
0xf95a7ccc, 0x4c55, 0x4426, { 0xa7, 0xb4, 0xdc, 0x89, 0x61, 0x95, 0xb, 0xae } \
|
||||
};
|
||||
|
||||
/**
|
||||
Get the filename to get help text from if not using HII.
|
||||
|
||||
@retval The filename.
|
||||
**/
|
||||
CONST CHAR16*
|
||||
EFIAPI
|
||||
ShellCommandGetManFileNameLevel2 (
|
||||
|
@ -94,6 +100,7 @@ ShellLevel2CommandsLibConstructor (
|
|||
ShellCommandRegisterCommandName(L"set", ShellCommandRunSet , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_SET) );
|
||||
ShellCommandRegisterCommandName(L"ls", ShellCommandRunLs , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LS) );
|
||||
ShellCommandRegisterCommandName(L"rm", ShellCommandRunRm , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RM) );
|
||||
ShellCommandRegisterCommandName(L"vol", ShellCommandRunVol , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_VOL) );
|
||||
|
||||
//
|
||||
// support for permenant (built in) aliases
|
||||
|
@ -295,13 +302,29 @@ VerifyIntermediateDirectories (
|
|||
return (Status);
|
||||
}
|
||||
|
||||
// be lazy and borrow from baselib.
|
||||
/**
|
||||
Be lazy and borrow from baselib.
|
||||
|
||||
@param[in] Char The character to convert to upper case.
|
||||
|
||||
@return Char as an upper case character.
|
||||
**/
|
||||
CHAR16
|
||||
EFIAPI
|
||||
InternalCharToUpper (
|
||||
IN CONST CHAR16 Char
|
||||
);
|
||||
|
||||
/**
|
||||
String comparison without regard to case for a limited number of characters.
|
||||
|
||||
@param[in] Source The first item to compare.
|
||||
@param[in] Target The second item to compare.
|
||||
@param[in] Count How many characters to compare.
|
||||
|
||||
@retval NULL Source and Target are identical strings without regard to case.
|
||||
@return The location in Source where there is a difference.
|
||||
**/
|
||||
CONST CHAR16*
|
||||
EFIAPI
|
||||
StrniCmp(
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* functions are non-interactive only
|
||||
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -20,6 +20,9 @@
|
|||
|
||||
**/
|
||||
|
||||
#if !defined (_UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_)
|
||||
#define _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <ShellBase.h>
|
||||
|
||||
|
@ -295,3 +298,19 @@ StrniCmp(
|
|||
IN CONST CHAR16 *Target,
|
||||
IN CONST UINTN Count
|
||||
);
|
||||
|
||||
/**
|
||||
Function for 'Vol' command.
|
||||
|
||||
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
||||
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
ShellCommandRunVol (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## @file
|
||||
# Provides shell level 2 functions
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation. All rights reserved. <BR>
|
||||
# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -44,6 +44,7 @@
|
|||
Rm.c
|
||||
Mv.c
|
||||
Attrib.c
|
||||
Vol.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,256 @@
|
|||
/** @file
|
||||
Main file for vol shell level 2 function.
|
||||
|
||||
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "UefiShellLevel2CommandsLib.h"
|
||||
#include <Guid/FileSystemInfo.h>
|
||||
#include <Guid/FileSystemVolumeLabelInfo.h>
|
||||
|
||||
/**
|
||||
Print the info or change the volume info.
|
||||
|
||||
@param[in] Path String with starting path.
|
||||
@param[in] Delete TRUE to delete the volume label. FALSE otherwise.
|
||||
@param[in] Name New name to set to the volume label.
|
||||
|
||||
@retval SHELL_SUCCESS The operation was sucessful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
HandleVol(
|
||||
IN CONST CHAR16 *Path,
|
||||
IN CONST BOOLEAN Delete,
|
||||
IN CONST CHAR16 *Name
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SHELL_STATUS ShellStatus;
|
||||
EFI_FILE_SYSTEM_INFO *SysInfo;
|
||||
UINTN SysInfoSize;
|
||||
SHELL_FILE_HANDLE ShellFileHandle;
|
||||
EFI_FILE_PROTOCOL *EfiFpHandle;
|
||||
UINTN Size1;
|
||||
UINTN Size2;
|
||||
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
|
||||
Status = gEfiShellProtocol->OpenFileByName(
|
||||
Path,
|
||||
&ShellFileHandle,
|
||||
Name != NULL?EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE:EFI_FILE_MODE_READ);
|
||||
|
||||
if (EFI_ERROR(Status) || ShellFileHandle == NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, Path);
|
||||
ShellStatus = SHELL_ACCESS_DENIED;
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Volume Info from ShellFileHandle
|
||||
//
|
||||
SysInfo = NULL;
|
||||
SysInfoSize = 0;
|
||||
EfiFpHandle = ConvertShellHandleToEfiFileProtocol(ShellFileHandle);
|
||||
Status = EfiFpHandle->GetInfo(
|
||||
EfiFpHandle,
|
||||
&gEfiFileSystemInfoGuid,
|
||||
&SysInfoSize,
|
||||
SysInfo);
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
SysInfo = AllocateZeroPool(SysInfoSize);
|
||||
Status = EfiFpHandle->GetInfo(
|
||||
EfiFpHandle,
|
||||
&gEfiFileSystemInfoGuid,
|
||||
&SysInfoSize,
|
||||
SysInfo);
|
||||
}
|
||||
|
||||
if (Delete) {
|
||||
StrCpy ((CHAR16 *) SysInfo->VolumeLabel, L"");
|
||||
SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize(SysInfo->VolumeLabel);
|
||||
Status = EfiFpHandle->SetInfo(
|
||||
EfiFpHandle,
|
||||
&gEfiFileSystemInfoGuid,
|
||||
(UINTN)SysInfo->Size,
|
||||
SysInfo);
|
||||
} else if (Name != NULL) {
|
||||
Size1 = StrSize(Name);
|
||||
Size2 = StrSize(SysInfo->VolumeLabel);
|
||||
if (Size1 > Size2) {
|
||||
SysInfo = ReallocatePool((UINTN)SysInfo->Size, (UINTN)SysInfo->Size + Size1 - Size2, SysInfo);
|
||||
}
|
||||
StrCpy ((CHAR16 *) SysInfo->VolumeLabel, Name);
|
||||
SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + Size1;
|
||||
Status = EfiFpHandle->SetInfo(
|
||||
EfiFpHandle,
|
||||
&gEfiFileSystemInfoGuid,
|
||||
(UINTN)SysInfo->Size,
|
||||
SysInfo);
|
||||
}
|
||||
|
||||
FreePool(SysInfo);
|
||||
|
||||
if (Delete || Name != NULL) {
|
||||
if (EFI_ERROR(Status)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, Path);
|
||||
ShellStatus = SHELL_ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
SysInfo = AllocateZeroPool(SysInfoSize);
|
||||
Status = EfiFpHandle->GetInfo(
|
||||
EfiFpHandle,
|
||||
&gEfiFileSystemInfoGuid,
|
||||
&SysInfoSize,
|
||||
SysInfo);
|
||||
|
||||
gEfiShellProtocol->CloseFile(ShellFileHandle);
|
||||
|
||||
//
|
||||
// print VolumeInfo table
|
||||
//
|
||||
ShellPrintHiiEx (
|
||||
0,
|
||||
gST->ConOut->Mode->CursorRow,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_VOL_VOLINFO),
|
||||
gShellLevel2HiiHandle,
|
||||
SysInfo->VolumeLabel,
|
||||
SysInfo->ReadOnly?L"r":L"rw",
|
||||
SysInfo->VolumeSize,
|
||||
SysInfo->FreeSpace,
|
||||
SysInfo->BlockSize
|
||||
);
|
||||
SHELL_FREE_NON_NULL(SysInfo);
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||
{L"-d", TypeFlag},
|
||||
{L"-n", TypeValue},
|
||||
{NULL, TypeMax}
|
||||
};
|
||||
|
||||
/**
|
||||
Function for 'Vol' command.
|
||||
|
||||
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
||||
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
||||
**/
|
||||
SHELL_STATUS
|
||||
EFIAPI
|
||||
ShellCommandRunVol (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
CONST CHAR16 *PathName;
|
||||
CONST CHAR16 *CurDir;
|
||||
BOOLEAN DeleteMode;
|
||||
CHAR16 *FullPath;
|
||||
UINTN Length;
|
||||
|
||||
Length = 0;
|
||||
ProblemParam = NULL;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
PathName = NULL;
|
||||
CurDir = NULL;
|
||||
FullPath = NULL;
|
||||
|
||||
//
|
||||
// initialize the shell lib (we must be in non-auto-init...)
|
||||
//
|
||||
Status = ShellInitialize();
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
|
||||
//
|
||||
// Fix local copies of the protocol pointers
|
||||
//
|
||||
Status = CommandInit();
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
|
||||
//
|
||||
// parse the command line
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);
|
||||
FreePool(ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// check for "-?"
|
||||
//
|
||||
if (ShellCommandLineGetFlag(Package, L"-?")) {
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
|
||||
if (ShellCommandLineGetCount(Package) > 2) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
PathName = ShellCommandLineGetRawValue(Package, 1);
|
||||
if (PathName == NULL) {
|
||||
CurDir = gEfiShellProtocol->GetCurDir(NULL);
|
||||
if (CurDir == NULL) {
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
|
||||
} else {
|
||||
PathName = CurDir;
|
||||
}
|
||||
}
|
||||
if (PathName != NULL) {
|
||||
StrnCatGrow(&FullPath, &Length, PathName, StrStr(PathName, L"\\")==NULL?0:StrStr(PathName, L"\\")-PathName+1);
|
||||
if (StrStr(FullPath, L":\\") == NULL) {
|
||||
StrnCatGrow(&FullPath, &Length, L":\\", 0);
|
||||
}
|
||||
DeleteMode = ShellCommandLineGetFlag(Package, L"-d");
|
||||
if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellCommandLineGetFlag(Package, L"-n") && ShellCommandLineGetValue(Package, L"-n") == NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-n");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellCommandLineGetValue(Package, L"-n") != NULL && StrLen(ShellCommandLineGetValue(Package, L"-n")) > 11) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-n");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellStatus == SHELL_SUCCESS) {
|
||||
ShellStatus = HandleVol(
|
||||
FullPath,
|
||||
DeleteMode,
|
||||
ShellCommandLineGetValue(Package, L"-n")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL(FullPath);
|
||||
|
||||
//
|
||||
// free the command line package
|
||||
//
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
Loading…
Reference in New Issue