/*++\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
Module Name:\r
\r
Abstract:\r
\r
Produce Simple File System abstractions for directories on your PC using Win32 APIs.\r
- The configuration of what devices to mount or emulate comes from NT \r
- environment variables. The variables must be visible to the Microsoft* \r
+ The configuration of what devices to mount or emulate comes from NT\r
+ environment variables. The variables must be visible to the Microsoft*\r
Developer Studio for them to work.\r
\r
* Other names and brands may be claimed as the property of others.\r
for (Pointer = Str; *(Pointer + Count); Pointer++) {\r
*Pointer = *(Pointer + Count);\r
}\r
- *Pointer = *(Pointer + Count); \r
+ *Pointer = *(Pointer + Count);\r
}\r
}\r
\r
goto Done;\r
}\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- sizeof (WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE),\r
- &Private\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ Private = AllocatePool (sizeof (WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE));\r
+ if (Private == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+\r
goto Done;\r
}\r
\r
\r
Private->FilePath = WinNtIo->EnvString;\r
\r
- Private->VolumeLabel = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (L"EFI_EMULATED"),\r
- &Private->VolumeLabel\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ Private->VolumeLabel = AllocatePool (StrSize (L"EFI_EMULATED"));\r
+ if (Private->VolumeLabel == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
\r
FreeUnicodeStringTable (Private->ControllerNameTable);\r
\r
- gBS->FreePool (Private);\r
+ FreePool (Private);\r
}\r
\r
gBS->CloseProtocol (\r
//\r
FreeUnicodeStringTable (Private->ControllerNameTable);\r
\r
- gBS->FreePool (Private);\r
+ FreePool (Private);\r
}\r
\r
return Status;\r
\r
Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);\r
\r
- PrivateFile = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- sizeof (WIN_NT_EFI_FILE_PRIVATE),\r
- &PrivateFile\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ PrivateFile = AllocatePool (sizeof (WIN_NT_EFI_FILE_PRIVATE));\r
+ if (PrivateFile == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
- PrivateFile->FileName = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (Private->FilePath),\r
- &PrivateFile->FileName\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ PrivateFile->FileName = AllocatePool (StrSize (Private->FilePath));\r
+ if (PrivateFile->FileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
- PrivateFile->FilePath = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (Private->FilePath),\r
- &PrivateFile->FilePath\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ PrivateFile->FilePath = AllocatePool (StrSize (Private->FilePath));\r
+ if (PrivateFile->FilePath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
PrivateFile->LHandle = INVALID_HANDLE_VALUE;\r
PrivateFile->DirHandle = INVALID_HANDLE_VALUE;\r
PrivateFile->IsValidFindBuf = FALSE;\r
- \r
+\r
*Root = &PrivateFile->EfiFile;\r
\r
Status = EFI_SUCCESS;\r
if (EFI_ERROR (Status)) {\r
if (PrivateFile) {\r
if (PrivateFile->FileName) {\r
- gBS->FreePool (PrivateFile->FileName);\r
+ FreePool (PrivateFile->FileName);\r
}\r
\r
if (PrivateFile->FilePath) {\r
- gBS->FreePool (PrivateFile->FilePath);\r
+ FreePool (PrivateFile->FilePath);\r
}\r
\r
- gBS->FreePool (PrivateFile);\r
+ FreePool (PrivateFile);\r
}\r
}\r
\r
//\r
// Allocate buffer for FileName as the passed in FileName may be read only\r
//\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (FileName),\r
- &TempFileName\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
+ TempFileName = AllocatePool (StrSize (FileName));\r
+ if (TempFileName == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
StrCpy (TempFileName, FileName);\r
FileName = TempFileName;\r
}\r
\r
//\r
- // If file name does not equal to "." or "..", \r
+ // If file name does not equal to "." or "..",\r
// then we trim the leading/trailing blanks and trailing dots\r
//\r
if (StrCmp (FileName, L".") != 0 && StrCmp (FileName, L"..") != 0) {\r
//\r
// Trim trailing dots and blanks\r
//\r
- for (TempFileName = FileName + StrLen (FileName) - 1; \r
+ for (TempFileName = FileName + StrLen (FileName) - 1;\r
TempFileName >= FileName && (*TempFileName == L' ' || *TempFileName == L'.');\r
TempFileName--) {\r
;\r
//\r
// Attempt to open the file\r
//\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- sizeof (WIN_NT_EFI_FILE_PRIVATE),\r
- &NewPrivateFile\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ NewPrivateFile = AllocatePool (sizeof (WIN_NT_EFI_FILE_PRIVATE));\r
+ if (NewPrivateFile == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
CopyMem (NewPrivateFile, PrivateFile, sizeof (WIN_NT_EFI_FILE_PRIVATE));\r
\r
- NewPrivateFile->FilePath = NULL;\r
-\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (PrivateFile->FileName),\r
- &NewPrivateFile->FilePath\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ NewPrivateFile->FilePath = AllocatePool (StrSize (PrivateFile->FileName));\r
+ if (NewPrivateFile->FilePath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
StrCpy (NewPrivateFile->FilePath, PrivateFile->FilePath);\r
}\r
\r
- NewPrivateFile->FileName = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (NewPrivateFile->FilePath) + StrSize (L"\\") + StrSize (FileName),\r
- &NewPrivateFile->FileName\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ NewPrivateFile->FileName = AllocatePool (StrSize (NewPrivateFile->FilePath) + StrSize (L"\\") + StrSize (FileName));\r
+ if (NewPrivateFile->FileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
if (StrCmp (FileName, L"") != 0) {\r
//\r
// In case the filename becomes empty, especially after trimming dots and blanks\r
- // \r
+ //\r
StrCat (NewPrivateFile->FileName, L"\\");\r
StrCat (NewPrivateFile->FileName, FileName);\r
}\r
\r
if (StrCmp (NewPrivateFile->FileName, PrivateRoot->FilePath) == 0) {\r
NewPrivateFile->IsRootDirectory = TRUE;\r
- gBS->FreePool (NewPrivateFile->FilePath);\r
- gBS->FreePool (NewPrivateFile->FileName);\r
- gBS->FreePool (NewPrivateFile);\r
+ FreePool (NewPrivateFile->FilePath);\r
+ FreePool (NewPrivateFile->FileName);\r
+ FreePool (NewPrivateFile);\r
goto OpenRoot;\r
}\r
\r
TempChar = *(RealFileName - 1);\r
*(RealFileName - 1) = 0;\r
\r
- gBS->FreePool (NewPrivateFile->FilePath);\r
+ FreePool (NewPrivateFile->FilePath);\r
NewPrivateFile->FilePath = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (NewPrivateFile->FileName),\r
- &NewPrivateFile->FilePath\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ NewPrivateFile->FilePath = AllocatePool (StrSize (NewPrivateFile->FileName));\r
+ if (NewPrivateFile->FilePath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
//\r
if (NewPrivateFile->IsDirectoryPath) {\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (NewPrivateFile->FileName) + StrSize (L"\\*"),\r
- &TempFileName\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ TempFileName = AllocatePool (StrSize (NewPrivateFile->FileName) + StrSize (L"\\*"));\r
+ if (TempFileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
\r
LastError = PrivateFile->WinNtThunk->GetLastError ();\r
if (LastError != ERROR_ALREADY_EXISTS) {\r
- gBS->FreePool (TempFileName);\r
+ FreePool (TempFileName);\r
Status = EFI_ACCESS_DENIED;\r
goto Done;\r
}\r
goto Done;\r
}\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- InfoSize,\r
- &Info\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ Info = AllocatePool (InfoSize);\r
+ if (Info == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
}\r
\r
Done: ;\r
- gBS->FreePool (FileName);\r
+ FreePool (FileName);\r
\r
if (EFI_ERROR (Status)) {\r
if (NewPrivateFile) {\r
if (NewPrivateFile->FileName) {\r
- gBS->FreePool (NewPrivateFile->FileName);\r
+ FreePool (NewPrivateFile->FileName);\r
}\r
\r
if (NewPrivateFile->FilePath) {\r
- gBS->FreePool (NewPrivateFile->FilePath);\r
+ FreePool (NewPrivateFile->FilePath);\r
}\r
\r
- gBS->FreePool (NewPrivateFile);\r
+ FreePool (NewPrivateFile);\r
}\r
} else {\r
*NewHandle = &NewPrivateFile->EfiFile;\r
}\r
\r
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);\r
- \r
+\r
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
\r
if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) {\r
}\r
\r
if (PrivateFile->FileName) {\r
- gBS->FreePool (PrivateFile->FileName);\r
+ FreePool (PrivateFile->FileName);\r
}\r
\r
- gBS->FreePool (PrivateFile);\r
+ FreePool (PrivateFile);\r
\r
gBS->RestoreTPL (OldTpl);\r
- \r
+\r
return EFI_SUCCESS;\r
}\r
\r
}\r
\r
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);\r
- \r
+\r
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
\r
Status = EFI_WARN_DELETE_FAILURE;\r
}\r
}\r
\r
- gBS->FreePool (PrivateFile->FileName);\r
- gBS->FreePool (PrivateFile);\r
+ FreePool (PrivateFile->FileName);\r
+ FreePool (PrivateFile);\r
\r
gBS->RestoreTPL (OldTpl);\r
\r
}\r
\r
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);\r
- \r
+\r
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
\r
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {\r
}\r
\r
FileInfoSize = SIZE_OF_EFI_FILE_SYSTEM_INFO;\r
- gBS->AllocatePool (\r
- EfiBootServicesData,\r
- FileInfoSize,\r
- &FileInfo\r
- );\r
+ FileInfo = AllocatePool (FileInfoSize);\r
\r
Status = This->GetInfo (\r
This,\r
);\r
\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
- gBS->FreePool (FileInfo);\r
- gBS->AllocatePool (\r
- EfiBootServicesData,\r
- FileInfoSize,\r
- &FileInfo\r
- );\r
+ FreePool (FileInfo);\r
+ FileInfo = AllocatePool (FileInfoSize);\r
Status = This->GetInfo (\r
This,\r
&gEfiFileInfoGuid,\r
\r
FileSize = FileInfo->FileSize;\r
\r
- gBS->FreePool (FileInfo);\r
+ FreePool (FileInfo);\r
\r
if (Pos >= FileSize) {\r
*BufferSize = 0;\r
}\r
\r
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);\r
- \r
+\r
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
\r
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {\r
}\r
\r
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);\r
- \r
+\r
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
\r
if (PrivateFile->IsDirectoryPath) {\r
goto Done;\r
}\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (PrivateFile->FileName) + StrSize (L"\\*"),\r
- &FileName\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ FileName = AllocatePool (StrSize (PrivateFile->FileName) + StrSize (L"\\*"));\r
+ if (FileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
PrivateFile->IsValidFindBuf = TRUE;\r
}\r
\r
- gBS->FreePool (FileName);\r
+ FreePool (FileName);\r
\r
Status = (PrivateFile->LHandle == INVALID_HANDLE_VALUE) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
} else {\r
//\r
// Try to get the drive name\r
//\r
- DriveName = NULL;\r
DriveNameFound = FALSE;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (PrivateFile->FilePath) + 1,\r
- &DriveName\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ DriveName = AllocatePool (StrSize (PrivateFile->FilePath) + 1);\r
+ if (DriveName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
&TotalClusters\r
);\r
if (DriveName) {\r
- gBS->FreePool (DriveName);\r
+ FreePool (DriveName);\r
}\r
\r
if (NtStatus) {\r
\r
NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;\r
\r
- gBS->FreePool (PrivateRoot->VolumeLabel);\r
-\r
- PrivateRoot->VolumeLabel = NULL;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (NewFileSystemInfo->VolumeLabel),\r
- &PrivateRoot->VolumeLabel\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ FreePool (PrivateRoot->VolumeLabel);\r
+ PrivateRoot->VolumeLabel = AllocatePool (StrSize (NewFileSystemInfo->VolumeLabel));\r
+ if (PrivateRoot->VolumeLabel == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
goto Done;\r
}\r
\r
- Status = gBS->AllocatePool (EfiBootServicesData, OldInfoSize, &OldFileInfo);\r
-\r
- if (EFI_ERROR (Status)) {\r
+ OldFileInfo = AllocatePool (OldInfoSize);\r
+ if (OldFileInfo == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
goto Done;\r
}\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (PrivateFile->FileName),\r
- &OldFileName\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ OldFileName = AllocatePool (StrSize (PrivateFile->FileName));\r
+ if (OldFileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
// Make full pathname from new filename and rootpath.\r
//\r
if (NewFileInfo->FileName[0] == '\\') {\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (PrivateRoot->FilePath) + StrSize (L"\\") + StrSize (NewFileInfo->FileName),\r
- &NewFileName\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ NewFileName = AllocatePool (StrSize (PrivateRoot->FilePath) + StrSize (L"\\") + StrSize (NewFileInfo->FileName));\r
+ if (NewFileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
StrCat (NewFileName, L"\\");\r
StrCat (NewFileName, NewFileInfo->FileName + 1);\r
} else {\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (PrivateFile->FilePath) + StrSize (L"\\") + StrSize (NewFileInfo->FileName),\r
- &NewFileName\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
+ NewFileName = AllocatePool (StrSize (PrivateFile->FilePath) + StrSize (L"\\") + StrSize (NewFileInfo->FileName));\r
+ if (NewFileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
//\r
// modify file name\r
//\r
- gBS->FreePool (PrivateFile->FileName);\r
-\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (NewFileName),\r
- &PrivateFile->FileName\r
- );\r
+ FreePool (PrivateFile->FileName);\r
\r
- if (EFI_ERROR (Status)) {\r
+ PrivateFile->FileName = AllocatePool (StrSize (NewFileName));\r
+ if (PrivateFile->FileName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
\r
StrCpy (PrivateFile->FileName, NewFileName);\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (NewFileName) + StrSize (L"\\*"),\r
- &TempFileName\r
- );\r
+ TempFileName = AllocatePool (StrSize (NewFileName) + StrSize (L"\\*"));\r
\r
StrCpy (TempFileName, NewFileName);\r
\r
if (!PrivateFile->IsDirectoryPath) {\r
- PrivateFile->LHandle = PrivateFile->WinNtThunk->CreateFile (\r
+ PrivateFile->LHandle = PrivateFile->WinNtThunk->CreateFile (\r
TempFileName,\r
PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,\r
FILE_SHARE_READ | FILE_SHARE_WRITE,\r
NULL\r
);\r
\r
- gBS->FreePool (TempFileName);\r
+ FreePool (TempFileName);\r
\r
//\r
// Flush buffers just in case\r
StrCat (TempFileName, L"\\*");\r
PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (TempFileName, &FindBuf);\r
\r
- gBS->FreePool (TempFileName);\r
+ FreePool (TempFileName);\r
}\r
} else {\r
Reopen: ;\r
goto Done;\r
}\r
\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- StrSize (OldFileName) + StrSize (L"\\*"),\r
- &TempFileName\r
- );\r
+ TempFileName = AllocatePool (StrSize (OldFileName) + StrSize (L"\\*"));\r
\r
StrCpy (TempFileName, OldFileName);\r
\r
PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (TempFileName, &FindBuf);\r
}\r
\r
- gBS->FreePool (TempFileName);\r
+ FreePool (TempFileName);\r
\r
goto Done;\r
\r
\r
Done:\r
if (OldFileInfo != NULL) {\r
- gBS->FreePool (OldFileInfo);\r
+ FreePool (OldFileInfo);\r
}\r
\r
if (OldFileName != NULL) {\r
- gBS->FreePool (OldFileName);\r
+ FreePool (OldFileName);\r
}\r
\r
if (NewFileName != NULL) {\r
- gBS->FreePool (NewFileName);\r
+ FreePool (NewFileName);\r
}\r
\r
gBS->RestoreTPL (OldTpl);\r
}\r
\r
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);\r
- \r
+\r
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
\r
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {\r