summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTapan Shah <tapandshah@hpe.com>2016-10-07 13:59:34 -0700
committerJaben Carsey <jaben.carsey@intel.com>2016-10-12 10:24:35 -0700
commita7ea752e59bbbf69c6d8a72ee6a8b7a0f77cca7c (patch)
treeaf60eb7b1e7706bc108a8c6096248e260feb22b6
parenta12b214ef9e002b3b7a7f7845bb025a2a8597dcc (diff)
downloadedk2-a7ea752e59bbbf69c6d8a72ee6a8b7a0f77cca7c.tar.gz
ShellPkg:?cd \? command fails to go back to the root directory of a file system
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 <tapandshah@hpe.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
index 2e51b4cb4..0967bc7c5 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<BR>
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
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);
}
}