From d0a5723f505aaad41115aff8138bc9df5cda8468 Mon Sep 17 00:00:00 2001 From: Jaben Carsey Date: Mon, 31 Mar 2014 21:06:13 +0000 Subject: ShellPkg: Allow opening of root drive nodes Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey Reviewed-by: Erik Bjorge git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15424 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ShellProtocol.c | 51 +++++++++++++++++++----------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'ShellPkg/Application') diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index c702a35914..9cc4ca38c1 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1898,7 +1898,7 @@ CreateAndPopulateShellFileInfo( TempString = StrnCatGrow(&TempString, &Size, BasePath, 0); if (TempString == NULL) { FreePool((VOID*)ShellFileListItem->FileName); - FreePool(ShellFileListItem->Info); + SHELL_FREE_NON_NULL(ShellFileListItem->Info); FreePool(ShellFileListItem); return (NULL); } @@ -2105,6 +2105,7 @@ ShellSearchHandle( EFI_SHELL_FILE_INFO *ShellInfo; EFI_SHELL_FILE_INFO *ShellInfoNode; EFI_SHELL_FILE_INFO *NewShellNode; + EFI_FILE_INFO *FileInfo; BOOLEAN Directory; CHAR16 *NewFullName; UINTN Size; @@ -2132,30 +2133,44 @@ ShellSearchHandle( if (CurrentFilePattern[0] == CHAR_NULL &&NextFilePatternStart[0] == CHAR_NULL - ){ + ){ // - // Add the current parameter FileHandle to the list, then end... + // we want the parent or root node (if no parent) // if (ParentNode == NULL) { - Status = EFI_INVALID_PARAMETER; + // + // We want the root node. create the node. + // + FileInfo = FileHandleGetInfo(FileHandle); + NewShellNode = CreateAndPopulateShellFileInfo( + L":", + EFI_SUCCESS, + L"\\", + FileHandle, + FileInfo + ); + SHELL_FREE_NON_NULL(FileInfo); } else { + // + // Add the current parameter FileHandle to the list, then end... + // NewShellNode = InternalDuplicateShellFileInfo((EFI_SHELL_FILE_INFO*)ParentNode, TRUE); - if (NewShellNode == NULL) { - Status = EFI_OUT_OF_RESOURCES; - } else { - NewShellNode->Handle = NULL; - if (*FileList == NULL) { - *FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO)); - InitializeListHead(&((*FileList)->Link)); - } + } + if (NewShellNode == NULL) { + Status = EFI_OUT_OF_RESOURCES; + } else { + NewShellNode->Handle = NULL; + if (*FileList == NULL) { + *FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO)); + InitializeListHead(&((*FileList)->Link)); + } - // - // Add to the returning to use list - // - InsertTailList(&(*FileList)->Link, &NewShellNode->Link); + // + // Add to the returning to use list + // + InsertTailList(&(*FileList)->Link, &NewShellNode->Link); - Status = EFI_SUCCESS; - } + Status = EFI_SUCCESS; } } else { Status = EfiShellFindFilesInDir(FileHandle, &ShellInfo); -- cgit v1.2.3