From 83c7a556a254048388d457d7a5a988ddff408b68 Mon Sep 17 00:00:00 2001 From: Chris Phillips Date: Tue, 24 Jun 2014 18:39:15 +0000 Subject: 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 Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15584 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 26 +++++++++++++-------- .../UefiShellLevel2CommandsLib.uni | Bin 112756 -> 112782 bytes 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'ShellPkg/Library/UefiShellLevel2CommandsLib') 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.
+ (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P. + Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
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 Binary files a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni and b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni differ -- cgit v1.2.3