From nobody Mon Apr 29 06:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49259+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49259+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=outlook.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1571585791341129.09276355900556; Sun, 20 Oct 2019 08:36:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bprGYY1788612xpeotRAE1Lh; Sun, 20 Oct 2019 08:36:30 -0700 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.1504.1571573315251344544 for ; Sun, 20 Oct 2019 05:08:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UNUCEvOXrinWD2P49W8fY19GeALbdwLVslwQZyNGQOaHkc+IQbx7y0cH40/ilyAlkxICs/8/x6V4FW4uUBYHMOuGdlzSiAGEJaps3pxEPU5L2130GHWtV7zfEL3KgZBUOHHBrzUaOJ9nAozXGl4uu7qWPKtZK18RsJSgDuqbVr8hTYBDGc0HhLt8kJM8xhuQ5r1UWynH0GJKMKnEiSu18ik0FZC1c5WcDJLHObmRPdBuw50fM4FXGDeVMMJ22rPGO/kGa+/WFy5p+LPH5cNulG3K6L+SwPSiOu1REuwJBEMSPavbS5ENEv5TQmGx3lxTWyCsmzwxY3BlIm9cOX6vzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B3fo6Vw8Vr7S+VDPsp2leCAP5euon+k1tGQ3twZh0N4=; b=k2nWb7azfbQBGX+PQ3G62qwXIkbTgnXu67sWejxRIkG74OWGtqTTUyRgs7tX3nT4r7tFrvwyJyLlfL61oNP71UJiFtm6h/Fm5kavEHWi68IIGgVyg5ixajgB2m8Fgj4YpmB2WMyi7BHxLjNxo+i4U8POptOmTONEMCheFtPktONOqd587u5nPdOiLJZwv1tDpfsargiagzYNs8l2O9s2WuLsDU4UWI2ex1gMq9kdSy6AkXTWz3OIjBO6hACi4bV0Xh1cgTS9m91cEMnFZkfSIWdVhKrgCx4z/DhlTST8aG3myFGpI0zdR+/1uqt5WCl/RokzbwxD/J5s+/zIgbiMRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none X-Received: from VE1EUR02FT003.eop-EUR02.prod.protection.outlook.com (10.152.12.55) by VE1EUR02HT150.eop-EUR02.prod.protection.outlook.com (10.152.13.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.14; Sun, 20 Oct 2019 12:08:33 +0000 X-Received: from DB7PR07MB4917.eurprd07.prod.outlook.com (10.152.12.58) by VE1EUR02FT003.mail.protection.outlook.com (10.152.12.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.14 via Frontend Transport; Sun, 20 Oct 2019 12:08:33 +0000 X-Received: from DB7PR07MB4917.eurprd07.prod.outlook.com ([fe80::1b8:f59a:96de:82ef]) by DB7PR07MB4917.eurprd07.prod.outlook.com ([fe80::1b8:f59a:96de:82ef%3]) with mapi id 15.20.2367.021; Sun, 20 Oct 2019 12:08:33 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "devel@edk2.groups.io" CC: "vit9696@protonmail.com" , Ray Ni , Zhichao Gao Subject: [edk2-devel] [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/0lsI9g== Date: Sun, 20 Oct 2019 12:08:33 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0052.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::29) To DB7PR07MB4917.eurprd07.prod.outlook.com (2603:10a6:10:5f::30) x-incomingtopheadermarker: OriginalChecksum:5AC81D680DB881777F8312BE18D2E5321DCF1D442D42511585DDAA7920FF380E;UpperCasedChecksum:0ABAB2DD040D34D7CCC60D246E20E776CA3ABAAEB015C2F1160EDCD751098719;SizeAsReceived:7753;Count:51 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [Bxk2i+US9dJ4RpM36p3M/BFI/PA3EItW] x-microsoft-original-message-id: <3b8072fcdb50ae2b6cf53be633d30e052841df73.1571572996.git.mhaeuser@outlook.de> x-ms-publictraffictype: Email x-incomingheadercount: 51 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR02HT150: x-ms-exchange-purlcount: 1 x-microsoft-antispam-message-info: y6+v26GV34zZ0mB2nbNNJxnJyqaZnFZQEZ7YyqZJkSpQlAPDh8Zry+3GzKHUqd/ACgac063O2jVYK/CvtXOztH/UY+0hSMeGZaE7MhUSQtrXslZbIywLKqGkEhzEKVPoYKQVBwY/K8rPhOaQoPsFE78Yu9mC/uHs9lYFak/g9majEQFm6hVurr9YsUWl+MPEHSB/enNthAWAog2oyO5raJAVimioOXdikjKBxGMWntc= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 4fbe4193-47d0-4928-575b-08d755563a69 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Oct 2019 12:08:33.5877 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT150 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Marvin.Haeuser@outlook.com X-Gm-Message-State: KDqWwfr8vLoW7EGJUJZVPDJmx1787277AA= Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1571585790; bh=ng+dSk2m9E9xgXT22drW0tGO2p3S0u6bKtueJnGf0bA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=PnATJRwNpe6fDvy56q8BmXRokPi2Y0Y/jl1t+B8U3vGpzFAauvuaUi+aA38zE70T+21 xgmPrdK1rvhijYNLGd98GkMvvusiBSyMfOVzsydEYTjdqMN1xbwAyLTcXGC7RYbYihcgS ElW8whkYH2Fd/9ANiQNzT4ehZG6GobzYUmA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Marvin Haeuser REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2296 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 Cc: Zhichao Gao Signed-off-by: Marvin Haeuser Reviewed-by: Zhichao Gao --- ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 33 +++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Li= brary/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. =20 @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; } =20 - if (!Sfo && ShellStatus !=3D SHELL_ABORTED) { + if (!Sfo && ShellStatus !=3D SHELL_ABORTED && HeaderPrinted) { PrintNonSfoFooter(FileCount, FileSize, DirCount); } } @@ -602,7 +605,8 @@ PrintLsOutput( SearchString, &FoundOne, Count, - TimeZone); + TimeZone, + FALSE); =20 // // Since it's running recursively, we have to break immediately = when returned SHELL_ABORTED @@ -619,7 +623,21 @@ PrintLsOutput( ShellCloseFileMetaArg(&ListHead); =20 if (Found =3D=3D 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 !=3D SHELL_ABORTED) { + PrintNonSfoFooter (FileCount, FileSize, DirCount); + } + } + } else { + return (SHELL_NOT_FOUND); + } } =20 if (Found !=3D NULL) { @@ -662,6 +680,7 @@ ShellCommandRunLs ( UINTN Size; EFI_TIME TheTime; CHAR16 *SearchString; + BOOLEAN ListUnfiltered; =20 Size =3D 0; FullPath =3D NULL; @@ -673,6 +692,7 @@ ShellCommandRunLs ( SearchString =3D NULL; CurDir =3D NULL; Count =3D 0; + ListUnfiltered =3D FALSE; =20 // // initialize the shell lib (we must 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), g= ShellLevel2HiiHandle, 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_FO= UND), gShellLevel2HiiHandle, L"ls", FullPath); --=20 2.23.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#49259): https://edk2.groups.io/g/devel/message/49259 Mute This Topic: https://groups.io/mt/35954834/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-