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
This commit is contained in:
oliviermartin 2011-03-31 12:14:06 +00:00
parent 8e06b586e8
commit 20fd35dc44
1 changed files with 25 additions and 4 deletions

View File

@ -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) {
//
// 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
);
if (!EFI_ERROR(Status)) {
AsciiPrint("'%a'='%a'\n",AsciiVariableName,AsciiValue);
}
return Status;
}