X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EmbeddedPkg%2FEbl%2FDir.c;h=c45f67b95bdca1d35450774a296ecbba54fb95e7;hb=3402aac7d985bf8a9f9d3c639f3fe93609380513;hp=126ef5d7c78ca802e01b8a96a1c821b9bb7a043a;hpb=3575301ce76ebc18e5dff77e5ec4926ff1889798;p=mirror_edk2.git diff --git a/EmbeddedPkg/Ebl/Dir.c b/EmbeddedPkg/Ebl/Dir.c index 126ef5d7c7..c45f67b95b 100644 --- a/EmbeddedPkg/Ebl/Dir.c +++ b/EmbeddedPkg/Ebl/Dir.c @@ -1,11 +1,11 @@ /** @file Dir for EBL (Embedded Boot Loader) - Copyright (c) 2007, Intel Corporation
- Portions copyright (c) 2008-2009, Apple Inc. All rights reserved. + Copyright (c) 2007, Intel Corporation. All rights reserved.
+ Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- All rights reserved. This program and the accompanying materials + 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 http://opensource.org/licenses/bsd-license.php @@ -40,23 +40,23 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gFvFileType[] = { /** Perform a dir on a device. The device must support Simple File System Protocol - or the FV protocol. + or the FV protocol. Argv[0] - "dir" - Argv[1] - Device Name:path. Path is optional + Argv[1] - Device Name:path. Path is optional Argv[2] - Optional filename to match on. A leading * means match substring Argv[3] - Optional FV file type dir fs1:\efi ; perform a dir on fs1: device in the efi directory - dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but + dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but only print out files that contain the string *.efi - dir fv1:\ ; perform a dir on fv1: device in the efi directory - NOTE: fv devices do not contian subdirs + dir fv1:\ ; perform a dir on fv1: device in the efi directory + NOTE: fv devices do not contain subdirs dir fv1:\ * PEIM ; will match all files of type PEIM @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the comamnd name + @param Argv Array of strings that represent the parsed command line. + Argv[0] is the command name @return EFI_SUCCESS @@ -71,7 +71,7 @@ EblDirCmd ( EFI_OPEN_FILE *File; EFI_FILE_INFO *DirInfo; UINTN ReadSize; - UINTN CurrentRow; + UINTN CurrentRow; CHAR16 *MatchSubString; EFI_STATUS GetNextFileStatus; UINTN Key; @@ -90,6 +90,7 @@ EblDirCmd ( CHAR16 UnicodeFileName[MAX_CMD_LINE]; CHAR8 *Path; CHAR8 *TypeStr; + UINTN TotalSize; if (Argc <= 1) { @@ -143,26 +144,28 @@ EblDirCmd ( } } + TotalSize = 0; Fv = File->Fv; Key = 0; CurrentRow = 0; do { Type = SearchType; GetNextFileStatus = Fv->GetNextFile ( - Fv, + Fv, &Key, - &Type, - &NameGuid, - &Attributes, + &Type, + &NameGuid, + &Attributes, &Size ); if (!EFI_ERROR (GetNextFileStatus)) { + TotalSize += Size; // Calculate size of entire file Section = NULL; Size = 0; Status = Fv->ReadFile ( Fv, - &NameGuid, + &NameGuid, Section, &Size, &Type, @@ -170,10 +173,10 @@ EblDirCmd ( &AuthenticationStatus ); if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) { - // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid - Size = 0; + // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid + Size = 0; } - + TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN"; // read the UI seciton to do a name match. @@ -189,7 +192,7 @@ EblDirCmd ( ); if (!EFI_ERROR (Status)) { if (StrStr (Section, MatchSubString) != NULL) { - AsciiPrint ("%,6d %7a %g %s\n", Size, TypeStr, &NameGuid, Section); + AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section); if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { break; } @@ -197,7 +200,7 @@ EblDirCmd ( FreePool (Section); } else { if (*MatchSubString == '\0') { - AsciiPrint ("%,6d %7a %g\n", Size, TypeStr, &NameGuid); + AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid); if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { break; } @@ -205,7 +208,12 @@ EblDirCmd ( } } } while (!EFI_ERROR (GetNextFileStatus)); - + + if (SearchType == EFI_FV_FILETYPE_ALL) { + AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File->FvSize - File->FvHeaderSize - TotalSize); + } + + } else if ((File->Type == EfiOpenFileSystem) || (File->Type == EfiOpenBlockIo)) { // Simple File System DIR @@ -225,7 +233,7 @@ EblDirCmd ( if (UnicodeFileName[0] == '*') { MatchSubString = &UnicodeFileName[1]; } - } + } File->FsFileHandle->SetPosition (File->FsFileHandle, 0); for (CurrentRow = 0;;) { @@ -239,7 +247,7 @@ EblDirCmd ( if (DirInfo == NULL) { goto Done; } - + // Read the data Status = File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, DirInfo); if ((EFI_ERROR (Status)) || (ReadSize == 0)) { @@ -248,7 +256,7 @@ EblDirCmd ( } else { break; } - + if (MatchSubString != NULL) { if (StrStr (&DirInfo->FileName[0], MatchSubString) == NULL) { // does not match *name argument, so skip @@ -270,7 +278,7 @@ EblDirCmd ( if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { break; } - + FreePool (DirInfo); } @@ -289,11 +297,11 @@ Done: Change the Current Working Directory Argv[0] - "cd" - Argv[1] - Device Name:path. Path is optional + Argv[1] - Device Name:path. Path is optional @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the comamnd name + @param Argv Array of strings that represent the parsed command line. + Argv[0] is the command name @return EFI_SUCCESS @@ -306,8 +314,8 @@ EblCdCmd ( { if (Argc <= 1) { return EFI_SUCCESS; - } - + } + return EfiSetCwd (Argv[1]); } @@ -337,7 +345,7 @@ VOID EblInitializeDirCmd ( VOID ) -{ +{ if (FeaturePcdGet (PcdEmbeddedDirCmd)) { EblAddCommands (mCmdDirTemplate, sizeof (mCmdDirTemplate)/sizeof (EBL_COMMAND_TABLE)); }