block session: remove Block::Session::Operations

This patch modernizes the 'Block::Session::info' interface. Instead of
using out parameters, the 'init' RPC function returns a compound 'Info'
object now. The rather complicated 'Operations' struct is replaced by
a 'writeable' attribute in the 'Info' object.

Fixes #3275
This commit is contained in:
Norman Feske
2019-04-03 16:05:10 +02:00
committed by Christian Helmuth
parent 10c567daee
commit 2208220c12
45 changed files with 385 additions and 526 deletions

View File

@@ -32,12 +32,13 @@ struct Gpt::Writer
struct Io_error : Genode::Exception { };
struct Gpt_invalid : Genode::Exception { };
using sector_t = Block::sector_t;
using sector_t = Block::sector_t;
Block::Connection &_block;
Block::Session::Operations _block_ops { };
Block::sector_t _block_count { 0 };
size_t _block_size { 0 };
Block::Connection &_block;
Block::Session::Info const _info { _block.info() };
size_t const _block_size { _info.block_size };
sector_t const _block_count { _info.block_count };
/*
* Blocks available is a crude approximation that _does not_ take
@@ -653,9 +654,7 @@ struct Gpt::Writer
*/
Writer(Block::Connection &block, Genode::Xml_node config) : _block(block)
{
_block.info(&_block_count, &_block_size, &_block_ops);
if (!_block_ops.supported(Block::Packet_descriptor::WRITE)) {
if (!_info.writeable) {
Genode::error("cannot write to Block session");
throw Io_error();
}

View File

@@ -28,7 +28,7 @@ class Http
private:
Genode::Heap &_heap;
size_t _size; /* number of bytes in file */
size_t _size; /* number of bytes in file */
char *_host; /* host name */
char *_port; /* host port */
char *_path; /* absolute file path on host */
@@ -95,7 +95,7 @@ class Http
*
* \return Remote file size in bytes
*/
size_t file_size() { return _size; }
size_t file_size() const { return _size; }
/**
* Set base address of I/O dataspace

View File

@@ -42,14 +42,11 @@ class Driver : public Block::Driver
** Block::Driver interface **
*******************************/
Genode::size_t block_size() { return _block_size; }
Block::sector_t block_count() { return _http.file_size() / _block_size; }
Block::Session::Operations ops()
Block::Session::Info info() const override
{
Block::Session::Operations o;
o.set_operation(Block::Packet_descriptor::READ);
return o;
return { .block_size = _block_size,
.block_count = _http.file_size() / _block_size,
.writeable = false };
}
void read(Block::sector_t block_nr,