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:
commit
98270a95ed
1 changed files with 10 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue