summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorChris Phillips <chrisp@hp.com>2014-06-24 18:39:15 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-06-24 18:39:15 +0000
commit83c7a556a254048388d457d7a5a988ddff408b68 (patch)
tree5866964c934afdcd387d3f4bc82f04ecf4666185 /ShellPkg/Library
parentb34039b2e17e682d78feb92afba20132cc7d1e0b (diff)
downloadedk2-platforms-83c7a556a254048388d457d7a5a988ddff408b68.tar.xz
ShellPkg: Fix 'mv' command to not attempt moving a file from write-protected media
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips <chrisp@hp.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15584 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c26
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.unibin112756 -> 112782 bytes
2 files changed, 16 insertions, 10 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index 65e83ccc0f..f9b83e6fa4 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -1,8 +1,8 @@
/** @file
Main file for mv shell level 2 function.
- Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2009 - 2014, 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
@@ -29,6 +29,7 @@
@param Cwd [in] The current working directory
@param DestPath [in] The target location to move to
@param Attribute[in] The Attribute of the file
+ @param FileStatus[in] The Status of the file when opened
@retval TRUE The move is valid
@retval FALSE The move is not
@@ -36,10 +37,11 @@
BOOLEAN
EFIAPI
IsValidMove(
- IN CONST CHAR16 *FullName,
- IN CONST CHAR16 *Cwd,
- IN CONST CHAR16 *DestPath,
- IN CONST UINT64 Attribute
+ IN CONST CHAR16 *FullName,
+ IN CONST CHAR16 *Cwd,
+ IN CONST CHAR16 *DestPath,
+ IN CONST UINT64 Attribute,
+ IN CONST EFI_STATUS FileStatus
)
{
CHAR16 *Test;
@@ -87,11 +89,11 @@ IsValidMove(
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
return (FALSE);
}
- if ((Attribute & EFI_FILE_READ_ONLY) != 0) {
+ if (((Attribute & EFI_FILE_READ_ONLY) != 0) || (FileStatus == EFI_WRITE_PROTECTED)) {
//
// invalid to move read only
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, FullName);
return (FALSE);
}
Test = StrStr(FullName, L":");
@@ -290,7 +292,6 @@ ValidateAndMoveFiles(
ASSERT (DestPath != NULL);
ASSERT (HiiResultOk != NULL);
ASSERT (HiiOutput != NULL);
-// ASSERT (Cwd != NULL);
//
// Go through the list of files and directories to move...
@@ -302,8 +303,13 @@ ValidateAndMoveFiles(
if (ShellGetExecutionBreakFlag()) {
break;
}
+
+ //
+ // These should never be NULL
+ //
ASSERT(Node->FileName != NULL);
ASSERT(Node->FullName != NULL);
+ ASSERT(Node->Info != NULL);
//
// skip the directory traversing stuff...
@@ -315,7 +321,7 @@ ValidateAndMoveFiles(
//
// Validate that the move is valid
//
- if (!IsValidMove(Node->FullName, Cwd, DestPath, Node->Info->Attribute)) {
+ if (!IsValidMove(Node->FullName, Cwd, DestPath, Node->Info->Attribute, Node->Status)) {
ShellStatus = SHELL_INVALID_PARAMETER;
continue;
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
index 749d184a7a..51ec7e1267 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
Binary files differ