cbe/vfs/trust_anchor_vfs.h: avoid 'Constructible'

This commit is contained in:
Norman Feske 2022-12-21 18:59:36 +01:00 committed by Christian Helmuth
parent 53b67810ba
commit 74e6370187

View File

@ -34,6 +34,7 @@ struct Util::Trust_anchor_vfs
using Path = Genode::Path<256>; using Path = Genode::Path<256>;
Vfs::File_system &_vfs; Vfs::File_system &_vfs;
Allocator &_alloc;
struct File struct File
{ {
@ -121,22 +122,19 @@ struct Util::Trust_anchor_vfs
} }
}; };
Path const _ta_dir;
Util::Io_job::Buffer _init_io_buffer { }; Util::Io_job::Buffer _init_io_buffer { };
Genode::Constructible<File> _init_file { };
Util::Io_job::Buffer _encrypt_io_buffer { }; Util::Io_job::Buffer _encrypt_io_buffer { };
Genode::Constructible<File> _encrypt_file { };
Util::Io_job::Buffer _decrypt_io_buffer { }; Util::Io_job::Buffer _decrypt_io_buffer { };
Genode::Constructible<File> _decrypt_file { };
Util::Io_job::Buffer _generate_key_io_buffer { }; Util::Io_job::Buffer _generate_key_io_buffer { };
Genode::Constructible<File> _generate_key_file { };
Util::Io_job::Buffer _last_hash_io_buffer { }; Util::Io_job::Buffer _last_hash_io_buffer { };
Genode::Constructible<File> _last_hash_file { };
Path _ta_dir { }; File _init_file { _ta_dir, "initialize", _vfs, _alloc };
File _encrypt_file { _ta_dir, "encrypt", _vfs, _alloc };
File _decrypt_file { _ta_dir, "decrypt", _vfs, _alloc };
File _generate_key_file { _ta_dir, "generate_key", _vfs, _alloc };
File _last_hash_file { _ta_dir, "hashsum", _vfs, _alloc };
struct Job struct Job
{ {
@ -242,7 +240,7 @@ struct Util::Trust_anchor_vfs
using Op = Util::Io_job::Operation; using Op = Util::Io_job::Operation;
Op const op = write ? Op::WRITE : Op::READ; Op const op = write ? Op::WRITE : Op::READ;
if (!_decrypt_file->submit_io_job(_decrypt_io_buffer, op)) { if (!_decrypt_file.submit_io_job(_decrypt_io_buffer, op)) {
break; break;
} }
job.state = Job::State::IN_PROGRESS; job.state = Job::State::IN_PROGRESS;
@ -250,17 +248,17 @@ struct Util::Trust_anchor_vfs
} }
[[fallthrough]]; [[fallthrough]];
case Job::State::IN_PROGRESS: case Job::State::IN_PROGRESS:
if (!_decrypt_file->execute_io_job()) { if (!_decrypt_file.execute_io_job()) {
break; break;
} }
progress |= true; progress |= true;
completed_io_job = _decrypt_file->completed_io_job(); completed_io_job = _decrypt_file.completed_io_job();
if (!completed_io_job.completed) { if (!completed_io_job.completed) {
break; break;
} }
_decrypt_file->drop_io_job(); _decrypt_file.drop_io_job();
/* setup second phase */ /* setup second phase */
if (write) { if (write) {
@ -306,7 +304,7 @@ struct Util::Trust_anchor_vfs
using Op = Util::Io_job::Operation; using Op = Util::Io_job::Operation;
Op const op = write ? Op::WRITE : Op::READ; Op const op = write ? Op::WRITE : Op::READ;
if (!_encrypt_file->submit_io_job(_encrypt_io_buffer, op)) { if (!_encrypt_file.submit_io_job(_encrypt_io_buffer, op)) {
break; break;
} }
job.state = Job::State::IN_PROGRESS; job.state = Job::State::IN_PROGRESS;
@ -314,17 +312,17 @@ struct Util::Trust_anchor_vfs
} }
[[fallthrough]]; [[fallthrough]];
case Job::State::IN_PROGRESS: case Job::State::IN_PROGRESS:
if (!_encrypt_file->execute_io_job()) { if (!_encrypt_file.execute_io_job()) {
break; break;
} }
progress |= true; progress |= true;
completed_io_job = _encrypt_file->completed_io_job(); completed_io_job = _encrypt_file.completed_io_job();
if (!completed_io_job.completed) { if (!completed_io_job.completed) {
break; break;
} }
_encrypt_file->drop_io_job(); _encrypt_file.drop_io_job();
/* setup second phase */ /* setup second phase */
if (write) { if (write) {
@ -366,7 +364,7 @@ struct Util::Trust_anchor_vfs
switch (job.state) { switch (job.state) {
case Job::State::PENDING: case Job::State::PENDING:
if (!_generate_key_file->submit_io_job(_generate_key_io_buffer, if (!_generate_key_file.submit_io_job(_generate_key_io_buffer,
Util::Io_job::Operation::READ)) { Util::Io_job::Operation::READ)) {
break; break;
} }
@ -374,17 +372,17 @@ struct Util::Trust_anchor_vfs
progress |= true; progress |= true;
[[fallthrough]]; [[fallthrough]];
case Job::State::IN_PROGRESS: case Job::State::IN_PROGRESS:
if (!_generate_key_file->execute_io_job()) { if (!_generate_key_file.execute_io_job()) {
break; break;
} }
progress |= true; progress |= true;
completed_io_job = _generate_key_file->completed_io_job(); completed_io_job = _generate_key_file.completed_io_job();
if (!completed_io_job.completed) { if (!completed_io_job.completed) {
break; break;
} }
_generate_key_file->drop_io_job(); _generate_key_file.drop_io_job();
job.state = Job::State::COMPLETE; job.state = Job::State::COMPLETE;
job.success = completed_io_job.success; job.success = completed_io_job.success;
@ -407,7 +405,7 @@ struct Util::Trust_anchor_vfs
using Op = Util::Io_job::Operation; using Op = Util::Io_job::Operation;
Op const op = write ? Op::WRITE : Op::READ; Op const op = write ? Op::WRITE : Op::READ;
if (!_init_file->submit_io_job(_init_io_buffer, op)) { if (!_init_file.submit_io_job(_init_io_buffer, op)) {
break; break;
} }
job.state = Job::State::IN_PROGRESS; job.state = Job::State::IN_PROGRESS;
@ -415,17 +413,17 @@ struct Util::Trust_anchor_vfs
} }
[[fallthrough]]; [[fallthrough]];
case Job::State::IN_PROGRESS: case Job::State::IN_PROGRESS:
if (!_init_file->execute_io_job()) { if (!_init_file.execute_io_job()) {
break; break;
} }
progress |= true; progress |= true;
completed_io_job = _init_file->completed_io_job(); completed_io_job = _init_file.completed_io_job();
if (!completed_io_job.completed) { if (!completed_io_job.completed) {
break; break;
} }
_init_file->drop_io_job(); _init_file.drop_io_job();
/* setup second phase */ /* setup second phase */
if (write) { if (write) {
@ -467,7 +465,7 @@ struct Util::Trust_anchor_vfs
switch (job.state) { switch (job.state) {
case Job::State::PENDING: case Job::State::PENDING:
if (!_last_hash_file->submit_io_job(_last_hash_io_buffer, if (!_last_hash_file.submit_io_job(_last_hash_io_buffer,
Util::Io_job::Operation::READ)) { Util::Io_job::Operation::READ)) {
break; break;
} }
@ -475,17 +473,17 @@ struct Util::Trust_anchor_vfs
progress |= true; progress |= true;
[[fallthrough]]; [[fallthrough]];
case Job::State::IN_PROGRESS: case Job::State::IN_PROGRESS:
if (!_last_hash_file->execute_io_job()) { if (!_last_hash_file.execute_io_job()) {
break; break;
} }
progress |= true; progress |= true;
completed_io_job = _last_hash_file->completed_io_job(); completed_io_job = _last_hash_file.completed_io_job();
if (!completed_io_job.completed) { if (!completed_io_job.completed) {
break; break;
} }
_last_hash_file->drop_io_job(); _last_hash_file.drop_io_job();
job.state = Job::State::COMPLETE; job.state = Job::State::COMPLETE;
job.success = completed_io_job.success; job.success = completed_io_job.success;
@ -508,7 +506,7 @@ struct Util::Trust_anchor_vfs
using Op = Util::Io_job::Operation; using Op = Util::Io_job::Operation;
Op const op = write ? Op::WRITE : Op::READ; Op const op = write ? Op::WRITE : Op::READ;
if (!_last_hash_file->submit_io_job(_last_hash_io_buffer, op)) { if (!_last_hash_file.submit_io_job(_last_hash_io_buffer, op)) {
break; break;
} }
job.state = Job::State::IN_PROGRESS; job.state = Job::State::IN_PROGRESS;
@ -516,17 +514,17 @@ struct Util::Trust_anchor_vfs
} }
[[fallthrough]]; [[fallthrough]];
case Job::State::IN_PROGRESS: case Job::State::IN_PROGRESS:
if (!_last_hash_file->execute_io_job()) { if (!_last_hash_file.execute_io_job()) {
break; break;
} }
progress |= true; progress |= true;
completed_io_job = _last_hash_file->completed_io_job(); completed_io_job = _last_hash_file.completed_io_job();
if (!completed_io_job.completed) { if (!completed_io_job.completed) {
break; break;
} }
_last_hash_file->drop_io_job(); _last_hash_file.drop_io_job();
/* setup second phase */ /* setup second phase */
if (write) { if (write) {
@ -565,15 +563,8 @@ struct Util::Trust_anchor_vfs
Genode::Allocator &alloc, Genode::Allocator &alloc,
Path const &path) Path const &path)
: :
_vfs { vfs }, _vfs(vfs), _alloc(alloc), _ta_dir(path)
_ta_dir { path } { }
{
_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 bool request_acceptable() const
{ {