mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 02:00:00 +03:00
Rollup merge of #150853 - uefi-fs-read, r=joboet
std: sys: fs: uefi: Implement File::read Tested using OVMF on QEMU. @rustbot label +O-UEFI
This commit is contained in:
@@ -320,8 +320,8 @@ pub fn truncate(&self, size: u64) -> io::Result<()> {
|
||||
self.0.set_file_info(file_info)
|
||||
}
|
||||
|
||||
pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
|
||||
unsupported()
|
||||
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
self.0.read(buf)
|
||||
}
|
||||
|
||||
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||
@@ -666,6 +666,19 @@ fn open(
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
pub(crate) fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
let file_ptr = self.protocol.as_ptr();
|
||||
let mut buf_size = buf.len();
|
||||
|
||||
let r = unsafe { ((*file_ptr).read)(file_ptr, &mut buf_size, buf.as_mut_ptr().cast()) };
|
||||
|
||||
if buf_size == 0 && r.is_error() {
|
||||
Err(io::Error::from_raw_os_error(r.as_usize()))
|
||||
} else {
|
||||
Ok(buf_size)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn read_dir_entry(&self) -> io::Result<Option<UefiBox<file::Info>>> {
|
||||
let file_ptr = self.protocol.as_ptr();
|
||||
let mut buf_size = 0;
|
||||
|
||||
Reference in New Issue
Block a user