[edk2] [PATCH v2] ShellPkg/Ls: Handle path specified from root

Jeff Westfahl posted 1 patch 7 years, 7 months ago
Failed in applying to current master (apply log)
ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 3 +++
1 file changed, 3 insertions(+)
[edk2] [PATCH v2] ShellPkg/Ls: Handle path specified from root
Posted by Jeff Westfahl 7 years, 7 months ago
This fixes 'ls' when specifying a path from the root, like "ls \" from
within a subfolder. Currently, 'ls' will append the specified path to the
current working directory. The correct behavior is to start from the root
of the currently selected filesystem.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 8d33392..8eeb2c0 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -685,6 +685,9 @@ ShellCommandRunLs (
                 ShellCommandLineFreeVarList (Package);
                 return SHELL_OUT_OF_RESOURCES;
               }
+              if (PathName[0] == L'\\') {
+                while (PathRemoveLastItem(FullPath)) ;
+              }
               Size = FullPath != NULL? StrSize(FullPath) : 0;
               StrnCatGrow(&FullPath, &Size, L"\\", 0);
             }
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v2] ShellPkg/Ls: Handle path specified from root
Posted by Carsey, Jaben 7 years, 7 months ago
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Jeff Westfahl [mailto:jeff.westfahl@ni.com]
> Sent: Monday, May 15, 2017 10:18 AM
> To: edk2-devel@lists.01.org
> Cc: Jeff Westfahl <jeff.westfahl@ni.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [edk2][PATCH v2] ShellPkg/Ls: Handle path specified from root
> Importance: High
> 
> This fixes 'ls' when specifying a path from the root, like "ls \" from
> within a subfolder. Currently, 'ls' will append the specified path to the
> current working directory. The correct behavior is to start from the root
> of the currently selected filesystem.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
> ---
>  ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> index 8d33392..8eeb2c0 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> @@ -685,6 +685,9 @@ ShellCommandRunLs (
>                  ShellCommandLineFreeVarList (Package);
>                  return SHELL_OUT_OF_RESOURCES;
>                }
> +              if (PathName[0] == L'\\') {
> +                while (PathRemoveLastItem(FullPath)) ;
> +              }
>                Size = FullPath != NULL? StrSize(FullPath) : 0;
>                StrnCatGrow(&FullPath, &Size, L"\\", 0);
>              }
> --
> 2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel