2 Save Non-Volatile Variables to a file system.
4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "NvVarsFileLib.h"
10 #include <Library/DebugLib.h>
11 #include <Library/NvVarsFileLib.h>
13 EFI_HANDLE mNvVarsFileLibFsHandle
= NULL
;
16 Attempts to connect the NvVarsFileLib to the specified file system.
18 @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
20 @return The EFI_STATUS while attempting to connect the NvVarsFileLib
21 to the file system instance.
22 @retval EFI_SUCCESS - The given file system was connected successfully
27 ConnectNvVarsToFileSystem (
28 IN EFI_HANDLE FsHandle
31 #ifdef SECURE_BOOT_FEATURE_ENABLED
33 return EFI_UNSUPPORTED
;
40 // We might fail to load the variable, since the file system initially
41 // will not have the NvVars file.
43 LoadNvVarsFromFs (FsHandle
);
46 // We must be able to save the variables successfully to the file system
47 // to have connected successfully.
49 Status
= SaveNvVarsToFs (FsHandle
);
50 if (!EFI_ERROR (Status
)) {
51 mNvVarsFileLibFsHandle
= FsHandle
;
59 Update non-volatile variables stored on the file system.
61 @return The EFI_STATUS while attempting to update the variable on
62 the connected file system.
63 @retval EFI_SUCCESS - The non-volatile variables were saved to the disk
64 @retval EFI_NOT_STARTED - A file system has not been connected
69 UpdateNvVarsOnFileSystem (
72 if (mNvVarsFileLibFsHandle
== NULL
) {
74 // A file system had not been connected to the library.
76 return EFI_NOT_STARTED
;
78 return SaveNvVarsToFs (mNvVarsFileLibFsHandle
);