/** @file
File System Access for NvVarsFileLib
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "NvVarsFileLib.h"
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
/**
Open the NvVars file for reading or writing
@param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
@param[in] ReadingFile - TRUE: open the file for reading. FALSE: writing
@param[out] NvVarsFile - If EFI_SUCCESS is returned, then this is updated
with the opened NvVars file.
@return EFI_SUCCESS if the file was opened
**/
)
{
//
// Get the FileSystem protocol on that handle
//
);
return Status;
}
//
// Get the volume (the root directory)
//
return Status;
}
//
// Attempt to open the NvVars file in the root directory
//
Root,
L"NvVars",
(
),
0
);
return Status;
}
return Status;
}
/**
Open the NvVars file for reading or writing
@param[in] File - The file to inspect
@param[out] Exists - Returns whether the file exists
@param[out] Size - Returns the size of the file
(0 if the file does not exist)
**/
)
{
*Size = 0;
return;
}
return;
}
}
/**
Open the NvVars file for reading or writing
@param[in] File - The file to inspect
@param[out] Exists - Returns whether the file exists
@param[out] Size - Returns the size of the file
(0 if the file does not exist)
**/
)
{
//
// Retrieve the FileInfo structure
//
return EFI_INVALID_PARAMETER;
}
//
// If the path is a directory, then return an error
//
return EFI_INVALID_PARAMETER;
}
//
// If the file size is already 0, then it is empty, so
// we can return success.
//
return EFI_SUCCESS;
}
//
// Set the file size to 0.
//
return Status;
}
/**
Reads a file to a newly allocated buffer
@param[in] File - The file to read
@param[in] ReadSize - The size of data to read from the file
@return Pointer to buffer allocated to hold the file
contents. NULL if an error occured.
**/
VOID*
)
{
if (FileContents != NULL) {
Status = FileHandleRead (
&ReadSize,
);
return NULL;
}
}
return FileContents;
}
/**
Reads the contents of the NvVars file on the file system
@param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
@return EFI_STATUS based on the success or failure of the file read
**/
)
{
return Status;
}
if (FileSize == 0) {
return EFI_UNSUPPORTED;
}
if (FileContents == NULL) {
return EFI_UNSUPPORTED;
}
DEBUG ((
"FsAccess.c: Read %d bytes from NV Variables file\n",
));
);
if (!RETURN_ERROR (Status)) {
}
return Status;
}
/**
Loads the non-volatile variables from the NvVars file on the
given file system.
@param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
@return EFI_STATUS based on the success or failure of load operation
**/
)
{
//
// We write a variable to indicate we've already loaded the
// variable data. If it is found, we skip the loading.
//
// This is relevent if the non-volatile variable have been
// able to survive a reboot operation. In that case, we don't
// want to re-load the file as it would overwrite newer changes
// made to the variables.
//
L"NvVars",
NULL,
&Size,
);
if (Status == EFI_SUCCESS) {
return EFI_ALREADY_STARTED;
}
//
// Attempt to restore the variables from the NvVars file.
//
return Status;
}
//
// Write a variable to indicate we've already loaded the
// variable data. If it is found, we skip the loading on
// subsequent attempts.
//
gRT->SetVariable (
L"NvVars",
Size,
);
DEBUG ((
"FsAccess.c: Read NV Variables file (size=%d)\n",
));
return Status;
}
)
{
//
// Only save non-volatile variables
//
if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
return RETURN_SUCCESS;
}
return SerializeVariablesAddVariable (
);
}
/**
Saves the non-volatile variables into the NvVars file on the
given file system.
@param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
@return EFI_STATUS based on the success or failure of load operation
**/
)
{
return Status;
}
);
return Status;
}
VariableData = NULL;
VariableDataSize = 0;
NULL,
);
if (Status == RETURN_BUFFER_TOO_SMALL) {
if (VariableData == NULL) {
} else {
);
}
}
return Status;
}
//
// Open the NvVars file for writing.
//
return Status;
}
//
// Empty the starting file contents.
//
return Status;
}
return Status;
}
}
return Status;
}