From 96c93dae491f18547d780376fd448fe7fea89c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Tue, 18 Feb 2020 14:43:11 +0100 Subject: [PATCH] vfs: implement 'sync' in Block VFS plugin Fixes #3659. --- repos/os/src/lib/vfs/block_file_system.h | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/repos/os/src/lib/vfs/block_file_system.h b/repos/os/src/lib/vfs/block_file_system.h index ff485e77b..a84f92d2f 100644 --- a/repos/os/src/lib/vfs/block_file_system.h +++ b/repos/os/src/lib/vfs/block_file_system.h @@ -319,6 +319,34 @@ class Vfs::Block_file_system : public Single_file_system } + Sync_result sync() override + { + /* + * Just in case bail if we cannot submit the packet. + * (Since the plugin operates in a synchronous fashion + * that should not happen.) + */ + if (!_tx_source->ready_to_submit()) { + Genode::error("vfs_block: could not sync blocks"); + return SYNC_ERR_INVALID; + } + + Block::Packet_descriptor p = + Block::Session::sync_all_packet_descriptor( + _block.info(), Block::Session::Tag { 0 }); + + _tx_source->submit_packet(p); + p = _tx_source->get_acked_packet(); + _tx_source->release_packet(p); + + if (!p.succeeded()) { + Genode::error("vfs_block: syncing blocks failed"); + return SYNC_ERR_INVALID; + } + + return SYNC_OK; + } + bool read_ready() override { return true; } };