part_block: use expanding reporter

Depending on the number of partitions the current fixed size of 4096
bytes might not be sufficient for the resulting partitions report.
The use of the expanding reporter allows for accomodating large reports
while still keeping the resource usage down for the common case of
few partitions (with potentially short names).

Fixes #4782.
This commit is contained in:
Josef Söntgen 2023-03-09 13:32:41 +01:00 committed by Christian Helmuth
parent d0f4791413
commit 9b9d1f4e12
4 changed files with 15 additions and 15 deletions

View File

@ -348,9 +348,9 @@ class Block::Gpt : public Block::Partition_table
}
/* Report the partitions */
if (reporter.enabled())
if (reporter.constructed())
{
Reporter::Xml_generator xml(reporter, [&] () {
reporter->generate([&] (Xml_generator &xml) {
xml.attribute("type", "gpt");
uint64_t const total_blocks = block.info().block_count;

View File

@ -212,8 +212,8 @@ class Block::Main : Rpc_object<Typed_root<Session>>,
Attached_rom_dataspace _config { _env, "config" };
Heap _heap { _env.ram(), _env.rm() };
Reporter _reporter { _env, "partitions" };
Heap _heap { _env.ram(), _env.rm() };
Constructible<Expanding_reporter> _reporter { };
Number_of_bytes const _io_buffer_size =
_config.xml().attribute_value("io_buffer",
@ -498,7 +498,7 @@ Block::Partition_table & Block::Main::_table()
report = _config.xml().sub_node("report").attribute_value
("partitions", false);
if (report)
_reporter.enabled(true);
_reporter.construct(_env, "partitions", "partitions");
} catch(...) {}
/*

View File

@ -215,7 +215,7 @@ struct Block::Mbr_partition_table : public Block::Partition_table
Partition(0, (block_count_t)(block.info().block_count - 1)));
/* report the partitions */
if (reporter.enabled()) {
if (reporter.constructed()) {
auto gen_partition_attr = [&] (Xml_generator &xml, unsigned i)
{
@ -238,7 +238,7 @@ struct Block::Mbr_partition_table : public Block::Partition_table
xml.attribute("file_system", fs_type);
};
Reporter::Xml_generator xml(reporter, [&] () {
reporter->generate([&] (Xml_generator &xml) {
xml.attribute("type", mbr_valid ? "mbr" :
ahdi_valid ? "ahdi" :

View File

@ -152,10 +152,10 @@ struct Block::Partition_table : Interface
return reinterpret_cast<T>(_buffer); }
};
Env &env;
Block_connection &block;
Reporter &reporter;
Sector_data data;
Env &env;
Block_connection &block;
Constructible<Expanding_reporter> &reporter;
Sector_data data;
Io_signal_handler<Partition_table> io_sigh {
env.ep(), *this, &Partition_table::handle_io };
@ -165,10 +165,10 @@ struct Block::Partition_table : Interface
if (data.current) { data.current->handle_io(); }
}
Partition_table(Env &env,
Block_connection &block,
Allocator &alloc,
Reporter &r)
Partition_table(Env &env,
Block_connection &block,
Allocator &alloc,
Constructible<Expanding_reporter> &r)
: env(env), block(block), reporter(r), data(env, block, alloc)
{ }