* [PATCH] ShellPkg:‘cd \’ command fails to go back to the root directory of a file system
@ 2016-10-07 20:59 Tapan Shah
2016-10-12 17:25 ` Carsey, Jaben
0 siblings, 1 reply; 2+ messages in thread
From: Tapan Shah @ 2016-10-07 20:59 UTC (permalink / raw)
To: edk2-devel; +Cc: jaben.carsey, Tapan Shah
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>
---
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<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);
}
}
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ShellPkg:‘cd \’ command fails to go back to the root directory of a file system
2016-10-07 20:59 [PATCH] ShellPkg:‘cd \’ command fails to go back to the root directory of a file system Tapan Shah
@ 2016-10-12 17:25 ` Carsey, Jaben
0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2016-10-12 17:25 UTC (permalink / raw)
To: Tapan Shah, edk2-devel@lists.01.org; +Cc: Carsey, Jaben
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
And pushed.
> -----Original Message-----
> From: Tapan Shah [mailto:tapandshah@hpe.com]
> Sent: Friday, October 07, 2016 2:00 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Tapan Shah
> <tapandshah@hpe.com>
> Subject: [PATCH] ShellPkg:‘cd \’ command fails to go back to the root
> directory of a file system
> Importance: High
>
> 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>
> ---
> 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<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);
> }
> }
> --
> 1.9.5.msysgit.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-12 17:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-07 20:59 [PATCH] ShellPkg:‘cd \’ command fails to go back to the root directory of a file system Tapan Shah
2016-10-12 17:25 ` Carsey, Jaben
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox