diff options
author | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-03-31 12:14:06 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-03-31 12:14:06 +0000 |
commit | 20fd35dc44dce47c319c3917fc78c30160354cee (patch) | |
tree | 9ff51984062ce477732b18cacba6405dca52b645 /EmbeddedPkg/Ebl | |
parent | 8e06b586e832e4c050eb506c2fadbdca5bf361ff (diff) | |
download | edk2-20fd35dc44dce47c319c3917fc78c30160354cee.zip edk2-20fd35dc44dce47c319c3917fc78c30160354cee.tar.gz edk2-20fd35dc44dce47c319c3917fc78c30160354cee.tar.bz2 |
EmbeddedPkg/Ebl: Add support for env variable deletion
Passing only the variable name should delete the environment
variable if it exists.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11477 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg/Ebl')
-rw-r--r-- | EmbeddedPkg/Ebl/Variable.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/EmbeddedPkg/Ebl/Variable.c b/EmbeddedPkg/Ebl/Variable.c index 330a143..3fd688b 100644 --- a/EmbeddedPkg/Ebl/Variable.c +++ b/EmbeddedPkg/Ebl/Variable.c @@ -55,7 +55,7 @@ EblGetCmd ( Size = 0; Status = gRT->GetVariable (VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value); if (Status == EFI_NOT_FOUND) { - AsciiPrint("Variable name '%a' not found.\n",VariableName); + AsciiPrint("Variable name '%s' not found.\n",VariableName); } else if (Status == EFI_BUFFER_TOO_SMALL) { // Get the environment variable value Value = AllocatePool (Size); @@ -117,7 +117,27 @@ EblSetCmd ( // Check if it is a valid variable setting AsciiValue = AsciiStrStr (AsciiVariableSetting,"=");
if (AsciiValue == NULL) { - AsciiPrint("Variable setting is incorrect. It should be VariableName=Value\n"); + // + // There is no value. It means this variable will be deleted + // + + // Convert VariableName into Unicode + VariableName = AllocatePool((AsciiStrLen (AsciiVariableSetting) + 1) * sizeof (CHAR16)); + AsciiStrToUnicodeStr (AsciiVariableSetting,VariableName); + + Status = gRT->SetVariable ( + VariableName, + &gEfiGlobalVariableGuid, + ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) | + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + 0, + NULL + ); + if (!EFI_ERROR(Status)) { + AsciiPrint("Variable '%s' deleted\n",VariableName); + } else { + AsciiPrint("Variable setting is incorrect. It should be VariableName=Value\n"); + } return Status; }
@@ -158,8 +178,9 @@ EblSetCmd ( AsciiStrLen (AsciiValue)+1, AsciiValue );
-
- AsciiPrint("'%a'='%a'\n",AsciiVariableName,AsciiValue);
+ if (!EFI_ERROR(Status)) {
+ AsciiPrint("'%a'='%a'\n",AsciiVariableName,AsciiValue);
+ } return Status;
}
|