From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 707D31A1E72 for ; Fri, 7 Oct 2016 13:59:42 -0700 (PDT) Received: from SHAHTA6.americas.hpqcorp.net (shahta6.americas.hpqcorp.net [16.100.127.81]) by g9t5009.houston.hpe.com (Postfix) with ESMTP id 1051A55; Fri, 7 Oct 2016 20:59:40 +0000 (UTC) From: Tapan Shah To: edk2-devel@lists.01.org Cc: jaben.carsey@intel.com, Tapan Shah Date: Fri, 7 Oct 2016 15:59:34 -0500 Message-Id: <1475873974-3896-1-git-send-email-tapandshah@hpe.com> X-Mailer: git-send-email 1.9.5.msysgit.0 MIME-Version: 1.0 Subject: =?UTF-8?B?W1BBVENIXSBTaGVsbFBrZzrigJhjZCBc4oCZIGNvbW1hbmQgZmFpbHMgdG8gZ28gYmFjayB0byB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgYSBmaWxlIHN5c3RlbQ==?= X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2016 20:59:42 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows cd command to go back to the root directory when 'cd \' executed in system. This change prevents last PathRemoveLastItem() call which truncates '\' from 'fs0:\' in desired root path which is required to set CWD to the root directory. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah --- ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c index 2e51b4c..0967bc7 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c @@ -1,6 +1,7 @@ /** @file Main file for attrib shell level 2 function. + (C) Copyright 2016 Hewlett Packard Enterprise Development LP
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials @@ -164,7 +165,16 @@ ShellCommandRunCd ( StrCpyS (Cwd, StrSize (Directory) / sizeof (CHAR16) + 1, Directory); StrCatS (Cwd, StrSize (Directory) / sizeof (CHAR16) + 1, L"\\"); Drive = GetFullyQualifiedPath (Cwd); - while (PathRemoveLastItem (Drive)); + while (PathRemoveLastItem (Drive)) { + // + // Check if Drive contains 'fsx:\' only or still points to a sub-directory. + // Don't remove trailing '\' from Drive if it points to the root directory. + // + Path = StrStr (Drive, L":\\"); + if ((Path != NULL) && (*(Path + 2) == CHAR_NULL)) { + break; + } + } FreePool (Cwd); } } -- 1.9.5.msysgit.0