Skip to content

Commit 052ca3f

Browse files
hughsienicholasbishop
authored andcommitted
uefi: Add delete_variable() helper
1 parent 0606b0e commit 052ca3f

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
wrapper will automatically select `ComponentName2` if available, and fall back
99
to `ComponentName1` otherwise.
1010
- `FileType`, `FileHandle`, `RegularFile`, and `Directory` now implement `Debug`.
11+
- Added `RuntimeServices::delete_variable()` helper method.
1112

1213
### Changed
1314

uefi-test-runner/src/runtime/vars.rs

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use log::info;
22
use uefi::guid;
33
use uefi::prelude::*;
44
use uefi::table::runtime::{VariableAttributes, VariableVendor};
5+
use uefi::Status;
56

67
fn test_variables(rt: &RuntimeServices) {
78
let name = cstr16!("UefiRsTestVar");
@@ -37,6 +38,16 @@ fn test_variables(rt: &RuntimeServices) {
3738
if let Some(key) = variable_keys.first() {
3839
info!("First variable: {}", key);
3940
}
41+
42+
info!("Testing delete_variable()");
43+
rt.delete_variable(name, &vendor)
44+
.expect("failed to delete variable");
45+
assert_eq!(
46+
rt.get_variable(name, &vendor, &mut buf)
47+
.unwrap_err()
48+
.status(),
49+
Status::NOT_FOUND
50+
);
4051
}
4152

4253
fn test_variable_info(rt: &RuntimeServices) {

uefi/src/table/runtime.rs

+5
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ impl RuntimeServices {
245245
}
246246
}
247247

248+
/// Deletes a UEFI variable.
249+
pub fn delete_variable(&self, name: &CStr16, vendor: &VariableVendor) -> Result {
250+
self.set_variable(name, vendor, VariableAttributes::empty(), &[])
251+
}
252+
248253
/// Get information about UEFI variable storage space for the type
249254
/// of variable specified in `attributes`.
250255
///

0 commit comments

Comments
 (0)