* Copyright (c) 2017 Rob Clark
*/
-#include <env.h>
-#include <malloc.h>
-#include <charset.h>
+#include <common.h>
#include <efi_loader.h>
-#include <hexdump.h>
#include <env_internal.h>
+#include <hexdump.h>
+#include <malloc.h>
#include <search.h>
-#include <uuid.h>
#define READ_ONLY BIT(31)
if (ret)
goto out;
-#define ACCESS_ATTR (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)
-
old_val = env_get(native_name);
if (old_val) {
old_val = parse_attr(old_val, &attr);
goto out;
}
- if ((data_size == 0) || !(attributes & ACCESS_ATTR)) {
+ if ((data_size == 0 &&
+ !(attributes & EFI_VARIABLE_APPEND_WRITE)) ||
+ !attributes) {
/* delete the variable: */
env_set(native_name, NULL);
ret = EFI_SUCCESS;
if (attributes & EFI_VARIABLE_APPEND_WRITE) {
if (!prefix(old_val, "(blob)")) {
- return EFI_DEVICE_ERROR;
+ ret = EFI_DEVICE_ERROR;
goto out;
}
old_size = strlen(old_val);
old_size = 0;
}
} else {
- if ((data_size == 0) || !(attributes & ACCESS_ATTR) ||
+ if (data_size == 0 || !attributes ||
(attributes & EFI_VARIABLE_APPEND_WRITE)) {
- /* delete, but nothing to do */
+ /*
+ * Trying to delete or to update a non-existent
+ * variable.
+ */
ret = EFI_NOT_FOUND;
goto out;
}