Fix component name bugs when input Controller Name is invalid

Fix the driver binding version for platform/OEM specific drivers 




git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2275 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2007-01-19 09:46:44 +00:00
parent 61fb1657e5
commit caea5554ab
10 changed files with 326 additions and 263 deletions

View File

@ -60,8 +60,8 @@ Abstract:
--*/
#include <fcntl.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include "UnixBlockIo.h"
//
@ -318,7 +318,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixBlockIoDriverBinding = {
UnixBlockIoDriverBindingSupported,
UnixBlockIoDriverBindingStart,
UnixBlockIoDriverBindingStop,
0x10,
0xa,
NULL,
NULL
};
@ -372,7 +372,7 @@ Returns:
//
// Check the GUID to see if this is a handle type the driver supports
//
if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixVirtualDisksGuid) ) {
if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixVirtualDisksGuid) ) {
Status = EFI_SUCCESS;
}
}
@ -420,7 +420,7 @@ Returns:
BOOLEAN WriteProtected;
UINTN NumberOfBlocks;
UINTN BlockSize;
INTN i;
INTN i;
//
// Grab the protocols we need
@ -446,47 +446,47 @@ Returns:
}
Status = EFI_NOT_FOUND;
// Extract filename.
// Extract filename.
Str = UnixIo->EnvString;
i = 0;
while (*Str && *Str != ':')
Buffer[i++] = *Str++;
Buffer[i] = 0;
i = 0;
while (*Str && *Str != ':')
Buffer[i++] = *Str++;
Buffer[i] = 0;
if (*Str != ':') {
goto Done;
}
Str++;
RemovableMedia = FALSE;
WriteProtected = TRUE;
NumberOfBlocks = 0;
BlockSize = 512;
do {
RemovableMedia = FALSE;
WriteProtected = TRUE;
NumberOfBlocks = 0;
BlockSize = 512;
do {
if (*Str == 'R' || *Str == 'F') {
RemovableMedia = (BOOLEAN) (*Str == 'R');
Str++;
}
}
if (*Str == 'O' || *Str == 'W') {
WriteProtected = (BOOLEAN) (*Str == 'O');
Str++;
}
if (*Str == 0)
break;
if (*Str != ';')
goto Done;
Str++;
Str++;
}
if (*Str == 0)
break;
if (*Str != ';')
goto Done;
Str++;
NumberOfBlocks = Atoi (Str);
Str = GetNextElementPastTerminator (Str, ';');
if (NumberOfBlocks == 0)
break;
if (NumberOfBlocks == 0)
break;
BlockSize = Atoi (Str);
if (BlockSize != 0)
if (BlockSize != 0)
Str = GetNextElementPastTerminator (Str, ';');
} while (0);
} while (0);
//
// If we get here the variable is valid so do the work.
//
@ -693,10 +693,10 @@ Returns:
Private->Filename[Index] = 0;
Private->Mode = (ReadOnly ? O_RDONLY : O_RDWR);
Private->Mode = (ReadOnly ? O_RDONLY : O_RDWR);
Private->NumberOfBlocks = NumberOfBlocks;
Private->fd = -1;
Private->fd = -1;
Private->ControllerNameTable = NULL;
@ -780,19 +780,19 @@ Returns:
//
// If the device is already opened, close it
//
if (Private->fd >= 0) {
if (Private->fd >= 0) {
BlockIo->Reset (BlockIo, FALSE);
}
//
// Open the device
//
Private->fd = Private->UnixThunk->Open
(Private->Filename, Private->Mode, 0644);
Private->fd = Private->UnixThunk->Open
(Private->Filename, Private->Mode, 0644);
if (Private->fd < 0) {
DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s\n",
Private->Filename));
if (Private->fd < 0) {
DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s\n",
Private->Filename));
BlockIo->Media->MediaPresent = FALSE;
Status = EFI_NO_MEDIA;
goto Done;
@ -834,12 +834,12 @@ Returns:
//
// first set it to 0
//
Private->UnixThunk->FTruncate (Private->fd, 0);
Private->UnixThunk->FTruncate (Private->fd, 0);
//
// then set it to the needed file size (OS will zero fill it)
//
Private->UnixThunk->FTruncate (Private->fd, EndOfFile);
Private->UnixThunk->FTruncate (Private->fd, EndOfFile);
}
DEBUG ((EFI_D_INIT, "%HPlOpenBlock: opened %s%N\n", Private->Filename));
@ -878,13 +878,13 @@ Returns:
--*/
{
return EFI_DEVICE_ERROR;
#if 0
#if 0
EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_STATUS Status;
BOOLEAN ReinstallBlockIoFlag;
BlockIo = &Private->BlockIo;
switch (Private->UnixThunk->GetLastError ()) {
@ -928,7 +928,7 @@ Returns:
}
return Status;
#endif
#endif
}
STATIC
@ -1017,7 +1017,7 @@ Returns:
// Seek to End of File
//
DistanceToMove = MultU64x32 (Lba, BlockSize);
Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);
Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_INIT, "WriteBlocks: SetFilePointer failed\n"));
@ -1062,7 +1062,7 @@ UnixBlockIoReadBlocks (
--*/
{
UNIX_BLOCK_IO_PRIVATE *Private;
ssize_t len;
ssize_t len;
EFI_STATUS Status;
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@ -1072,9 +1072,9 @@ UnixBlockIoReadBlocks (
return Status;
}
len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize);
len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize);
if (len != BufferSize) {
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));
return UnixBlockIoError (Private);
}
@ -1121,7 +1121,7 @@ UnixBlockIoWriteBlocks (
--*/
{
UNIX_BLOCK_IO_PRIVATE *Private;
ssize_t len;
ssize_t len;
EFI_STATUS Status;
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@ -1131,9 +1131,9 @@ UnixBlockIoWriteBlocks (
return Status;
}
len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize);
len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize);
if (len != BufferSize) {
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));
return UnixBlockIoError (Private);
}
@ -1198,7 +1198,7 @@ UnixBlockIoResetBlock (
if (Private->fd >= 0) {
Private->UnixThunk->Close (Private->fd);
Private->fd = -1;
Private->fd = -1;
}
return EFI_SUCCESS;
@ -1272,15 +1272,15 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
// TODO: MoveMethod - add argument and description to function comment
{
EFI_STATUS Status;
off_t res;
off_t res;
res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);
if (res == -1) {
res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);
if (res == -1) {
Status = EFI_INVALID_PARAMETER;
}
if (NewFilePointer != NULL) {
*NewFilePointer = res;
*NewFilePointer = res;
}
return Status;