mirror of https://github.com/acidanthera/audk.git
ShellPkg: fix 'ls' handling of empty drives where there is not even an "." or ".." directory.
Signed-off-by: jcarsey Reviewed-by: winddy_zhang@byosoft.com.cn git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12981 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
66c44008ba
commit
74fa83fda6
|
@ -1799,7 +1799,7 @@ CreateAndPopulateShellFileInfo(
|
||||||
if (ShellFileListItem == NULL) {
|
if (ShellFileListItem == NULL) {
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (Info != NULL) {
|
if (Info != NULL && Info->Size != 0) {
|
||||||
ShellFileListItem->Info = AllocateZeroPool((UINTN)Info->Size);
|
ShellFileListItem->Info = AllocateZeroPool((UINTN)Info->Size);
|
||||||
if (ShellFileListItem->Info == NULL) {
|
if (ShellFileListItem->Info == NULL) {
|
||||||
FreePool(ShellFileListItem);
|
FreePool(ShellFileListItem);
|
||||||
|
|
|
@ -509,9 +509,12 @@ FileHandleFindFirstFile (
|
||||||
//
|
//
|
||||||
Status = FileHandleRead (DirHandle, &BufferSize, *Buffer);
|
Status = FileHandleRead (DirHandle, &BufferSize, *Buffer);
|
||||||
ASSERT(Status != EFI_BUFFER_TOO_SMALL);
|
ASSERT(Status != EFI_BUFFER_TOO_SMALL);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status) || BufferSize == 0) {
|
||||||
FreePool(*Buffer);
|
FreePool(*Buffer);
|
||||||
*Buffer = NULL;
|
*Buffer = NULL;
|
||||||
|
if (BufferSize == 0) {
|
||||||
|
return (EFI_NOT_FOUND);
|
||||||
|
}
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
|
|
|
@ -66,14 +66,22 @@ PrintLsOutput(
|
||||||
CorrectedPath = NULL;
|
CorrectedPath = NULL;
|
||||||
|
|
||||||
CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);
|
CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);
|
||||||
ASSERT(CorrectedPath != NULL);
|
if (CorrectedPath == NULL) {
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
PathCleanUpDirectories(CorrectedPath);
|
PathCleanUpDirectories(CorrectedPath);
|
||||||
|
|
||||||
Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
|
Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
|
SHELL_FREE_NON_NULL(CorrectedPath);
|
||||||
|
if(Status == EFI_NOT_FOUND){
|
||||||
|
return (SHELL_NOT_FOUND);
|
||||||
|
}
|
||||||
return (SHELL_DEVICE_ERROR);
|
return (SHELL_DEVICE_ERROR);
|
||||||
}
|
}
|
||||||
if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {
|
if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {
|
||||||
|
SHELL_FREE_NON_NULL(CorrectedPath);
|
||||||
//
|
//
|
||||||
// On the first one only we expect to find something...
|
// On the first one only we expect to find something...
|
||||||
// do we find the . and .. directories otherwise?
|
// do we find the . and .. directories otherwise?
|
||||||
|
|
Loading…
Reference in New Issue