Skip to content

Commit

Permalink
freebsd: Don't panic if can't ioctl ESRT
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Aug 6, 2024
1 parent 2e30627 commit 2e58cb1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions framework_lib/src/esrt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,12 @@ ioctl_readwrite!(efi_get_table, b'E', 1, EfiGetTableIoc);

#[cfg(all(not(feature = "uefi"), target_os = "freebsd"))]
pub fn get_esrt() -> Option<Esrt> {
let path = "/dev/efi";
let file = OpenOptions::new()
.read(true)
.write(true)
.custom_flags(libc::O_NONBLOCK)
.open("/dev/efi")
.open(path)
.unwrap();

let mut buf: Vec<u8> = Vec::new();
Expand All @@ -433,7 +434,10 @@ pub fn get_esrt() -> Option<Esrt> {
};
unsafe {
let fd = file.as_raw_fd();
let _res = efi_get_table(fd, &mut table).unwrap();
if let Err(err) = efi_get_table(fd, &mut table) {
error!("Failed to access ESRT at {}: {:?}", path, err);
return None;
}
buf.resize(table.table_len, 0);
table.buf_len = table.table_len;
table.buf = buf.as_mut_ptr();
Expand Down

0 comments on commit 2e58cb1

Please sign in to comment.