From f3a14a0f575e7e856ff4d90d7d0ab73f7e02ae41 Mon Sep 17 00:00:00 2001 From: Shumin Qiu Date: Wed, 12 Feb 2014 01:52:27 +0000 Subject: Add code to check the return status for ShellReadFile and ShellWriteFile when execute the 'cp' command. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shumin Qiu Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15231 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | 15 +++++++++++++-- .../UefiShellLevel2CommandsLib.uni | Bin 111846 -> 112254 bytes 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'ShellPkg/Library/UefiShellLevel2CommandsLib') diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c index ae36807958..8fc263f6ba 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c @@ -224,12 +224,23 @@ CopySingleFile( ASSERT(Buffer != NULL); while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) { Status = ShellReadFile(SourceHandle, &ReadSize, Buffer); - Status = ShellWriteFile(DestHandle, &ReadSize, Buffer); + if (!EFI_ERROR(Status)) { + 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, Dest); + break; + } + } else { + ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT)); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, Source); + break; + } } } SHELL_FREE_NON_NULL(DestVolumeInfo); } - + // // close files // diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni index f0991507c4..a64091591e 100644 Binary files a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni and b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni differ -- cgit v1.2.3