From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: Laszlo Ersek <lersek@redhat.com>,
edk2-devel-groups-io <devel@edk2.groups.io>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Ni, Ray" <ray.ni@intel.com>
Subject: Re: [PATCH 5/8] ShellPkg/Ls: sort output by FileName in non-SFO mode
Date: Wed, 13 Jan 2021 03:04:18 +0000 [thread overview]
Message-ID: <MWHPR11MB1647073A06483AA0F6593B15F6A90@MWHPR11MB1647.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20210104154235.31785-6-lersek@redhat.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Thanks,
Zhichao
> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com>
> Sent: Monday, January 4, 2021 11:43 PM
> To: edk2-devel-groups-io <devel@edk2.groups.io>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>; Ni, Ray <ray.ni@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>
> Subject: [PATCH 5/8] ShellPkg/Ls: sort output by FileName in non-SFO mode
>
> Sorting the LS output in non-SFO mode by FileName is best demonstrated with
> two examples.
>
> (1a) Before:
>
> > FS2:\> dir -r apps
> > Directory of: FS2:\apps\
> > 01/01/1970 01:00 <DIR> r 0 .
> > 12/22/2020 17:53 <DIR> 4,096 X64
> > 12/22/2020 17:53 <DIR> 4,096 AARCH64
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 12/22/2020 17:53 <DIR> 4,096 IA32
> > 0 File(s) 0 bytes
> > 5 Dir(s)
> > Directory of: FS2:\apps\X64\
> > 12/22/2020 17:52 18,752 DumpDynPcd.efi
> > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi
> > 01/01/1970 01:00 <DIR> r 0 .
> > 12/22/2020 17:52 11,456 VariableInfo.efi
> > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi
> > 12/22/2020 17:53 126,656 AcpiViewApp.efi
> > 12/22/2020 17:53 38,784 Cpuid.efi
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 6 File(s) 256,192 bytes
> > 2 Dir(s)
> > Directory of: FS2:\apps\AARCH64\
> > 12/22/2020 17:52 32,768 DumpDynPcd.efi
> > 01/01/1970 01:00 <DIR> r 0 .
> > 12/22/2020 17:52 20,480 VariableInfo.efi
> > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi
> > 12/22/2020 17:53 139,264 AcpiViewApp.efi
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 4 File(s) 233,472 bytes
> > 2 Dir(s)
> > Directory of: FS2:\apps\IA32\
> > 12/22/2020 17:52 17,344 DumpDynPcd.efi
> > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi
> > 01/01/1970 01:00 <DIR> r 0 .
> > 12/22/2020 17:52 10,880 VariableInfo.efi
> > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi
> > 12/22/2020 17:53 105,536 AcpiViewApp.efi
> > 12/22/2020 17:53 36,096 Cpuid.efi
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 6 File(s) 224,768 bytes
> > 2 Dir(s)
>
> (1b) After:
>
> > FS2:\> dir -r apps
> > Directory of: FS2:\apps\
> > 01/01/1970 01:00 <DIR> r 0 .
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 12/22/2020 17:53 <DIR> 4,096 AARCH64
> > 12/22/2020 17:53 <DIR> 4,096 IA32
> > 12/22/2020 17:53 <DIR> 4,096 X64
> > 0 File(s) 0 bytes
> > 5 Dir(s)
> > Directory of: FS2:\apps\X64\
> > 01/01/1970 01:00 <DIR> r 0 .
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 12/22/2020 17:53 126,656 AcpiViewApp.efi
> > 12/22/2020 17:53 38,784 Cpuid.efi
> > 12/22/2020 17:52 18,752 DumpDynPcd.efi
> > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi
> > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi
> > 12/22/2020 17:52 11,456 VariableInfo.efi
> > 6 File(s) 256,192 bytes
> > 2 Dir(s)
> > Directory of: FS2:\apps\AARCH64\
> > 01/01/1970 01:00 <DIR> r 0 .
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 12/22/2020 17:53 139,264 AcpiViewApp.efi
> > 12/22/2020 17:52 32,768 DumpDynPcd.efi
> > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi
> > 12/22/2020 17:52 20,480 VariableInfo.efi
> > 4 File(s) 233,472 bytes
> > 2 Dir(s)
> > Directory of: FS2:\apps\IA32\
> > 01/01/1970 01:00 <DIR> r 0 .
> > 01/01/1970 01:00 <DIR> r 0 ..
> > 12/22/2020 17:53 105,536 AcpiViewApp.efi
> > 12/22/2020 17:53 36,096 Cpuid.efi
> > 12/22/2020 17:52 17,344 DumpDynPcd.efi
> > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi
> > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi
> > 12/22/2020 17:52 10,880 VariableInfo.efi
> > 6 File(s) 224,768 bytes
> > 2 Dir(s)
>
> (2a) Before:
>
> > FS2:\> dir apps\*\*.efi
> > Directory of: FS2:\apps\*\
> > 12/22/2020 17:52 18,752 DumpDynPcd.efi
> > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi
> > 12/22/2020 17:52 11,456 VariableInfo.efi
> > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi
> > 12/22/2020 17:53 126,656 AcpiViewApp.efi
> > 12/22/2020 17:53 38,784 Cpuid.efi
> > 12/22/2020 17:52 32,768 DumpDynPcd.efi
> > 12/22/2020 17:52 20,480 VariableInfo.efi
> > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi
> > 12/22/2020 17:53 139,264 AcpiViewApp.efi
> > 12/22/2020 17:52 17,344 DumpDynPcd.efi
> > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi
> > 12/22/2020 17:52 10,880 VariableInfo.efi
> > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi
> > 12/22/2020 17:53 105,536 AcpiViewApp.efi
> > 12/22/2020 17:53 36,096 Cpuid.efi
> > 16 File(s) 714,432 bytes
> > 0 Dir(s)
>
> (2b) After:
>
> > FS2:\> dir apps\*\*.efi
> > Directory of: FS2:\apps\*\
> > 12/22/2020 17:53 126,656 AcpiViewApp.efi
> > 12/22/2020 17:53 139,264 AcpiViewApp.efi
> > 12/22/2020 17:53 105,536 AcpiViewApp.efi
> > 12/22/2020 17:53 38,784 Cpuid.efi
> > 12/22/2020 17:53 36,096 Cpuid.efi
> > 12/22/2020 17:52 18,752 DumpDynPcd.efi
> > 12/22/2020 17:52 32,768 DumpDynPcd.efi
> > 12/22/2020 17:52 17,344 DumpDynPcd.efi
> > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi
> > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi
> > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi
> > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi
> > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi
> > 12/22/2020 17:52 11,456 VariableInfo.efi
> > 12/22/2020 17:52 20,480 VariableInfo.efi
> > 12/22/2020 17:52 10,880 VariableInfo.efi
> > 16 File(s) 714,432 bytes
> > 0 Dir(s)
>
> (In example (2), note that the sorting is stable; that is, whatever order is
> established between identical FileNames by ShellOpenFileMetaArg(), it is
> preserved by ShellSortFileList().)
>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3151
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> index da2b1acab47c..8b97926d7f47 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> @@ -489,6 +489,20 @@ PrintLsOutput(
> PrintSfoVolumeInfoTableEntry(ListHead);
> }
>
> + if (!Sfo) {
> + //
> + // Sort the file list by FileName, stably.
> + //
> + // If the call below fails, then the EFI_SHELL_FILE_INFO list anchored to
> + // ListHead will not be changed in any way.
> + //
> + ShellSortFileList (
> + &ListHead,
> + NULL, // Duplicates
> + ShellSortFileListByFileName
> + );
> + }
> +
> for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link),
> LongestPath = 0
> ; !IsNull(&ListHead->Link, &Node->Link)
> ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node-
> >Link)
> --
> 2.19.1.3.g30247aa5d201
>
next prev parent reply other threads:[~2021-01-13 3:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 15:42 [PATCH 0/8] ShellPkg, ArmVirtPkg, OvmfPkg: shell usability improvements Laszlo Ersek
2021-01-04 15:42 ` [PATCH 1/8] ShellPkg/Comp: add file buffering Laszlo Ersek
2021-01-11 1:24 ` Gao, Zhichao
2021-01-04 15:42 ` [PATCH 2/8] OvmfPkg: raise PcdShellFileOperationSize to 128KB Laszlo Ersek
2021-01-04 15:42 ` [PATCH 3/8] ArmVirtPkg: " Laszlo Ersek
2021-01-04 15:42 ` [PATCH 4/8] ShellPkg/ShellCommandLib: add ShellSortFileList() Laszlo Ersek
2021-01-13 3:03 ` Gao, Zhichao
2021-01-04 15:42 ` [PATCH 5/8] ShellPkg/Ls: sort output by FileName in non-SFO mode Laszlo Ersek
2021-01-13 3:04 ` Gao, Zhichao [this message]
2021-01-04 15:42 ` [PATCH 6/8] ShellPkg/ShellProtocol: sort files by FullName in RemoveDupInFileList() Laszlo Ersek
2021-01-13 3:04 ` Gao, Zhichao
2021-01-04 15:42 ` [PATCH 7/8] OvmfPkg: disable list length checks in NOOPT and DEBUG builds Laszlo Ersek
2021-01-04 15:42 ` [PATCH 8/8] ArmVirtPkg: " Laszlo Ersek
2021-01-04 16:12 ` [PATCH 0/8] ShellPkg, ArmVirtPkg, OvmfPkg: shell usability improvements Ard Biesheuvel
2021-01-08 8:34 ` [edk2-devel] " Laszlo Ersek
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=MWHPR11MB1647073A06483AA0F6593B15F6A90@MWHPR11MB1647.namprd11.prod.outlook.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