vfs/cbe: Remove use of Io_response_handler

The patch also touches app/cbe_init because it depends on the
public cbe/vfs/trust_anchor_vfs.h header.

Issue #4706
This commit is contained in:
Norman Feske 2022-12-21 17:46:21 +01:00 committed by Christian Helmuth
parent 6c79e95052
commit 909c3571e3
3 changed files with 18 additions and 101 deletions

View File

@ -35,25 +35,6 @@ struct Util::Trust_anchor_vfs
Vfs::File_system &_vfs;
struct Io_response_handler : Vfs::Io_response_handler
{
Genode::Signal_context_capability _io_sigh;
Io_response_handler(Genode::Signal_context_capability io_sigh)
: _io_sigh(io_sigh) { }
void read_ready_response() override { }
void io_progress_response() override
{
if (_io_sigh.valid()) {
Genode::Signal_transmitter(_io_sigh).submit();
}
}
};
Io_response_handler _io_response_handler;
struct File
{
struct Could_not_open_file : Genode::Exception { };
@ -77,8 +58,7 @@ struct Util::Trust_anchor_vfs
File(Path const &base_path,
char const *name,
Vfs::File_system &vfs,
Genode::Allocator &alloc,
Io_response_handler &io_response_handler)
Genode::Allocator &alloc)
:
_vfs { vfs },
_vfs_handle { nullptr }
@ -96,8 +76,6 @@ struct Util::Trust_anchor_vfs
error("could not open '", file_path.string(), "'");
throw Could_not_open_file();
}
_vfs_handle->handler(&io_response_handler);
}
~File()
@ -585,18 +563,16 @@ struct Util::Trust_anchor_vfs
Trust_anchor_vfs(Vfs::File_system &vfs,
Genode::Allocator &alloc,
Path const &path,
Genode::Signal_context_capability io_sigh)
Path const &path)
:
_vfs { vfs },
_io_response_handler { io_sigh },
_ta_dir { path }
_vfs { vfs },
_ta_dir { path }
{
_init_file.construct(path, "initialize", _vfs, alloc, _io_response_handler);
_encrypt_file.construct(path, "encrypt", _vfs, alloc, _io_response_handler);
_decrypt_file.construct(path, "decrypt", _vfs, alloc, _io_response_handler);
_generate_key_file.construct(path, "generate_key", _vfs, alloc, _io_response_handler);
_last_hash_file.construct(path, "hashsum", _vfs, alloc, _io_response_handler);
_init_file.construct(path, "initialize", _vfs, alloc);
_encrypt_file.construct(path, "encrypt", _vfs, alloc);
_decrypt_file.construct(path, "decrypt", _vfs, alloc);
_generate_key_file.construct(path, "generate_key", _vfs, alloc);
_last_hash_file.construct(path, "hashsum", _vfs, alloc);
}
bool request_acceptable() const

View File

@ -31,7 +31,7 @@ enum { VERBOSE = 0 };
using namespace Genode;
class Main
class Main : Vfs::Env::User
{
private:
@ -52,9 +52,14 @@ class Main
Genode::size_t _blk_ratio {
Cbe::BLOCK_SIZE / _blk.info().block_size };
Vfs::Simple_env _vfs_env { _env, _heap, _config_rom.xml().sub_node("vfs") };
Vfs::Simple_env _vfs_env { _env, _heap, _config_rom.xml().sub_node("vfs"), *this };
Vfs::File_system &_vfs { _vfs_env.root_dir() };
/**
* Vfs::Env::User interface
*/
void wakeup_vfs_user() override { _blk_handler.local_submit(); }
static Util::Trust_anchor_vfs::Path _config_ta_dir(Xml_node const &node)
{
using String_path = Genode::String<1024>;
@ -72,8 +77,7 @@ class Main
}
Util::Trust_anchor_vfs _trust_anchor {
_vfs, _vfs_env.alloc(), _config_ta_dir(_config_rom.xml()),
_blk_handler };
_vfs, _vfs_env.alloc(), _config_ta_dir(_config_rom.xml()) };
bool _execute_trust_anchor()
{

View File

@ -97,47 +97,6 @@ class Vfs_cbe::Wrapper
Vfs_handle *_backend_handle { nullptr };
Constructible<Io_job> _backend_job { };
friend struct Backend_io_response_handler;
struct Backend_io_response_handler : Vfs::Io_response_handler
{
Vfs_cbe::Wrapper &_wrapper;
Genode::Signal_context_capability _io_sigh;
Backend_io_response_handler(Vfs_cbe::Wrapper &wrapper,
Genode::Signal_context_capability io_sigh)
: _wrapper(wrapper), _io_sigh(io_sigh) { }
void read_ready_response() override { }
void io_progress_response() override
{
if (_io_sigh.valid()) {
Genode::Signal_transmitter(_io_sigh).submit();
}
}
};
Genode::Io_signal_handler<Wrapper> _io_handler {
_env.env().ep(), *this, &Wrapper::_handle_io };
void _handle_io()
{
_notify_backend_io_progress();
}
void _notify_backend_io_progress()
{
if (_enqueued_vfs_handle) {
_enqueued_vfs_handle->io_progress_response();
} else {
handle_frontend_request();
_io_progress_pending = true;
}
}
Backend_io_response_handler _backend_io_response_handler { *this, _io_handler };
Vfs_handle *_add_key_handle { nullptr };
Vfs_handle *_remove_key_handle { nullptr };
@ -324,8 +283,6 @@ class Vfs_cbe::Wrapper
throw Could_not_open_block_backend();
}
_backend_handle->handler(&_backend_io_response_handler);
{
Genode::String<128> crypto_add_key_file {
_crypto_device.string(), "/add_key" };
@ -355,8 +312,7 @@ class Vfs_cbe::Wrapper
}
_trust_anchor.construct(_env.root_dir(), _env.alloc(),
_trust_anchor_device.string(),
_io_handler);
_trust_anchor_device.string());
_cbe.construct();
}
@ -552,25 +508,11 @@ class Vfs_cbe::Wrapper
return _frontend_request;
}
// XXX needs to be a list when snapshots are used
Vfs_handle *_enqueued_vfs_handle { nullptr };
bool _io_progress_pending { false };
void enqueue_handle(Vfs_handle &handle)
{
_enqueued_vfs_handle = &handle;
if (_io_progress_pending) {
_enqueued_vfs_handle->io_progress_response();
_io_progress_pending = false;
}
}
void ack_frontend_request(Vfs_handle &handle)
{
// assert current state was *_COMPLETE
_frontend_request.state = Frontend_request::State::NONE;
_frontend_request.cbe_request = Cbe::Request { };
_enqueued_vfs_handle = nullptr;
}
bool submit_frontend_request(Vfs_handle &handle,
@ -1255,8 +1197,6 @@ class Vfs_cbe::Wrapper
/* set key id to make file valid */
cf->key_id = key_id_value;
cf->encrypt_handle->handler(&_backend_io_response_handler);
cf->decrypt_handle->handler(&_backend_io_response_handler);
request.success(true);
_cbe->crypto_add_key_completed(request);
@ -1901,7 +1841,6 @@ class Vfs_cbe::Data_file_system : public Single_file_system
if ( state == State::PENDING
|| state == State::IN_PROGRESS) {
_w.enqueue_handle(*this);
return READ_QUEUED;
}
@ -1952,7 +1891,6 @@ class Vfs_cbe::Data_file_system : public Single_file_system
if ( state == State::PENDING
|| state == State::IN_PROGRESS) {
_w.enqueue_handle(*this);
return WRITE_ERR_WOULD_BLOCK;
}
@ -2001,7 +1939,6 @@ class Vfs_cbe::Data_file_system : public Single_file_system
if ( state == State::PENDING
|| state == State::IN_PROGRESS) {
_w.enqueue_handle(*this);
return SYNC_QUEUED;
}