Rollup merge of #150862 - uefi-fs-flush, r=the8472

std: sys: fs: uefi: Implement File::flush

- Also forward fsync and datasync to flush. UEFI does not have anything separate for metadata sync.

@rustbot label +O-UEFI
This commit is contained in:
Matthias Krüger 2026-01-11 09:56:49 +01:00 committed by GitHub
commit 98270a95ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -285,11 +285,11 @@ impl File {
}
pub fn fsync(&self) -> io::Result<()> {
unsupported()
self.datasync()
}
pub fn datasync(&self) -> io::Result<()> {
unsupported()
self.0.flush()
}
pub fn lock(&self) -> io::Result<()> {
@ -348,8 +348,9 @@ impl File {
false
}
// Write::flush is only meant for buffered writers. So should be noop for unbuffered files.
pub fn flush(&self) -> io::Result<()> {
unsupported()
Ok(())
}
pub fn seek(&self, _pos: SeekFrom) -> io::Result<u64> {
@ -784,6 +785,12 @@ mod uefi_fs {
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) }
}
pub(crate) fn flush(&self) -> io::Result<()> {
let file_ptr = self.protocol.as_ptr();
let r = unsafe { ((*file_ptr).flush)(file_ptr) };
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) }
}
pub(crate) fn path(&self) -> &Path {
&self.path
}