summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorTapan Shah <tapandshah@hp.com>2015-04-07 20:39:22 +0000
committerjcarsey <jcarsey@Edk2>2015-04-07 20:39:22 +0000
commitbf6bbc212d77736c9f81d6877701d4cf86030349 (patch)
treeb3d017989cb50afd5937ee61f389afcca114b9ba /ShellPkg
parentbbf57d4fb9047c01d1e27f8a05e0c41b94fbc4b7 (diff)
downloadedk2-platforms-bf6bbc212d77736c9f81d6877701d4cf86030349.tar.xz
ShellPkg: fix mv and cp command related issues
1.mv deletes file/directory when trying to move it to non-existing file system. 2.mv causes RSOD in system when trying to move same file at the same location. 3.Refactor mv and cp command with command name passed-in. remove redundant move status error message when file failed to move across file system. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah <tapandshah@hp.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17129 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c16
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c25
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h4
3 files changed, 31 insertions, 14 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
index f857767047..ffe1ebce6a 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
@@ -53,6 +53,7 @@ ValidateAndCopyFiles(
@param[in] Dest pointer to destination file name
@param[out] Resp pointer to response from question. Pass back on looped calling
@param[in] SilentMode whether to run in quiet mode or not
+ @param[in] CmdName Source command name requesting single file copy
@retval SHELL_SUCCESS The source file was copied to the destination
**/
@@ -62,7 +63,8 @@ CopySingleFile(
IN CONST CHAR16 *Source,
IN CONST CHAR16 *Dest,
OUT VOID **Resp,
- IN BOOLEAN SilentMode
+ IN BOOLEAN SilentMode,
+ IN CONST CHAR16 *CmdName
)
{
VOID *Response;
@@ -132,7 +134,7 @@ CopySingleFile(
if (ShellIsDirectory(Source) == EFI_SUCCESS) {
Status = ShellCreateDirectory(Dest, &DestHandle);
if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, L"cp", Dest);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
return (SHELL_ACCESS_DENIED);
}
@@ -161,7 +163,7 @@ CopySingleFile(
//
Status = ShellOpenFileByName(Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, L"cp", Dest);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
return (SHELL_ACCESS_DENIED);
}
@@ -217,7 +219,7 @@ CopySingleFile(
//not enough space on destination directory to copy file
//
SHELL_FREE_NON_NULL(DestVolumeInfo);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, L"cp");
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, CmdName);
return(SHELL_VOLUME_FULL);
} else {
//
@@ -231,12 +233,12 @@ CopySingleFile(
Status = ShellWriteFile(DestHandle, &ReadSize, Buffer);
if (EFI_ERROR(Status)) {
ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, L"cp", Dest);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, CmdName, Dest);
break;
}
} else {
ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, L"cp", Source);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, CmdName, Source);
break;
}
}
@@ -531,7 +533,7 @@ ValidateAndCopyFiles(
//
// copy single file...
//
- ShellStatus = CopySingleFile(Node->FullName, DestPath, &Response, SilentMode);
+ ShellStatus = CopySingleFile(Node->FullName, DestPath, &Response, SilentMode, L"cp");
if (ShellStatus != SHELL_SUCCESS) {
break;
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index 9160204195..c025cebe56 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -128,7 +128,7 @@ IsValidMove(
//
// If they're the same, or if source is "above" dest on file path tree
//
- if ( StrCmp(DestPathWalker, SourcePath) == 0
+ if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0
|| StrStr(DestPathWalker, SourcePath) == DestPathWalker
) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
@@ -291,25 +291,33 @@ MoveBetweenFileSystems(
OUT VOID **Resp
)
{
- EFI_STATUS Status;
+ SHELL_STATUS ShellStatus;
//
// First we copy the file
//
- Status = CopySingleFile(Node->FullName, DestPath, Resp, TRUE);
+ ShellStatus = CopySingleFile (Node->FullName, DestPath, Resp, TRUE, L"mv");
//
// Check our result
//
- if (!EFI_ERROR(Status)) {
+ if (ShellStatus == SHELL_SUCCESS) {
//
// The copy was successful. delete the source file.
//
CascadeDelete(Node, TRUE);
Node->Handle = NULL;
+ } else if (ShellStatus == SHELL_ABORTED) {
+ return EFI_ABORTED;
+ } else if (ShellStatus == SHELL_ACCESS_DENIED) {
+ return EFI_ACCESS_DENIED;
+ } else if (ShellStatus == SHELL_VOLUME_FULL) {
+ return EFI_VOLUME_FULL;
+ } else {
+ return EFI_UNSUPPORTED;
}
- return (Status);
+ return (EFI_SUCCESS);
}
/**
@@ -587,13 +595,18 @@ ValidateAndMoveFiles(
Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);
} else {
Status = MoveWithinFileSystems(Node, DestPath, &Response);
+ //
+ // Display error status
+ //
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
+ }
}
//
// Check our result
//
if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);
ShellStatus = SHELL_INVALID_PARAMETER;
if (Status == EFI_SECURITY_VIOLATION) {
ShellStatus = SHELL_SECURITY_VIOLATION;
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
index 05582da3ca..634515e493 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
@@ -338,6 +338,7 @@ ShellCommandRunVol (
@param[in] Dest pointer to destination file name
@param[out] Resp pointer to response from question. Pass back on looped calling
@param[in] SilentMode whether to run in quiet mode or not
+ @param[in] CmdName Source command name requesting single file copy
@retval SHELL_SUCCESS The source file was copied to the destination
**/
@@ -347,7 +348,8 @@ CopySingleFile(
IN CONST CHAR16 *Source,
IN CONST CHAR16 *Dest,
OUT VOID **Resp,
- IN BOOLEAN SilentMode
+ IN BOOLEAN SilentMode,
+ IN CONST CHAR16 *CmdName
);
/**