Skip to content
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
23 changes: 21 additions & 2 deletions library/std/src/sys/fs/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ impl File {
crate::io::default_read_buf(|buf| self.read(buf), cursor)
}

pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
unsupported()
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
self.0.write(buf)
}

pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
Expand Down Expand Up @@ -692,6 +692,25 @@ mod uefi_fs {
}
}

pub(crate) fn write(&self, buf: &[u8]) -> io::Result<usize> {
let file_ptr = self.protocol.as_ptr();
let mut buf_size = buf.len();

let r = unsafe {
((*file_ptr).write)(
file_ptr,
&mut buf_size,
buf.as_ptr().cast::<crate::ffi::c_void>().cast_mut(),
)
};

if buf_size == 0 && r.is_error() {
Err(io::Error::from_raw_os_error(r.as_usize()))
} else {
Ok(buf_size)
}
}

pub(crate) fn file_info(&self) -> io::Result<UefiBox<file::Info>> {
let file_ptr = self.protocol.as_ptr();
let mut info_id = file::INFO_ID;
Expand Down
Loading