Skip to content

Commit 92b9e84

Browse files
authored
Rollup merge of #150855 - uefi-fs-tell, r=joboet
std: sys: fs: uefi: Implement File::tell - Just a call to get_position - Tested with OVMF on QEMU @rustbot label +O-UEFI
2 parents 93f6171 + 97fc739 commit 92b9e84

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

library/std/src/sys/fs/uefi.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl File {
364364
}
365365

366366
pub fn tell(&self) -> io::Result<u64> {
367-
unsupported()
367+
self.0.position()
368368
}
369369

370370
pub fn duplicate(&self) -> io::Result<File> {
@@ -747,6 +747,14 @@ mod uefi_fs {
747747
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) }
748748
}
749749

750+
pub(crate) fn position(&self) -> io::Result<u64> {
751+
let file_ptr = self.protocol.as_ptr();
752+
let mut pos = 0;
753+
754+
let r = unsafe { ((*file_ptr).get_position)(file_ptr, &mut pos) };
755+
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(pos) }
756+
}
757+
750758
pub(crate) fn delete(self) -> io::Result<()> {
751759
let file_ptr = self.protocol.as_ptr();
752760
let r = unsafe { ((*file_ptr).delete)(file_ptr) };

0 commit comments

Comments
 (0)