X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel2CommandsLib%2FLs.c;h=a93b54c4293d58f1855df611e4ee4e9992bcc0c0;hb=532691c8ba90e5022174503ab0781322c6f79cab;hp=61d48977f1d003e0269889ea3dabb9f0124c6e73;hpb=a405b86d274d32b92f69842bfb9a1ab143128f57;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c index 61d48977f1..a93b54c429 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -1,7 +1,7 @@ /** @file Main file for ls shell level 2 function. - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -67,7 +67,7 @@ PrintLsOutput( CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0); ASSERT(CorrectedPath != NULL); - ShellCommandCleanPath(CorrectedPath); + PathCleanUpDirectories(CorrectedPath); Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead); if (EFI_ERROR(Status)) { @@ -234,7 +234,7 @@ PrintLsOutput( // // exact match on all bits // - if ( Node->Info->Attribute != Attribs) { + if ( (Node->Info->Attribute|EFI_FILE_ARCHIVE) != (Attribs|EFI_FILE_ARCHIVE)) { continue; } } @@ -348,31 +348,36 @@ PrintLsOutput( } if (Rec){ - DirectoryName = AllocatePool(LongestPath + 2*sizeof(CHAR16)); - for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link) - ; !IsNull(&ListHead->Link, &Node->Link) - ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link) - ){ - // - // recurse on any directory except the traversing ones... - // - if (((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) - && StrCmp(Node->FileName, L".") != 0 - && StrCmp(Node->FileName, L"..") != 0 - ){ - StrCpy(DirectoryName, Node->FullName); - StrCat(DirectoryName, L"\\*"); - PrintLsOutput( - Rec, - Attribs, - Sfo, - DirectoryName, - FALSE, - Count, - TimeZone); + DirectoryName = AllocateZeroPool(LongestPath + 2*sizeof(CHAR16)); + if (DirectoryName == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle); + ShellStatus = SHELL_OUT_OF_RESOURCES; + } else { + for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link) + ; !IsNull(&ListHead->Link, &Node->Link) + ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link) + ){ + // + // recurse on any directory except the traversing ones... + // + if (((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) + && StrCmp(Node->FileName, L".") != 0 + && StrCmp(Node->FileName, L"..") != 0 + ){ + StrCpy(DirectoryName, Node->FullName); + StrCat(DirectoryName, L"\\*"); + PrintLsOutput( + Rec, + Attribs, + Sfo, + DirectoryName, + FALSE, + Count, + TimeZone); + } } + FreePool(DirectoryName); } - FreePool(DirectoryName); } FreePool(CorrectedPath); @@ -412,7 +417,7 @@ ShellCommandRunLs ( UINTN Count; CHAR16 *FullPath; UINTN Size; - EFI_TIME theTime; + EFI_TIME TheTime; BOOLEAN SfoMode; Size = 0; @@ -518,17 +523,26 @@ ShellCommandRunLs ( } } if (PathName != NULL) { - ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL)); - StrnCatGrow(&FullPath, &Size, PathName, 0); - if (ShellIsDirectory(PathName) == EFI_SUCCESS) { - StrnCatGrow(&FullPath, &Size, L"\\*", 0); + if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) { + ShellStatus = SHELL_NOT_FOUND; + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle); + } else { + ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL)); + StrnCatGrow(&FullPath, &Size, PathName, 0); + if (ShellIsDirectory(PathName) == EFI_SUCCESS) { + StrnCatGrow(&FullPath, &Size, L"\\*", 0); + } } } else { ASSERT(FullPath == NULL); StrnCatGrow(&FullPath, NULL, L"*", 0); } - Status = gRT->GetTime(&theTime, NULL); - ASSERT_EFI_ERROR(Status); + Status = gRT->GetTime(&TheTime, NULL); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status); + TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE; + } + SfoMode = ShellCommandLineGetFlag(Package, L"-sfo"); if (ShellStatus == SHELL_SUCCESS) { ShellStatus = PrintLsOutput( @@ -538,7 +552,7 @@ ShellCommandRunLs ( FullPath, TRUE, Count, - (INT16)(theTime.TimeZone==2047?0:theTime.TimeZone) + (INT16)(TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:TheTime.TimeZone) ); if (ShellStatus == SHELL_NOT_FOUND) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_FILES), gShellLevel2HiiHandle);