Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freebsd: Don't panic if can't ioctl ESRT #50

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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