From 22feb630eb1bbe975c4c14ff859156dcbf6f87e3 Mon Sep 17 00:00:00 2001 From: Jaben Carsey Date: Fri, 21 Jun 2013 21:20:03 +0000 Subject: ShellPkg: Update rm command to properly prepend file system identifiers to filenames. This is required when recursively removing directories with files on file systems other than the current one. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey Reviewed-by: Eugene Cohen git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14441 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c index 2eb54d3e39..e1473cf907 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c @@ -1,7 +1,7 @@ /** @file Main file for attrib shell level 2 function. - Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2013, 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 @@ -75,6 +75,7 @@ CascadeDelete( EFI_SHELL_FILE_INFO *Node2; EFI_STATUS Status; SHELL_PROMPT_RESPONSE *Resp; + CHAR16 *TempName; Resp = NULL; ShellStatus = SHELL_SUCCESS; @@ -120,6 +121,22 @@ CascadeDelete( continue; } Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE); + if (EFI_ERROR(Node2->Status) && StrStr(Node2->FileName, L":") == NULL) { + // + // Update the node filename to have full path with file system identifier + // + TempName = AllocateZeroPool(StrSize(Node->FullName) + StrSize(Node2->FullName)); + StrCpy(TempName, Node->FullName); + TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL; + StrCat(TempName, Node2->FullName); + FreePool((VOID*)Node2->FullName); + Node2->FullName = TempName; + + // + // Now try again to open the file + // + Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE); + } ShellStatus = CascadeDelete(Node2, Quiet); if (ShellStatus != SHELL_SUCCESS) { if (List!=NULL) { -- cgit v1.2.3