From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: "'Marvin Häuser'" <Marvin.Haeuser@outlook.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "vit9696@protonmail.com" <vit9696@protonmail.com>,
"Ni, Ray" <ray.ni@intel.com>
Subject: Re: [PATCH] ShellPkg/Ls: Return empty content for all empty folders
Date: Fri, 1 Nov 2019 00:39:00 +0000 [thread overview]
Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B86BACF@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <DB7PR07MB4917FA11270BD7D5B108EBE4806E0@DB7PR07MB4917.eurprd07.prod.outlook.com>
Sorry for missing this one.
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
> -----Original Message-----
> From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com]
> Sent: Sunday, October 20, 2019 8:09 PM
> To: devel@edk2.groups.io
> Cc: vit9696@protonmail.com; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>
> Subject: [PATCH] ShellPkg/Ls: Return empty content for all empty folders
>
> From: Marvin Haeuser <mhaeuser@outlook.de>
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2296
>
> Currently, when 'ls' is run on an entirely empty directory (this includes not
> having '.' and '..'), the output is always 'File not found'. For when not filtering
> its children, this patch rather displays the usual header and footer.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Marvin Haeuser <mhaeuser@outlook.de>
> ---
> ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 33
> +++++++++++++++++---
> 1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> index 1a65f60c3b44..da2b1acab47c 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> @@ -417,6 +417,8 @@ FileTimeToLocalTime (
> @param[in] Found Set to TRUE, if anyone were found. @param[in]
> Count The count of bits enabled in Attribs. @param[in] TimeZone
> The current time zone offset.+ @param[in] ListUnfiltered TRUE to request
> listing the directory contents+ unfiltered. @retval
> SHELL_SUCCESS the printing was sucessful. **/@@ -429,7 +431,8 @@
> PrintLsOutput(
> IN CONST CHAR16 *SearchString, IN BOOLEAN *Found, IN CONST
> UINTN Count,- IN CONST INT16 TimeZone+ IN CONST INT16 TimeZone,+
> IN CONST BOOLEAN ListUnfiltered ) { EFI_STATUS Status;@@ -555,7
> +558,7 @@ PrintLsOutput(
> HeaderPrinted = TRUE; } - if (!Sfo && ShellStatus != SHELL_ABORTED)
> {+ if (!Sfo && ShellStatus != SHELL_ABORTED && HeaderPrinted)
> { PrintNonSfoFooter(FileCount, FileSize, DirCount); } }@@ -602,7 +605,8
> @@ PrintLsOutput(
> SearchString, &FoundOne, Count,- TimeZone);+
> TimeZone,+ FALSE); // // Since it's running recursively, we
> have to break immediately when returned SHELL_ABORTED@@ -619,7
> +623,21 @@ PrintLsOutput(
> ShellCloseFileMetaArg(&ListHead); if (Found == NULL && !FoundOne) {-
> return (SHELL_NOT_FOUND);+ if (ListUnfiltered) {+ //+ // When
> running "ls" without any filtering request, avoid outputing+ // "File not
> found" when the directory is entirely empty, but print+ // header and
> footer stating "0 File(s), 0 Dir(s)".+ //+ if (!Sfo) {+ PrintNonSfoHeader
> (RootPath);+ if (ShellStatus != SHELL_ABORTED) {+
> PrintNonSfoFooter (FileCount, FileSize, DirCount);+ }+ }+ } else {+
> return (SHELL_NOT_FOUND);+ } } if (Found != NULL) {@@ -662,6 +680,7
> @@ ShellCommandRunLs (
> UINTN Size; EFI_TIME TheTime; CHAR16 *SearchString;+
> BOOLEAN ListUnfiltered; Size = 0; FullPath = NULL;@@ -
> 673,6 +692,7 @@ ShellCommandRunLs (
> SearchString = NULL; CurDir = NULL; Count = 0;+
> ListUnfiltered = FALSE; // // initialize the shell lib (we must be in non-
> auto-init...)@@ -768,6 +788,7 @@ ShellCommandRunLs (
> ShellStatus = SHELL_NOT_FOUND; ShellPrintHiiEx(-1, -1, NULL,
> STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls"); }+
> ListUnfiltered = TRUE; // // Copy to the 2 strings for starting path
> and file search string //@@ -808,6 +829,7 @@ ShellCommandRunLs (
> // // is listing ends with a directory, then we list all files in that
> directory //+ ListUnfiltered = TRUE;
> StrnCatGrow(&SearchString, NULL, L"*", 0); } else { //@@ -839,7
> +861,8 @@ ShellCommandRunLs (
> SearchString, NULL, Count,- TheTime.TimeZone+
> TheTime.TimeZone,+ ListUnfiltered ); if (ShellStatus ==
> SHELL_NOT_FOUND) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle, L"ls", FullPath);--
> 2.23.0.windows.1
next prev parent reply other threads:[~2019-11-01 0:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <aa5718fc4fdc610f03912cfcfd6fd8760d866117.1571572996.git.mhaeuser@outlook.de>
2019-10-20 12:08 ` [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames Marvin Häuser
2019-10-24 2:51 ` Gao, Zhichao
2019-11-04 0:50 ` Liming Gao
[not found] ` <15D3CF493CDD3994.15406@groups.io>
2019-11-04 2:07 ` [edk2-devel] " Liming Gao
2019-10-20 12:08 ` [PATCH] ShellPkg/Ls: Consider UEFI timezone may not be set Marvin Häuser
2019-10-24 1:19 ` Gao, Zhichao
2019-10-20 12:08 ` [PATCH] ShellPkg/Ls: Return empty content for all empty folders Marvin Häuser
2019-11-01 0:39 ` Gao, Zhichao [this message]
2019-10-20 12:08 ` [PATCH] UefiShellCommandLib: Default to first found UC for unsupported PlatformLang Marvin Häuser
2019-10-24 1:24 ` Gao, Zhichao
2019-11-05 3:03 ` Ni, Ray
2019-11-05 4:52 ` Gao, Zhichao
2019-11-05 6:41 ` Gao, Zhichao
2019-10-20 12:08 ` [PATCH] MdePkg/UefiDebugLibConOut: Pass the correct buffer size Marvin Häuser
2019-10-21 3:11 ` Liming Gao
[not found] ` <15CF8AE415F70486.7044@groups.io>
2019-11-04 2:11 ` [edk2-devel] " Liming Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3CE959C139B4C44DBEA1810E3AA6F9000B86BACF@SHSMSX101.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox