diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-19 09:46:44 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-19 09:46:44 +0000 |
commit | caea5554abdc29d7774bdd0ec4852be09d5a1630 (patch) | |
tree | 400efc381aa2ae7707559012c81d01e0aa8c5d84 /EdkUnixPkg/Dxe | |
parent | 61fb1657e5b2b37a2ec5c879f6fa7689100f0d54 (diff) | |
download | edk2-platforms-caea5554abdc29d7774bdd0ec4852be09d5a1630.tar.xz |
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
Diffstat (limited to 'EdkUnixPkg/Dxe')
10 files changed, 329 insertions, 266 deletions
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c index fd4b75e46f..19085fd88a 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c @@ -160,7 +160,17 @@ UnixBlockIoComponentNameGetControllerName ( if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
-
+ //
+ // Make sure this driver is currently managing ControllerHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gUnixBlockIoDriverBinding.DriverBindingHandle,
+ &gEfiUnixIoProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
//
// Get our context back
//
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c index 81dd20661b..1425531cf8 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c @@ -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;
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c index abfb328f60..1bbe1cc49b 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c @@ -160,7 +160,17 @@ UnixConsoleComponentNameGetControllerName ( if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
-
+ //
+ // Make sure this driver is currently managing ControllerHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gUnixConsoleDriverBinding.DriverBindingHandle,
+ &gEfiUnixIoProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
//
// Get out context back
//
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c index 79558a88d9..2d99d77b8a 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c @@ -50,7 +50,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixConsoleDriverBinding = { UnixConsoleDriverBindingSupported,
UnixConsoleDriverBindingStart,
UnixConsoleDriverBindingStop,
- 0x10,
+ 0xa,
NULL,
NULL
};
@@ -205,11 +205,11 @@ Done: FreeUnicodeStringTable (Private->ControllerNameTable);
-#if 0 +#if 0
if (Private->NtOutHandle != NULL) {
Private->UnixThunk->CloseHandle (Private->NtOutHandle);
}
-#endif +#endif
if (Private->SimpleTextIn.WaitForKey != NULL) {
gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
@@ -294,9 +294,9 @@ Returns: Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
ASSERT_EFI_ERROR (Status);
-#if 0 +#if 0
Private->UnixThunk->CloseHandle (Private->NtOutHandle);
-#endif +#endif
//
// DO NOT close Private->NtInHandle. It points to StdIn and not
// the Private->NtOutHandle is StdIn and should not be closed!
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c index b4bbb328f4..347326dcb8 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c @@ -168,6 +168,17 @@ UnixSimpleFileSystemComponentNameGetControllerName ( }
//
+ // Make sure this driver is currently managing ControllerHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gUnixSimpleFileSystemDriverBinding.DriverBindingHandle,
+ &gEfiUnixIoProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ //
// Get our context back
//
Status = gBS->OpenProtocol (
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c index 42a361b53d..db272bdc89 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c @@ -30,7 +30,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixSimpleFileSystemDriverBinding = { UnixSimpleFileSystemDriverBindingSupported,
UnixSimpleFileSystemDriverBindingStart,
UnixSimpleFileSystemDriverBindingStop,
- 0x10,
+ 0xa,
NULL,
NULL
};
@@ -257,7 +257,7 @@ Returns: EFI_STATUS Status;
EFI_UNIX_IO_PROTOCOL *UnixIo;
UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
- INTN i; + INTN i;
Private = NULL;
@@ -295,8 +295,8 @@ Returns: Private->Signature = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;
Private->UnixThunk = UnixIo->UnixThunk;
- Private->FilePath = NULL; - Private->VolumeLabel = NULL; + Private->FilePath = NULL;
+ Private->VolumeLabel = NULL;
Status = gBS->AllocatePool (
EfiBootServicesData,
@@ -307,10 +307,10 @@ Returns: if (EFI_ERROR (Status)) {
goto Done;
}
- - for (i = 0; UnixIo->EnvString[i] != 0; i++) +
+ for (i = 0; UnixIo->EnvString[i] != 0; i++)
Private->FilePath[i] = UnixIo->EnvString[i];
- Private->FilePath[i] = 0; + Private->FilePath[i] = 0;
Private->VolumeLabel = NULL;
Status = gBS->AllocatePool (
@@ -349,10 +349,10 @@ Done: if (Private != NULL) {
- if (Private->VolumeLabel != NULL) - gBS->FreePool (Private->VolumeLabel); - if (Private->FilePath != NULL) - gBS->FreePool (Private->FilePath); + if (Private->VolumeLabel != NULL)
+ gBS->FreePool (Private->VolumeLabel);
+ if (Private->FilePath != NULL)
+ gBS->FreePool (Private->FilePath);
FreeUnicodeStringTable (Private->ControllerNameTable);
gBS->FreePool (Private);
@@ -540,20 +540,20 @@ Returns: PrivateFile->EfiFile.GetInfo = UnixSimpleFileSystemGetInfo;
PrivateFile->EfiFile.SetInfo = UnixSimpleFileSystemSetInfo;
PrivateFile->EfiFile.Flush = UnixSimpleFileSystemFlush;
- PrivateFile->fd = -1; - PrivateFile->Dir = NULL; - PrivateFile->Dirent = NULL; + PrivateFile->fd = -1;
+ PrivateFile->Dir = NULL;
+ PrivateFile->Dirent = NULL;
*Root = &PrivateFile->EfiFile;
- PrivateFile->Dir = PrivateFile->UnixThunk->OpenDir(PrivateFile->FileName); + PrivateFile->Dir = PrivateFile->UnixThunk->OpenDir(PrivateFile->FileName);
- if (PrivateFile->Dir == NULL) { + if (PrivateFile->Dir == NULL) {
Status = EFI_ACCESS_DENIED;
- } - else { + }
+ else {
Status = EFI_SUCCESS;
- } + }
Done:
if (EFI_ERROR (Status)) {
@@ -629,8 +629,8 @@ Returns: UNIX_EFI_FILE_PRIVATE *NewPrivateFile;
UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
EFI_STATUS Status;
- CHAR16 *Src; - char *Dst; + CHAR16 *Src;
+ char *Dst;
CHAR8 *RealFileName;
//CHAR16 *TempFileName;
char *ParseFileName;
@@ -683,7 +683,7 @@ Returns: // BUGBUG: assume an open of root
// if current location, return current data
//
- if (StrCmp (FileName, L"\\") == 0 + if (StrCmp (FileName, L"\\") == 0
|| (StrCmp (FileName, L".") == 0 && PrivateFile->IsRootDirectory)) {
//
// BUGBUG: assume an open root
@@ -727,25 +727,25 @@ OpenRoot: if (*FileName == L'\\') {
AsciiStrCpy (NewPrivateFile->FileName, PrivateRoot->FilePath);
- // Skip first '\'. - Src = FileName + 1; + // Skip first '\'.
+ Src = FileName + 1;
} else {
AsciiStrCpy (NewPrivateFile->FileName, PrivateFile->FileName);
- Src = FileName; - }
- Dst = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName); - GuardPointer = NewPrivateFile->FileName + AsciiStrLen(PrivateRoot->FilePath); - *Dst++ = '/'; - // Convert unicode to ascii and '\' to '/' - while (*Src) { - if (*Src == '\\') - *Dst++ = '/'; - else - *Dst++ = *Src; - Src++; - } - *Dst = 0; - + Src = FileName;
+ }
+ Dst = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName);
+ GuardPointer = NewPrivateFile->FileName + AsciiStrLen(PrivateRoot->FilePath);
+ *Dst++ = '/';
+ // Convert unicode to ascii and '\' to '/'
+ while (*Src) {
+ if (*Src == '\\')
+ *Dst++ = '/';
+ else
+ *Dst++ = *Src;
+ Src++;
+ }
+ *Dst = 0;
+
//
// Get rid of . and .., except leading . or ..
@@ -810,22 +810,22 @@ OpenRoot: }
RealFileName = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName) - 1;
- while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/') - RealFileName--; + while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/')
+ RealFileName--;
TempChar = *(RealFileName - 1);
*(RealFileName - 1) = 0;
*(RealFileName - 1) = TempChar;
- - +
+
//
// Test whether file or directory
//
NewPrivateFile->IsRootDirectory = FALSE;
- NewPrivateFile->fd = -1; - NewPrivateFile->Dir = NULL; + NewPrivateFile->fd = -1;
+ NewPrivateFile->Dir = NULL;
if (OpenMode & EFI_FILE_MODE_CREATE) {
if (Attributes & EFI_FILE_DIRECTORY) {
NewPrivateFile->IsDirectoryPath = TRUE;
@@ -833,11 +833,11 @@ OpenRoot: NewPrivateFile->IsDirectoryPath = FALSE;
}
} else {
- struct stat finfo; - int res = NewPrivateFile->UnixThunk->Stat (NewPrivateFile->FileName, &finfo); - if (res == 0 && S_ISDIR(finfo.st_mode)) + struct stat finfo;
+ int res = NewPrivateFile->UnixThunk->Stat (NewPrivateFile->FileName, &finfo);
+ if (res == 0 && S_ISDIR(finfo.st_mode))
NewPrivateFile->IsDirectoryPath = TRUE;
- else + else
NewPrivateFile->IsDirectoryPath = FALSE;
}
@@ -859,10 +859,10 @@ OpenRoot: // Create a directory
//
if (NewPrivateFile->UnixThunk->MkDir (NewPrivateFile->FileName, 0777) != 0) {
- INTN LastError; + INTN LastError;
LastError = PrivateFile->UnixThunk->GetErrno ();
- if (LastError != EEXIST) { + if (LastError != EEXIST) {
//gBS->FreePool (TempFileName);
Status = EFI_ACCESS_DENIED;
goto Done;
@@ -870,11 +870,11 @@ OpenRoot: }
}
- NewPrivateFile->Dir = NewPrivateFile->UnixThunk->OpenDir - (NewPrivateFile->FileName); + NewPrivateFile->Dir = NewPrivateFile->UnixThunk->OpenDir
+ (NewPrivateFile->FileName);
- if (NewPrivateFile->Dir == NULL) { - if (PrivateFile->UnixThunk->GetErrno () == EACCES) { + if (NewPrivateFile->Dir == NULL) {
+ if (PrivateFile->UnixThunk->GetErrno () == EACCES) {
Status = EFI_ACCESS_DENIED;
} else {
Status = EFI_NOT_FOUND;
@@ -887,13 +887,13 @@ OpenRoot: //
// deal with file
//
- NewPrivateFile->fd = NewPrivateFile->UnixThunk->Open + NewPrivateFile->fd = NewPrivateFile->UnixThunk->Open
(NewPrivateFile->FileName,
- ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0) - | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR), - 0666); - if (NewPrivateFile->fd < 0) { - if (PrivateFile->UnixThunk->GetErrno () == ENOENT) { + ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0)
+ | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR),
+ 0666);
+ if (NewPrivateFile->fd < 0) {
+ if (PrivateFile->UnixThunk->GetErrno () == ENOENT) {
Status = EFI_NOT_FOUND;
} else {
Status = EFI_ACCESS_DENIED;
@@ -987,15 +987,15 @@ Returns: PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
- if (PrivateFile->fd >= 0) { + if (PrivateFile->fd >= 0) {
PrivateFile->UnixThunk->Close (PrivateFile->fd);
- } - if (PrivateFile->Dir != NULL) { + }
+ if (PrivateFile->Dir != NULL) {
PrivateFile->UnixThunk->CloseDir (PrivateFile->Dir);
- } + }
- PrivateFile->fd = -1; - PrivateFile->Dir = NULL; + PrivateFile->fd = -1;
+ PrivateFile->Dir = NULL;
if (PrivateFile->FileName) {
gBS->FreePool (PrivateFile->FileName);
@@ -1043,7 +1043,7 @@ Returns: if (PrivateFile->IsDirectoryPath) {
if (PrivateFile->Dir != NULL) {
PrivateFile->UnixThunk->CloseDir (PrivateFile->Dir);
- PrivateFile->Dir = NULL; + PrivateFile->Dir = NULL;
}
if (PrivateFile->UnixThunk->RmDir (PrivateFile->FileName) == 0) {
@@ -1051,7 +1051,7 @@ Returns: }
} else {
PrivateFile->UnixThunk->Close (PrivateFile->fd);
- PrivateFile->fd = -1; + PrivateFile->fd = -1;
if (!PrivateFile->IsOpenedByRead) {
if (!PrivateFile->UnixThunk->UnLink (PrivateFile->FileName)) {
@@ -1070,7 +1070,7 @@ STATIC VOID
UnixSystemTimeToEfiTime (
EFI_UNIX_THUNK_PROTOCOL *UnixThunk,
- IN time_t SystemTime, + IN time_t SystemTime,
OUT EFI_TIME *Time
)
/*++
@@ -1091,19 +1091,19 @@ Returns: --*/
{
- struct tm *tm; - tm = UnixThunk->GmTime (&SystemTime); - Time->Year = tm->tm_year; - Time->Month = tm->tm_mon; - Time->Day = tm->tm_mday; - Time->Hour = tm->tm_hour; - Time->Minute = tm->tm_min; - Time->Second = tm->tm_sec; - Time->Nanosecond = 0; - - Time->TimeZone = UnixThunk->GetTimeZone (); -
- if (UnixThunk->GetDayLight ()) { + struct tm *tm;
+ tm = UnixThunk->GmTime (&SystemTime);
+ Time->Year = tm->tm_year;
+ Time->Month = tm->tm_mon;
+ Time->Day = tm->tm_mday;
+ Time->Hour = tm->tm_hour;
+ Time->Minute = tm->tm_min;
+ Time->Second = tm->tm_sec;
+ Time->Nanosecond = 0;
+
+ Time->TimeZone = UnixThunk->GetTimeZone ();
+
+ if (UnixThunk->GetDayLight ()) {
Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT;
}
}
@@ -1112,7 +1112,7 @@ STATIC EFI_STATUS
UnixSimpleFileSystemFileInfo (
UNIX_EFI_FILE_PRIVATE *PrivateFile,
- IN CHAR8 *FileName, + IN CHAR8 *FileName,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
@@ -1141,18 +1141,18 @@ Returns: EFI_FILE_INFO *Info;
CHAR8 *RealFileName;
CHAR8 *TempPointer;
- CHAR16 *BufferFileName; - struct stat buf; + CHAR16 *BufferFileName;
+ struct stat buf;
- if (FileName != NULL) { - RealFileName = FileName; - } + if (FileName != NULL) {
+ RealFileName = FileName;
+ }
else if (PrivateFile->IsRootDirectory) {
- RealFileName = ""; + RealFileName = "";
} else {
RealFileName = PrivateFile->FileName;
- } - + }
+
TempPointer = RealFileName;
while (*TempPointer) {
if (*TempPointer == '/') {
@@ -1161,7 +1161,7 @@ Returns: TempPointer++;
}
- +
Size = SIZE_OF_EFI_FILE_INFO;
NameSize = AsciiStrSize (RealFileName) * 2;
ResultSize = Size + NameSize;
@@ -1169,39 +1169,39 @@ Returns: if (*BufferSize < ResultSize) {
*BufferSize = ResultSize;
return EFI_BUFFER_TOO_SMALL;
- } - if (PrivateFile->UnixThunk->Stat ( - FileName == NULL ? PrivateFile->FileName : FileName, - &buf) < 0) - return EFI_DEVICE_ERROR; - + }
+ if (PrivateFile->UnixThunk->Stat (
+ FileName == NULL ? PrivateFile->FileName : FileName,
+ &buf) < 0)
+ return EFI_DEVICE_ERROR;
+
Status = EFI_SUCCESS;
Info = Buffer;
ZeroMem (Info, ResultSize);
Info->Size = ResultSize;
- Info->FileSize = buf.st_size; - Info->PhysicalSize = MultU64x32 (buf.st_blocks, buf.st_blksize); -
- UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_ctime, &Info->CreateTime); - UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_atime, &Info->LastAccessTime); - UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_mtime, &Info->ModificationTime); - - if (!(buf.st_mode & S_IWUSR)) { + Info->FileSize = buf.st_size;
+ Info->PhysicalSize = MultU64x32 (buf.st_blocks, buf.st_blksize);
+
+ UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_ctime, &Info->CreateTime);
+ UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_atime, &Info->LastAccessTime);
+ UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_mtime, &Info->ModificationTime);
+
+ if (!(buf.st_mode & S_IWUSR)) {
Info->Attribute |= EFI_FILE_READ_ONLY;
}
- if (S_ISDIR(buf.st_mode)) { + if (S_ISDIR(buf.st_mode)) {
Info->Attribute |= EFI_FILE_DIRECTORY;
}
- BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size); - while (*RealFileName) - *BufferFileName++ = *RealFileName++; - *BufferFileName = 0; - + BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size);
+ while (*RealFileName)
+ *BufferFileName++ = *RealFileName++;
+ *BufferFileName = 0;
+
*BufferSize = ResultSize;
return Status;
}
@@ -1245,11 +1245,11 @@ Returns: {
UNIX_EFI_FILE_PRIVATE *PrivateFile;
EFI_STATUS Status;
- INTN Res; + INTN Res;
UINTN Size;
UINTN NameSize;
UINTN ResultSize;
- CHAR8 *FullFileName; + CHAR8 *FullFileName;
if (This == NULL || BufferSize == NULL || Buffer == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1266,62 +1266,62 @@ Returns: Res = PrivateFile->UnixThunk->Read (
PrivateFile->fd,
Buffer,
- *BufferSize); - if (Res < 0) - return EFI_DEVICE_ERROR; - *BufferSize = Res; - return EFI_SUCCESS; + *BufferSize);
+ if (Res < 0)
+ return EFI_DEVICE_ERROR;
+ *BufferSize = Res;
+ return EFI_SUCCESS;
}
//
- // Read on a directory. + // Read on a directory.
//
if (PrivateFile->Dir == NULL) {
return EFI_DEVICE_ERROR;
}
- - if (PrivateFile->Dirent == NULL) { - PrivateFile->Dirent = PrivateFile->UnixThunk->ReadDir (PrivateFile->Dir); - if (PrivateFile->Dirent == NULL) { +
+ if (PrivateFile->Dirent == NULL) {
+ PrivateFile->Dirent = PrivateFile->UnixThunk->ReadDir (PrivateFile->Dir);
+ if (PrivateFile->Dirent == NULL) {
*BufferSize = 0;
return EFI_SUCCESS;
- } - } - + }
+ }
+
Size = SIZE_OF_EFI_FILE_INFO;
- NameSize = AsciiStrLen (PrivateFile->Dirent->d_name) + 1; + NameSize = AsciiStrLen (PrivateFile->Dirent->d_name) + 1;
ResultSize = Size + 2 * NameSize;
if (*BufferSize < ResultSize) {
*BufferSize = ResultSize;
return EFI_BUFFER_TOO_SMALL;
- } + }
Status = EFI_SUCCESS;
*BufferSize = ResultSize;
- +
Status = gBS->AllocatePool (
EfiBootServicesData,
- AsciiStrLen(PrivateFile->FileName) + 1 + NameSize, - (VOID **)&FullFileName + AsciiStrLen(PrivateFile->FileName) + 1 + NameSize,
+ (VOID **)&FullFileName
);
if (EFI_ERROR (Status)) {
- return Status; + return Status;
}
- - AsciiStrCpy(FullFileName, PrivateFile->FileName); - AsciiStrCat(FullFileName, "/"); - AsciiStrCat(FullFileName, PrivateFile->Dirent->d_name); - Status = UnixSimpleFileSystemFileInfo (PrivateFile, - FullFileName, - BufferSize, - Buffer); - gBS->FreePool (FullFileName); +
+ AsciiStrCpy(FullFileName, PrivateFile->FileName);
+ AsciiStrCat(FullFileName, "/");
+ AsciiStrCat(FullFileName, PrivateFile->Dirent->d_name);
+ Status = UnixSimpleFileSystemFileInfo (PrivateFile,
+ FullFileName,
+ BufferSize,
+ Buffer);
+ gBS->FreePool (FullFileName);
- PrivateFile->Dirent = NULL; + PrivateFile->Dirent = NULL;
- return Status; + return Status;
}
EFI_STATUS
@@ -1368,7 +1368,7 @@ Returns: // TODO: EFI_INVALID_PARAMETER - add return value to function comment
{
UNIX_EFI_FILE_PRIVATE *PrivateFile;
- UINTN Res; + UINTN Res;
if (This == NULL || BufferSize == NULL || Buffer == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1391,11 +1391,11 @@ Returns: Res = PrivateFile->UnixThunk->Write (
PrivateFile->fd,
Buffer,
- *BufferSize); - if (Res == (UINTN)-1) - return EFI_DEVICE_ERROR; - *BufferSize = Res; - return EFI_SUCCESS; + *BufferSize);
+ if (Res == (UINTN)-1)
+ return EFI_DEVICE_ERROR;
+ *BufferSize = Res;
+ return EFI_SUCCESS;
//
// bugbug: need to access unix error reporting
@@ -1444,17 +1444,17 @@ Returns: return EFI_UNSUPPORTED;
}
- if (PrivateFile->Dir == NULL) { - return EFI_DEVICE_ERROR; - } - PrivateFile->UnixThunk->RewindDir (PrivateFile->Dir); + if (PrivateFile->Dir == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+ PrivateFile->UnixThunk->RewindDir (PrivateFile->Dir);
return EFI_SUCCESS;
} else {
if (Position == (UINT64) -1) {
Pos = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, 0, SEEK_END);
} else {
Pos = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, Position, SEEK_SET);
- } + }
Status = (Pos == (UINT64) -1) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
return Status;
@@ -1499,7 +1499,7 @@ Returns: if (PrivateFile->IsDirectoryPath) {
return EFI_UNSUPPORTED;
} else {
- *Position = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, 0, SEEK_CUR); + *Position = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, 0, SEEK_CUR);
return (*Position == (UINT64) -1) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
}
}
@@ -1552,7 +1552,7 @@ Returns: EFI_FILE_SYSTEM_INFO *FileSystemInfoBuffer;
INTN UnixStatus;
UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
- struct statfs buf; + struct statfs buf;
if (This == NULL || InformationType == NULL || BufferSize == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1572,10 +1572,10 @@ Returns: return EFI_BUFFER_TOO_SMALL;
}
- UnixStatus = PrivateFile->UnixThunk->StatFs (PrivateFile->FileName, &buf); - if (UnixStatus < 0) + UnixStatus = PrivateFile->UnixThunk->StatFs (PrivateFile->FileName, &buf);
+ if (UnixStatus < 0)
return EFI_DEVICE_ERROR;
- +
FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *) Buffer;
FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
FileSystemInfoBuffer->ReadOnly = FALSE;
@@ -1583,9 +1583,9 @@ Returns: //
// Succeeded
//
- FileSystemInfoBuffer->VolumeSize = MultU64x32 (buf.f_blocks, buf.f_bsize); - FileSystemInfoBuffer->FreeSpace = MultU64x32 (buf.f_bavail, buf.f_bsize); - FileSystemInfoBuffer->BlockSize = buf.f_bsize; + FileSystemInfoBuffer->VolumeSize = MultU64x32 (buf.f_blocks, buf.f_bsize);
+ FileSystemInfoBuffer->FreeSpace = MultU64x32 (buf.f_bavail, buf.f_bsize);
+ FileSystemInfoBuffer->BlockSize = buf.f_bsize;
StrCpy ((CHAR16 *) FileSystemInfoBuffer->VolumeLabel, PrivateRoot->VolumeLabel);
@@ -1593,7 +1593,7 @@ Returns: Status = EFI_SUCCESS;
}
- else if (CompareGuid (InformationType, + else if (CompareGuid (InformationType,
&gEfiFileSystemVolumeLabelInfoIdGuid)) {
if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
@@ -1674,9 +1674,9 @@ Returns: struct tm NewLastAccessSystemTime;
struct tm NewLastWriteSystemTime;
EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
- CHAR8 *AsciiFilePtr; - CHAR16 *UnicodeFilePtr; - INTN UnixStatus; + CHAR8 *AsciiFilePtr;
+ CHAR16 *UnicodeFilePtr;
+ INTN UnixStatus;
//
// Check for invalid parameters.
@@ -1779,7 +1779,7 @@ Returns: goto Done;
}
- Status = gBS->AllocatePool (EfiBootServicesData, OldInfoSize, + Status = gBS->AllocatePool (EfiBootServicesData, OldInfoSize,
(VOID **)&OldFileInfo);
if (EFI_ERROR (Status)) {
@@ -1819,9 +1819,9 @@ Returns: }
AsciiStrCpy (NewFileName, PrivateRoot->FilePath);
- AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName); - UnicodeFilePtr = NewFileInfo->FileName + 1; - *AsciiFilePtr++ ='/'; + AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+ UnicodeFilePtr = NewFileInfo->FileName + 1;
+ *AsciiFilePtr++ ='/';
} else {
Status = gBS->AllocatePool (
EfiBootServicesData,
@@ -1834,18 +1834,18 @@ Returns: }
AsciiStrCpy (NewFileName, PrivateRoot->FilePath);
- AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName); - while (AsciiFilePtr > NewFileName && AsciiFilePtr[-1] != '/') { - AsciiFilePtr--; - } - UnicodeFilePtr = NewFileInfo->FileName; + AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+ while (AsciiFilePtr > NewFileName && AsciiFilePtr[-1] != '/') {
+ AsciiFilePtr--;
+ }
+ UnicodeFilePtr = NewFileInfo->FileName;
+ }
+ // Convert to ascii.
+ while (*UnicodeFilePtr) {
+ *AsciiFilePtr++ = *UnicodeFilePtr++;
}
- // Convert to ascii. - while (*UnicodeFilePtr) { - *AsciiFilePtr++ = *UnicodeFilePtr++; - } - *AsciiFilePtr = 0; - + *AsciiFilePtr = 0;
+
//
// Is there an attribute change request?
@@ -1902,10 +1902,10 @@ Returns: //
// Set file or directory information.
//
- if (PrivateFile->UnixThunk->Stat (OldFileName, &OldAttr) != 0) { - Status = EFI_DEVICE_ERROR; - goto Done; - } + if (PrivateFile->UnixThunk->Stat (OldFileName, &OldAttr) != 0) {
+ Status = EFI_DEVICE_ERROR;
+ goto Done;
+ }
//
// Name change.
@@ -1977,7 +1977,7 @@ Returns: // Time change
//
if (TimeChangeFlag) {
- struct utimbuf utime; + struct utimbuf utime;
NewLastAccessSystemTime.tm_year = NewFileInfo->LastAccessTime.Year;
NewLastAccessSystemTime.tm_mon = NewFileInfo->LastAccessTime.Month;
@@ -1985,25 +1985,25 @@ Returns: NewLastAccessSystemTime.tm_hour = NewFileInfo->LastAccessTime.Hour;
NewLastAccessSystemTime.tm_min = NewFileInfo->LastAccessTime.Minute;
NewLastAccessSystemTime.tm_sec = NewFileInfo->LastAccessTime.Second;
- NewLastAccessSystemTime.tm_isdst = 0; + NewLastAccessSystemTime.tm_isdst = 0;
+
+ utime.actime = PrivateFile->UnixThunk->MkTime (&NewLastAccessSystemTime);
- utime.actime = PrivateFile->UnixThunk->MkTime (&NewLastAccessSystemTime); - NewLastWriteSystemTime.tm_year = NewFileInfo->ModificationTime.Year;
NewLastWriteSystemTime.tm_mon = NewFileInfo->ModificationTime.Month;
NewLastWriteSystemTime.tm_mday = NewFileInfo->ModificationTime.Day;
NewLastWriteSystemTime.tm_hour = NewFileInfo->ModificationTime.Hour;
NewLastWriteSystemTime.tm_min = NewFileInfo->ModificationTime.Minute;
NewLastWriteSystemTime.tm_sec = NewFileInfo->ModificationTime.Second;
- NewLastWriteSystemTime.tm_isdst = 0; + NewLastWriteSystemTime.tm_isdst = 0;
+
+ utime.modtime = PrivateFile->UnixThunk->MkTime (&NewLastWriteSystemTime);
- utime.modtime = PrivateFile->UnixThunk->MkTime (&NewLastWriteSystemTime); - - if (utime.actime == (time_t)-1 || utime.modtime == (time_t)-1) { + if (utime.actime == (time_t)-1 || utime.modtime == (time_t)-1) {
goto Done;
}
- if (PrivateFile->UnixThunk->UTime (PrivateFile->FileName, &utime) == -1) { + if (PrivateFile->UnixThunk->UTime (PrivateFile->FileName, &utime) == -1) {
goto Done;
}
}
@@ -2015,9 +2015,9 @@ Returns: NewAttr = OldAttr.st_mode;
if (NewFileInfo->Attribute & EFI_FILE_READ_ONLY) {
- NewAttr &= ~(S_IRUSR | S_IRGRP | S_IROTH); + NewAttr &= ~(S_IRUSR | S_IRGRP | S_IROTH);
} else {
- NewAttr |= S_IRUSR; + NewAttr |= S_IRUSR;
}
UnixStatus = PrivateFile->UnixThunk->Chmod (NewFileName, NewAttr);
@@ -2093,10 +2093,10 @@ Returns: return EFI_ACCESS_DENIED;
}
- if (PrivateFile->fd < 0) { + if (PrivateFile->fd < 0) {
return EFI_DEVICE_ERROR;
}
- +
return PrivateFile->UnixThunk->FSync (PrivateFile->fd) == 0 ? EFI_SUCCESS : EFI_DEVICE_ERROR;
//
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c index e6e5ebe3a5..5c50d5689c 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c @@ -162,6 +162,17 @@ UnixUgaComponentNameGetControllerName ( }
//
+ // Make sure this driver is currently managing ControllerHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gUnixUgaDriverBinding.DriverBindingHandle,
+ &gEfiUnixIoProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ //
// Get our context back
//
Status = gBS->OpenProtocol (
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c index 5e08fe838b..6073202bd7 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c @@ -31,7 +31,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding = { UnixUgaDriverBindingSupported,
UnixUgaDriverBindingStart,
UnixUgaDriverBindingStop,
- 0x10,
+ 0xa,
NULL,
NULL
};
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c index 2045f8fdd6..7ea1eacc1a 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c @@ -155,12 +155,33 @@ UnixBusDriverComponentNameGetControllerName ( UNIX_IO_DEVICE *Private;
//
+ // Make sure this driver is currently managing ControllHandle
+ //
+ Status = EfiTestManagedDevice (
+ ControllerHandle,
+ gUnixBusDriverBinding.DriverBindingHandle,
+ &gEfiUnixThunkProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
// This is a bus driver, so ChildHandle can not be NULL.
//
if (ChildHandle == NULL) {
return EFI_UNSUPPORTED;
}
+ Status = EfiTestChildHandle (
+ ControllerHandle,
+ ChildHandle,
+ &gEfiUnixThunkProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
//
// Get our context back
//
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c index 0e93e48f5c..efa66abeeb 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c @@ -107,7 +107,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixBusDriverBinding = { UnixBusDriverBindingSupported,
UnixBusDriverBindingStart,
UnixBusDriverBindingStop,
- 0x10,
+ 0xa,
NULL,
NULL
};
@@ -454,7 +454,7 @@ Returns: UnixDevice->ControllerNameTable = NULL;
- // FIXME: check size + // FIXME: check size
StrCpy(ComponentName, UnixDevice->UnixIo.EnvString);
UnixDevice->DevicePath = UnixBusCreateDevicePath (
|