From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.510.1572568755810026198 for ; Thu, 31 Oct 2019 17:39:16 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: zhichao.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 17:39:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,253,1569308400"; d="scan'208";a="225884921" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 31 Oct 2019 17:39:15 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 31 Oct 2019 17:39:15 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.213]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.2]) with mapi id 14.03.0439.000; Fri, 1 Nov 2019 08:39:00 +0800 From: "Gao, Zhichao" To: =?iso-8859-1?Q?=27Marvin_H=E4user=27?= , "devel@edk2.groups.io" CC: "vit9696@protonmail.com" , "Ni, Ray" Subject: Re: [PATCH] ShellPkg/Ls: Return empty content for all empty folders Thread-Topic: [PATCH] ShellPkg/Ls: Return empty content for all empty folders Thread-Index: AQHVhz8YYOklQdM3n0O8Sde/0lsI9qdpBUFw Date: Fri, 1 Nov 2019 00:39:00 +0000 Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B86BACF@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: zhichao.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sorry for missing this one. Reviewed-by: Zhichao Gao > -----Original Message----- > From: Marvin H=E4user [mailto:Marvin.Haeuser@outlook.com] > Sent: Sunday, October 20, 2019 8:09 PM > To: devel@edk2.groups.io > Cc: vit9696@protonmail.com; Ni, Ray ; Gao, Zhichao > > Subject: [PATCH] ShellPkg/Ls: Return empty content for all empty folders >=20 > From: Marvin Haeuser >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2296 >=20 > 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. >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Marvin Haeuser > --- > ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 33 > +++++++++++++++++--- > 1 file changed, 28 insertions(+), 5 deletions(-) >=20 > 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] TimeZon= e > 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 =3D TRUE; } - if (!Sfo && ShellStatus !=3D SH= ELL_ABORTED) > {+ if (!Sfo && ShellStatus !=3D SHELL_ABORTED && HeaderPrinted) > { PrintNonSfoFooter(FileCount, FileSize, DirCount); } }@@ -60= 2,7 +605,8 > @@ PrintLsOutput( > SearchString, &FoundOne, Count,- = TimeZone);+ > TimeZone,+ FALSE); // // Since it's runni= ng recursively, we > have to break immediately when returned SHELL_ABORTED@@ -619,7 > +623,21 @@ PrintLsOutput( > ShellCloseFileMetaArg(&ListHead); if (Found =3D=3D NULL && !FoundOn= e) {- > return (SHELL_NOT_FOUND);+ if (ListUnfiltered) {+ //+ // Whe= n > running "ls" without any filtering request, avoid outputing+ // "Fil= e not > found" when the directory is entirely empty, but print+ // header an= d > footer stating "0 File(s), 0 Dir(s)".+ //+ if (!Sfo) {+ = PrintNonSfoHeader > (RootPath);+ if (ShellStatus !=3D SHELL_ABORTED) {+ > PrintNonSfoFooter (FileCount, FileSize, DirCount);+ }+ }+ = } else {+ > return (SHELL_NOT_FOUND);+ } } if (Found !=3D NULL) {@@ -662,6 +6= 80,7 > @@ ShellCommandRunLs ( > UINTN Size; EFI_TIME TheTime; CHAR16 *SearchSt= ring;+ > BOOLEAN ListUnfiltered; Size =3D 0; FullPath = =3D NULL;@@ - > 673,6 +692,7 @@ ShellCommandRunLs ( > SearchString =3D NULL; CurDir =3D NULL; Count = =3D 0;+ > ListUnfiltered =3D FALSE; // // initialize the shell lib (we mu= st be in non- > auto-init...)@@ -768,6 +788,7 @@ ShellCommandRunLs ( > ShellStatus =3D SHELL_NOT_FOUND; ShellPrintHiiEx= (-1, -1, NULL, > STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls"); }= + > ListUnfiltered =3D 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 =3D TRUE; > StrnCatGrow(&SearchString, NULL, L"*", 0); } else { = //@@ -839,7 > +861,8 @@ ShellCommandRunLs ( > SearchString, NULL, Count,- = TheTime.TimeZone+ > TheTime.TimeZone,+ ListUnfiltered ); if (= ShellStatus =3D=3D > SHELL_NOT_FOUND) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN > (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle, L"ls", FullPath);-- > 2.23.0.windows.1