mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 20:05:54 +00:00
sculpt: remove notion of system 'block_devices'
This patch removes the remains of the original block-device discovery as done by the former driver manager. Block sessions are now always provided by components hosted in the runtime subsytem. The storage node of the graph is no more. Issue #5150
This commit is contained in:
parent
0cf12c6778
commit
f96cea8151
@ -22,9 +22,7 @@ namespace Sculpt { struct Feature; };
|
||||
struct Sculpt::Feature
|
||||
{
|
||||
static constexpr bool PRESENT_PLUS_MENU = false;
|
||||
static constexpr bool STORAGE_DIALOG_HOSTED_IN_GRAPH = false;
|
||||
static constexpr bool INSPECT_VIEW = false;
|
||||
static constexpr bool VISUAL_HOVER = false;
|
||||
};
|
||||
|
||||
#endif /* _FEATURE_H_ */
|
||||
|
@ -68,7 +68,7 @@ namespace Sculpt { struct Main; }
|
||||
struct Sculpt::Main : Input_event_handler,
|
||||
Runtime_config_generator,
|
||||
Deploy::Action,
|
||||
Storage::Action,
|
||||
Storage_device::Action,
|
||||
Network::Action,
|
||||
Network::Info,
|
||||
Graph::Action,
|
||||
@ -81,6 +81,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Dialpad_widget::Action,
|
||||
Current_call_widget::Action,
|
||||
Network_widget::Action,
|
||||
Ram_fs_widget::Action,
|
||||
Software_presets_widget::Action,
|
||||
Software_options_widget::Action,
|
||||
Software_update_widget::Action,
|
||||
@ -210,7 +211,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
*/
|
||||
void handle_device_plug_unplug() override
|
||||
{
|
||||
_handle_block_devices();
|
||||
_handle_storage_devices();
|
||||
network_config_changed();
|
||||
generate_runtime_config();
|
||||
}
|
||||
@ -311,37 +312,39 @@ struct Sculpt::Main : Input_event_handler,
|
||||
** Storage **
|
||||
*************/
|
||||
|
||||
Attached_rom_dataspace _block_devices_rom { _env, "report -> drivers/block_devices" };
|
||||
|
||||
Signal_handler<Main> _block_devices_handler {
|
||||
_env.ep(), *this, &Main::_handle_block_devices };
|
||||
|
||||
void _handle_block_devices()
|
||||
void _handle_storage_devices()
|
||||
{
|
||||
_block_devices_rom.update();
|
||||
Storage_target const orig_sculpt_partition = _storage._sculpt_partition;
|
||||
|
||||
_drivers.with_storage_devices([&] (Xml_node const &usb_devices,
|
||||
Xml_node const &ahci_ports,
|
||||
Xml_node const &nvme_namespaces,
|
||||
Xml_node const &mmc_devices) {
|
||||
_storage.update(usb_devices, ahci_ports, nvme_namespaces, mmc_devices,
|
||||
_block_devices_rom.xml(),
|
||||
_block_devices_handler);
|
||||
});
|
||||
bool total_progress = false;
|
||||
for (bool progress = true; progress; total_progress |= progress) {
|
||||
progress = false;
|
||||
_drivers.with_storage_devices([&] (Drivers::Storage_devices const &devices) {
|
||||
progress = _storage.update(devices.usb, devices.ahci,
|
||||
devices.nvme, devices.mmc).progress; });
|
||||
|
||||
/* update USB policies for storage devices */
|
||||
_drivers.update_usb();
|
||||
/* update USB policies for storage devices */
|
||||
_drivers.update_usb();
|
||||
}
|
||||
|
||||
if (orig_sculpt_partition != _storage._sculpt_partition)
|
||||
_restart_from_storage_target();
|
||||
|
||||
if (total_progress) {
|
||||
generate_runtime_config();
|
||||
_generate_dialog();
|
||||
}
|
||||
}
|
||||
|
||||
Storage _storage { _env, _heap, _child_states, *this, *this };
|
||||
|
||||
/**
|
||||
* Storage::Action interface
|
||||
* Storage_device::Action
|
||||
*/
|
||||
void use_storage_target(Storage_target const &target) override
|
||||
{
|
||||
_storage._sculpt_partition = target;
|
||||
void storage_device_discovered() override { _handle_storage_devices(); }
|
||||
|
||||
Storage _storage { _env, _heap, _child_states, *this };
|
||||
|
||||
void _restart_from_storage_target()
|
||||
{
|
||||
/* trigger loading of the configuration from the sculpt partition */
|
||||
_prepare_version.value++;
|
||||
|
||||
@ -350,11 +353,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage::Action interface
|
||||
*/
|
||||
void refresh_storage_dialog() override { _generate_dialog(); }
|
||||
|
||||
|
||||
/*************
|
||||
** Network **
|
||||
@ -1256,7 +1254,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_storage_widget .propagate(at, *this);
|
||||
_software_presets_widget.propagate(at, _presets, *this);
|
||||
_software_add_widget .propagate(at, *this);
|
||||
_graph .propagate(at, *this, _storage);
|
||||
_graph .propagate(at, *this, *this);
|
||||
|
||||
_update_touch_keyboard_visibility();
|
||||
}
|
||||
@ -1350,44 +1348,57 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
void use(Storage_target const &target) override
|
||||
{
|
||||
_storage._sculpt_partition = target;
|
||||
_software_update_widget.hosted.reset();
|
||||
_download_queue.reset();
|
||||
_storage.use(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
/*
|
||||
* Storage_dialog::Action interface
|
||||
* Storage_device_widget::Action interface
|
||||
*/
|
||||
void format(Storage_target const &target) override
|
||||
{
|
||||
_storage.format(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void cancel_format(Storage_target const &target) override
|
||||
{
|
||||
_storage.cancel_format(target);
|
||||
_reset_storage_widget_operation();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void expand(Storage_target const &target) override
|
||||
{
|
||||
_storage.expand(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void cancel_expand(Storage_target const &target) override
|
||||
{
|
||||
_storage.cancel_expand(target);
|
||||
_reset_storage_widget_operation();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void check(Storage_target const &target) override
|
||||
{
|
||||
_storage.check(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void toggle_default_storage_target(Storage_target const &target) override
|
||||
{
|
||||
_storage.toggle_default_storage_target(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void reset_ram_fs() override
|
||||
{
|
||||
_storage.reset_ram_fs();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2228,7 +2239,7 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
|
||||
device.for_each_partition([&] (Partition &partition) {
|
||||
|
||||
Storage_target const target { device.label, device.port, partition.number };
|
||||
Storage_target const target { device.driver, device.port, partition.number };
|
||||
|
||||
if (partition.check_in_progress) {
|
||||
String<64> name(target.label(), ".e2fsck");
|
||||
@ -2320,8 +2331,7 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
|
||||
/* handle failed initialization of USB-storage devices */
|
||||
_storage._storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device &dev) {
|
||||
String<64> name(dev.usb_block_drv_name());
|
||||
Child_exit_state exit_state(state, name);
|
||||
Child_exit_state exit_state(state, dev.driver);
|
||||
if (exit_state.exited) {
|
||||
dev.discard_usb_block_drv();
|
||||
reconfigure_runtime = true;
|
||||
|
@ -79,7 +79,10 @@ struct Sculpt::Ahci_driver : private Noncopyable
|
||||
Ram_quota { 10*1024*1024 }, Cap_quota { 100 });
|
||||
}
|
||||
|
||||
void with_ports(auto const &fn) const { fn(_ports.xml()); }
|
||||
void with_ports(auto const &fn) const
|
||||
{
|
||||
fn(_ahci.constructed() ? _ports.xml() : Xml_node("<none/>"));
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVER__AHCI_H_ */
|
||||
|
@ -77,7 +77,10 @@ struct Sculpt::Mmc_driver : private Noncopyable
|
||||
Ram_quota { 16*1024*1024 }, Cap_quota { 500 });
|
||||
}
|
||||
|
||||
void with_devices(auto const &fn) const { fn(_devices.xml()); }
|
||||
void with_devices(auto const &fn) const
|
||||
{
|
||||
fn(_mmc.constructed() ? _devices.xml() : Xml_node("<none/>"));
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVER__MMC_H_ */
|
||||
|
@ -78,7 +78,10 @@ struct Sculpt::Nvme_driver : private Noncopyable
|
||||
Ram_quota { 8*1024*1024 }, Cap_quota { 100 });
|
||||
}
|
||||
|
||||
void with_namespaces(auto const &fn) const { fn(_namespaces.xml()); }
|
||||
void with_namespaces(auto const &fn) const
|
||||
{
|
||||
fn(_nvme.constructed() ? _namespaces.xml() : Xml_node("<none/>"));
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVER_NVME_H_ */
|
||||
|
@ -178,7 +178,10 @@ struct Sculpt::Usb_driver : private Noncopyable
|
||||
_usb_config.trigger_update();
|
||||
}
|
||||
|
||||
void with_devices(auto const &fn) const { fn(_devices.xml()); }
|
||||
void with_devices(auto const &fn) const
|
||||
{
|
||||
fn(_hcd.constructed() ? _devices.xml() : Xml_node("<none/>"));
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVER__USB_H_ */
|
||||
|
@ -24,9 +24,6 @@ struct Sculpt::Feature
|
||||
/* show the '+' botton at the graph for opening the deploy popup dialog */
|
||||
static constexpr bool PRESENT_PLUS_MENU = true;
|
||||
|
||||
/* manage storage from within the respective graph nodes */
|
||||
static constexpr bool STORAGE_DIALOG_HOSTED_IN_GRAPH = true;
|
||||
|
||||
/* allow the browsing of file systems via the inspect view */
|
||||
static constexpr bool INSPECT_VIEW = true;
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ void Graph::_view_selected_node_content(Scope<Depgraph, Frame, Vbox> &s,
|
||||
s.sub_scope<Label>(ram);
|
||||
s.sub_scope<Label>(caps);
|
||||
|
||||
if ((name == "usb") && _storage_devices.usb_present)
|
||||
if ((name == "usb") && _storage_devices.num_usb_devices)
|
||||
s.sub_scope<Frame>([&] (Scope<Depgraph, Frame, Vbox, Frame> &s) {
|
||||
s.widget(_usb_devices_widget); });
|
||||
|
||||
@ -128,35 +128,11 @@ void Graph::_view_selected_node_content(Scope<Depgraph, Frame, Vbox> &s,
|
||||
}
|
||||
|
||||
|
||||
void Graph::_view_storage_node(Scope<Depgraph> &s) const
|
||||
{
|
||||
bool const any_selected = _runtime_state.selected().valid();
|
||||
|
||||
Selectable_node::view(s, Id { "storage" },
|
||||
{
|
||||
.selected = _storage_selected,
|
||||
.important = !any_selected || _runtime_state.storage_in_tcb(),
|
||||
.primary_dep = { },
|
||||
.pretty_name = "Storage"
|
||||
},
|
||||
[&] (Scope<Depgraph, Frame, Vbox> &s) {
|
||||
s.sub_scope<Frame>([&] (Scope<Depgraph, Frame, Vbox, Frame> &s) {
|
||||
s.widget(_block_devices_widget); });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Graph::view(Scope<Depgraph> &s) const
|
||||
{
|
||||
if (Feature::PRESENT_PLUS_MENU && _sculpt_partition.valid())
|
||||
s.widget(_plus, _popup_state == Popup::VISIBLE);
|
||||
|
||||
if (Feature::STORAGE_DIALOG_HOSTED_IN_GRAPH)
|
||||
_view_storage_node(s);
|
||||
else
|
||||
s.sub_scope<Parent_node>(Id { "storage" }, "Storage");
|
||||
|
||||
/* parent roles */
|
||||
s.sub_scope<Parent_node>(Id { "hardware" }, "Hardware");
|
||||
s.sub_scope<Parent_node>(Id { "config" }, "Config");
|
||||
@ -267,14 +243,9 @@ void Graph::click(Clicked_at const &at, Action &action)
|
||||
{
|
||||
/* select node */
|
||||
Id const id = at.matching_id<Depgraph, Frame, Vbox, Button>();
|
||||
if (id.valid()) {
|
||||
_storage_selected = !_storage_selected && (id.value == "storage");
|
||||
|
||||
if (_storage_selected) _block_devices_widget.reset();
|
||||
|
||||
if (id.valid())
|
||||
_runtime_config.with_start_name(id, [&] (Start_name const &name) {
|
||||
_runtime_state.toggle_selection(name, _runtime_config); });
|
||||
}
|
||||
|
||||
_plus.propagate(at, [&] {
|
||||
|
||||
@ -293,12 +264,11 @@ void Graph::click(Clicked_at const &at, Action &action)
|
||||
action.open_popup_dialog(popup_anchor(at._location));
|
||||
});
|
||||
|
||||
_ram_fs_widget .propagate(at, _sculpt_partition, action);
|
||||
_block_devices_widget.propagate(at, action);
|
||||
_ahci_devices_widget .propagate(at, action);
|
||||
_nvme_devices_widget .propagate(at, action);
|
||||
_mmc_devices_widget .propagate(at, action);
|
||||
_usb_devices_widget .propagate(at, action);
|
||||
_ram_fs_widget .propagate(at, _sculpt_partition, action);
|
||||
_ahci_devices_widget.propagate(at, action);
|
||||
_nvme_devices_widget.propagate(at, action);
|
||||
_mmc_devices_widget .propagate(at, action);
|
||||
_usb_devices_widget .propagate(at, action);
|
||||
|
||||
_remove .propagate(at);
|
||||
_restart.propagate(at);
|
||||
@ -307,12 +277,11 @@ void Graph::click(Clicked_at const &at, Action &action)
|
||||
|
||||
void Graph::clack(Clacked_at const &at, Action &action, Ram_fs_widget::Action &ram_fs_action)
|
||||
{
|
||||
_ram_fs_widget .propagate(at, ram_fs_action);
|
||||
_block_devices_widget.propagate(at, action);
|
||||
_ahci_devices_widget .propagate(at, action);
|
||||
_nvme_devices_widget .propagate(at, action);
|
||||
_mmc_devices_widget .propagate(at, action);
|
||||
_usb_devices_widget .propagate(at, action);
|
||||
_ram_fs_widget .propagate(at, ram_fs_action);
|
||||
_ahci_devices_widget.propagate(at, action);
|
||||
_nvme_devices_widget.propagate(at, action);
|
||||
_mmc_devices_widget .propagate(at, action);
|
||||
_usb_devices_widget .propagate(at, action);
|
||||
|
||||
_remove.propagate(at, [&] {
|
||||
action.remove_deployed_component(_runtime_state.selected());
|
||||
|
@ -54,10 +54,6 @@ struct Sculpt::Graph : Widget<Depgraph>
|
||||
_remove { Id { "Remove" } },
|
||||
_restart { Id { "Restart" } };
|
||||
|
||||
Hosted<Depgraph, Frame, Vbox, Frame, Block_devices_widget>
|
||||
_block_devices_widget { Id { "block_devices" },
|
||||
_storage_devices, _sculpt_partition };
|
||||
|
||||
Hosted<Depgraph, Frame, Vbox, Frame, Ahci_devices_widget>
|
||||
_ahci_devices_widget { Id { "ahci_devices" },
|
||||
_storage_devices, _sculpt_partition };
|
||||
@ -80,8 +76,6 @@ struct Sculpt::Graph : Widget<Depgraph>
|
||||
Start_name const &,
|
||||
Runtime_state::Info const &) const;
|
||||
|
||||
void _view_storage_node(Scope<Depgraph> &) const;
|
||||
|
||||
Graph(Runtime_state &runtime_state,
|
||||
Runtime_config const &runtime_config,
|
||||
Storage_devices const &storage_devices,
|
||||
@ -98,7 +92,7 @@ struct Sculpt::Graph : Widget<Depgraph>
|
||||
|
||||
void view(Scope<Depgraph> &) const;
|
||||
|
||||
struct Action : Storage_device_widget::Action
|
||||
struct Action : virtual Storage_device_widget::Action
|
||||
{
|
||||
virtual void remove_deployed_component(Start_name const &) = 0;
|
||||
virtual void restart_deployed_component(Start_name const &) = 0;
|
||||
@ -110,7 +104,6 @@ struct Sculpt::Graph : Widget<Depgraph>
|
||||
|
||||
void reset_storage_operation()
|
||||
{
|
||||
_block_devices_widget.reset_operation();
|
||||
_ahci_devices_widget.reset_operation();
|
||||
_nvme_devices_widget.reset_operation();
|
||||
_mmc_devices_widget.reset_operation();
|
||||
|
@ -58,7 +58,8 @@ namespace Sculpt { struct Main; }
|
||||
struct Sculpt::Main : Input_event_handler,
|
||||
Runtime_config_generator,
|
||||
Deploy::Action,
|
||||
Storage::Action,
|
||||
Storage_device::Action,
|
||||
Ram_fs_widget::Action,
|
||||
Network::Action,
|
||||
Network::Info,
|
||||
Graph::Action,
|
||||
@ -215,7 +216,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
*/
|
||||
void handle_device_plug_unplug() override
|
||||
{
|
||||
_handle_block_devices();
|
||||
_handle_storage_devices();
|
||||
network_config_changed();
|
||||
generate_runtime_config();
|
||||
}
|
||||
@ -246,49 +247,46 @@ struct Sculpt::Main : Input_event_handler,
|
||||
** Storage **
|
||||
*************/
|
||||
|
||||
Attached_rom_dataspace _block_devices_rom { _env, "report -> drivers/block_devices" };
|
||||
|
||||
Signal_handler<Main> _block_devices_handler {
|
||||
_env.ep(), *this, &Main::_handle_block_devices };
|
||||
|
||||
void _handle_block_devices()
|
||||
void _handle_storage_devices()
|
||||
{
|
||||
_block_devices_rom.update();
|
||||
Storage_target const orig_sculpt_partition = _storage._sculpt_partition;
|
||||
|
||||
_drivers.with_storage_devices([&] (Drivers::Storage_devices const &devices) {
|
||||
_storage.update(devices.usb, devices.ahci, devices.nvme, devices.mmc,
|
||||
_block_devices_rom.xml(),
|
||||
_block_devices_handler); });
|
||||
bool total_progress = false;
|
||||
for (bool progress = true; progress; total_progress |= progress) {
|
||||
progress = false;
|
||||
_drivers.with_storage_devices([&] (Drivers::Storage_devices const &devices) {
|
||||
progress = _storage.update(devices.usb, devices.ahci,
|
||||
devices.nvme, devices.mmc).progress; });
|
||||
|
||||
/* update USB policies for storage devices */
|
||||
_drivers.update_usb();
|
||||
/* update USB policies for storage devices */
|
||||
_drivers.update_usb();
|
||||
}
|
||||
|
||||
if (orig_sculpt_partition != _storage._sculpt_partition)
|
||||
_restart_from_storage_target();
|
||||
|
||||
if (total_progress) {
|
||||
generate_runtime_config();
|
||||
_generate_dialog();
|
||||
}
|
||||
}
|
||||
|
||||
Storage _storage { _env, _heap, _child_states, *this, *this };
|
||||
|
||||
|
||||
/**
|
||||
* Storage::Action interface
|
||||
* Storage_device::Action
|
||||
*/
|
||||
void use_storage_target(Storage_target const &target) override
|
||||
{
|
||||
_storage._sculpt_partition = target;
|
||||
void storage_device_discovered() override { _handle_storage_devices(); }
|
||||
|
||||
Storage _storage { _env, _heap, _child_states, *this };
|
||||
|
||||
void _restart_from_storage_target()
|
||||
{
|
||||
/* trigger loading of the configuration from the sculpt partition */
|
||||
_prepare_version.value++;
|
||||
|
||||
_download_queue.reset();
|
||||
_deploy.restart();
|
||||
|
||||
generate_runtime_config();
|
||||
_generate_dialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage::Action interface
|
||||
*/
|
||||
void refresh_storage_dialog() override { _generate_dialog(); }
|
||||
|
||||
|
||||
/*************
|
||||
** Network **
|
||||
@ -824,18 +822,20 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
/* refresh visibility of inspect tab */
|
||||
_panel_dialog.refresh();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void use(Storage_target const &target) override
|
||||
{
|
||||
_storage._sculpt_partition = target;
|
||||
_system_dialog.reset_update_widget();
|
||||
_download_queue.reset();
|
||||
_storage.use(target);
|
||||
|
||||
/* hide system panel button and system dialog when "un-using" */
|
||||
_panel_dialog.refresh();
|
||||
_system_dialog.refresh();
|
||||
_handle_window_layout();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void _reset_storage_dialog_operation()
|
||||
@ -844,38 +844,50 @@ struct Sculpt::Main : Input_event_handler,
|
||||
}
|
||||
|
||||
/*
|
||||
* Storage_widget::Action interface
|
||||
* Storage_device_widget::Action interface
|
||||
*/
|
||||
void format(Storage_target const &target) override
|
||||
{
|
||||
_storage.format(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void cancel_format(Storage_target const &target) override
|
||||
{
|
||||
_storage.cancel_format(target);
|
||||
_reset_storage_dialog_operation();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void expand(Storage_target const &target) override
|
||||
{
|
||||
_storage.expand(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void cancel_expand(Storage_target const &target) override
|
||||
{
|
||||
_storage.cancel_expand(target);
|
||||
_reset_storage_dialog_operation();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void check(Storage_target const &target) override
|
||||
{
|
||||
_storage.check(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void toggle_default_storage_target(Storage_target const &target) override
|
||||
{
|
||||
_storage.toggle_default_storage_target(target);
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
void reset_ram_fs() override
|
||||
{
|
||||
_storage.reset_ram_fs();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1425,7 +1437,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
}
|
||||
|
||||
void click(Clicked_at const &at) override { _main._graph.click(at, _main); }
|
||||
void clack(Clacked_at const &at) override { _main._graph.clack(at, _main, _main._storage); }
|
||||
void clack(Clacked_at const &at) override { _main._graph.clack(at, _main, _main); }
|
||||
void drag (Dragged_at const &) override { }
|
||||
|
||||
} _graph_dialog { *this };
|
||||
@ -1455,7 +1467,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_blueprint_rom .sigh(_blueprint_handler);
|
||||
_image_index_rom .sigh(_image_index_handler);
|
||||
_editor_saved_rom .sigh(_editor_saved_handler);
|
||||
_block_devices_rom .sigh(_block_devices_handler);
|
||||
|
||||
/*
|
||||
* Generate initial configurations
|
||||
@ -1467,7 +1478,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
* Import initial report content
|
||||
*/
|
||||
_handle_gui_mode();
|
||||
_handle_block_devices();
|
||||
_handle_storage_devices();
|
||||
_handle_runtime_config();
|
||||
|
||||
/*
|
||||
@ -1859,7 +1870,7 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
|
||||
device.for_each_partition([&] (Partition &partition) {
|
||||
|
||||
Storage_target const target { device.label, device.port, partition.number };
|
||||
Storage_target const target { device.driver, device.port, partition.number };
|
||||
|
||||
if (partition.check_in_progress) {
|
||||
String<64> name(target.label(), ".e2fsck");
|
||||
@ -1952,8 +1963,7 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
|
||||
/* handle failed initialization of USB-storage devices */
|
||||
_storage._storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device &dev) {
|
||||
String<64> name(dev.usb_block_drv_name());
|
||||
Child_exit_state exit_state(state, name);
|
||||
Child_exit_state exit_state(state, dev.driver);
|
||||
if (exit_state.exited) {
|
||||
dev.discard_usb_block_drv();
|
||||
reconfigure_runtime = true;
|
||||
@ -2031,7 +2041,7 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
reconfigure_runtime = true;
|
||||
|
||||
if (refresh_storage)
|
||||
_handle_block_devices();
|
||||
_handle_storage_devices();
|
||||
|
||||
if (regenerate_dialog) {
|
||||
_generate_dialog();
|
||||
|
@ -41,11 +41,10 @@ struct Sculpt::Ahci_device : List_model<Ahci_device>::Element, Storage_device
|
||||
* node.attribute_value("block_count", 0ULL) };
|
||||
}
|
||||
|
||||
Ahci_device(Env &env, Allocator &alloc, Signal_context_capability sigh,
|
||||
Xml_node const &node)
|
||||
Ahci_device(Env &env, Allocator &alloc, Xml_node const &node,
|
||||
Storage_device::Action &action)
|
||||
:
|
||||
Storage_device(env, alloc, Storage_device::Provider::RUNTIME,
|
||||
"ahci", _port(node), _capacity(node), sigh),
|
||||
Storage_device(env, alloc, "ahci", _port(node), _capacity(node), action),
|
||||
model(node.attribute_value("model", Model()))
|
||||
{ }
|
||||
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* \brief Representation of AHCI and NVMe devices
|
||||
* \author Norman Feske
|
||||
* \date 2018-04-30
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _MODEL__BLOCK_DEVICE_H_
|
||||
#define _MODEL__BLOCK_DEVICE_H_
|
||||
|
||||
#include "storage_device.h"
|
||||
|
||||
namespace Sculpt {
|
||||
|
||||
struct Block_device;
|
||||
struct Block_device_update_policy;
|
||||
|
||||
typedef List_model<Block_device> Block_devices;
|
||||
};
|
||||
|
||||
|
||||
struct Sculpt::Block_device : List_model<Block_device>::Element,
|
||||
Storage_device
|
||||
{
|
||||
typedef String<16> Model;
|
||||
|
||||
Model const model;
|
||||
|
||||
Block_device(Env &env, Allocator &alloc, Signal_context_capability sigh,
|
||||
Label const &label, Model const &model, Capacity capacity)
|
||||
:
|
||||
Storage_device(env, alloc, Storage_device::Provider::PARENT,
|
||||
label, Port { }, capacity, sigh), model(model)
|
||||
{ }
|
||||
|
||||
bool matches(Xml_node const &node) const
|
||||
{
|
||||
return node.attribute_value("label", Block_device::Label()) == label;
|
||||
}
|
||||
|
||||
static bool type_matches(Xml_node const &) { return true; }
|
||||
};
|
||||
|
||||
#endif /* _MODEL__BLOCK_DEVICE_H_ */
|
@ -36,10 +36,6 @@ struct Sculpt::Discovery_state
|
||||
if (_done)
|
||||
return Storage_target { };
|
||||
|
||||
/* defer decision until the low-level device enumeration is complete */
|
||||
if (!devices.all_devices_enumerated())
|
||||
return Storage_target { };
|
||||
|
||||
/*
|
||||
* As long as not all devices are completely known, it is too early to
|
||||
* take a decision.
|
||||
@ -56,33 +52,47 @@ struct Sculpt::Discovery_state
|
||||
* Search for a partition with the magic label "GENODE*", or - if no
|
||||
* such partition is present - a whole-device file system.
|
||||
*
|
||||
* Prefer USB storage devices over block devices. If no partition with
|
||||
* the magic label is present but a block device that is formatted as
|
||||
* a file system (the Sculpt EA way), this block device is selected.
|
||||
* Prefer USB storage devices over other block devices. If no partition
|
||||
* with the magic label is present but the block device is formatted
|
||||
* as a file system, this block device is selected. USB sticks with
|
||||
* no partition table are not considered as storage target.
|
||||
*/
|
||||
|
||||
Storage_target target { };
|
||||
|
||||
auto check_partitions = [&] (Storage_device const &device) {
|
||||
|
||||
device.for_each_partition([&] (Partition const &partition) {
|
||||
if (!partition.whole_device()
|
||||
&& partition.label == "GENODE*"
|
||||
&& partition.file_system.accessible())
|
||||
target = Storage_target { device.label, device.port, partition.number }; });
|
||||
target = Storage_target { device.driver, device.port, partition.number }; });
|
||||
};
|
||||
|
||||
if (!target.valid())
|
||||
devices.usb_storage_devices.for_each([&] (Storage_device const &device) {
|
||||
check_partitions(device); });
|
||||
|
||||
if (!target.valid())
|
||||
devices.block_devices.for_each([&] (Storage_device const &device) {
|
||||
auto try_discover_target = [&] (auto const &devices)
|
||||
{
|
||||
if (target.valid())
|
||||
return;
|
||||
|
||||
devices.for_each([&] (Storage_device const &device) {
|
||||
check_partitions(device); });
|
||||
|
||||
if (!target.valid())
|
||||
devices.block_devices.for_each([&] (Storage_device const &device) {
|
||||
if (target.valid())
|
||||
return;
|
||||
|
||||
devices.for_each([&] (Storage_device const &device) {
|
||||
if (device.whole_device
|
||||
&& device.whole_device_partition->file_system.accessible())
|
||||
target = Storage_target { device.label, device.port, Partition::Number() }; });
|
||||
target = Storage_target { device.driver, device.port, Partition::Number() }; });
|
||||
};
|
||||
|
||||
try_discover_target(devices.ahci_devices);
|
||||
try_discover_target(devices.nvme_devices);
|
||||
try_discover_target(devices.mmc_devices);
|
||||
|
||||
if (target.valid())
|
||||
_done = true;
|
||||
|
@ -41,11 +41,10 @@ struct Sculpt::Mmc_device : List_model<Mmc_device>::Element, Storage_device
|
||||
* node.attribute_value("block_count", 0ULL) };
|
||||
}
|
||||
|
||||
Mmc_device(Env &env, Allocator &alloc, Signal_context_capability sigh,
|
||||
Xml_node const &node)
|
||||
Mmc_device(Env &env, Allocator &alloc, Xml_node const &node,
|
||||
Storage_device::Action &action)
|
||||
:
|
||||
Storage_device(env, alloc, Storage_device::Provider::RUNTIME,
|
||||
"mmc", _port(node), _capacity(node), sigh),
|
||||
Storage_device(env, alloc, "mmc", _port(node), _capacity(node), action),
|
||||
model(node.attribute_value("model", Model()))
|
||||
{ }
|
||||
|
||||
|
@ -41,11 +41,10 @@ struct Sculpt::Nvme_device : List_model<Nvme_device>::Element, Storage_device
|
||||
* node.attribute_value("block_count", 0ULL) };
|
||||
}
|
||||
|
||||
Nvme_device(Env &env, Allocator &alloc, Signal_context_capability sigh,
|
||||
Model const &model, Xml_node const &node)
|
||||
Nvme_device(Env &env, Allocator &alloc, Model const &model, Xml_node const &node,
|
||||
Storage_device::Action &action)
|
||||
:
|
||||
Storage_device(env, alloc, Storage_device::Provider::RUNTIME,
|
||||
"nvme", _port(node), _capacity(node), sigh),
|
||||
Storage_device(env, alloc, "nvme", _port(node), _capacity(node), action),
|
||||
model(model)
|
||||
{ }
|
||||
|
||||
|
@ -30,26 +30,30 @@ struct Sculpt::Storage_device
|
||||
FAILED /* driver failed to access the device */
|
||||
};
|
||||
|
||||
Allocator &_alloc;
|
||||
|
||||
enum class Provider { PARENT, RUNTIME };
|
||||
|
||||
using Label = String<32>;
|
||||
using Port = String<8>;
|
||||
|
||||
Provider const provider;
|
||||
Label const label; /* driver name, or label of parent session */
|
||||
Port const port;
|
||||
|
||||
Label name() const
|
||||
struct Action : Interface
|
||||
{
|
||||
return port.valid() ? Start_name { label, "-", port }
|
||||
: Start_name { label };
|
||||
virtual void storage_device_discovered() = 0;
|
||||
};
|
||||
|
||||
Env &_env;
|
||||
Allocator &_alloc;
|
||||
Action &_action;
|
||||
|
||||
using Driver = String<32>;
|
||||
using Port = String<8>;
|
||||
|
||||
Driver const driver;
|
||||
Port const port;
|
||||
|
||||
Start_name name() const
|
||||
{
|
||||
return port.valid() ? Start_name { driver, "-", port }
|
||||
: Start_name { driver };
|
||||
}
|
||||
|
||||
Start_name part_block_start_name() const { return { name(), ".part" }; }
|
||||
Start_name relabel_start_name() const { return { name(), ".relabel" }; }
|
||||
Start_name expand_start_name() const { return { name(), ".expand" }; }
|
||||
Start_name part_block_start_name() const { return { name(), ".part" }; }
|
||||
Start_name relabel_start_name() const { return { name(), ".relabel" }; }
|
||||
Start_name expand_start_name() const { return { name(), ".expand" }; }
|
||||
|
||||
Capacity capacity; /* non-const because USB storage devices need to update it */
|
||||
|
||||
@ -62,7 +66,11 @@ struct Sculpt::Storage_device
|
||||
|
||||
Partitions partitions { };
|
||||
|
||||
Attached_rom_dataspace _partitions_rom;
|
||||
Attached_rom_dataspace _partitions {
|
||||
_env, String<80>("report -> runtime/", part_block_start_name(), "/partitions").string() };
|
||||
|
||||
Signal_handler<Storage_device> _partitions_handler {
|
||||
_env.ep(), *this, &Storage_device::_handle_partitions };
|
||||
|
||||
unsigned _part_block_version = 0;
|
||||
|
||||
@ -94,11 +102,15 @@ struct Sculpt::Storage_device
|
||||
_update_partitions_from_xml(Xml_node("<partitions/>"));
|
||||
}
|
||||
|
||||
void process_part_block_report()
|
||||
void _handle_partitions()
|
||||
{
|
||||
_partitions_rom.update();
|
||||
_partitions.update();
|
||||
_action.storage_device_discovered();
|
||||
}
|
||||
|
||||
Xml_node const report = _partitions_rom.xml();
|
||||
void process_partitions()
|
||||
{
|
||||
Xml_node const report = _partitions.xml();
|
||||
if (!report.has_type("partitions"))
|
||||
return;
|
||||
|
||||
@ -125,21 +137,14 @@ struct Sculpt::Storage_device
|
||||
state = RELEASED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param label label of block device at parent, or driver name
|
||||
* \param sigh signal handler to be notified on partition-info updates
|
||||
*/
|
||||
Storage_device(Env &env, Allocator &alloc, Provider provider,
|
||||
Label const &label, Port const &port,
|
||||
Capacity capacity, Signal_context_capability sigh)
|
||||
Storage_device(Env &env, Allocator &alloc, Driver const &driver,
|
||||
Port const &port, Capacity capacity, Action &action)
|
||||
:
|
||||
_alloc(alloc), provider(provider), label(label), port(port), capacity(capacity),
|
||||
_partitions_rom(env, String<80>("report -> runtime/", part_block_start_name(), "/partitions").string())
|
||||
_env(env), _alloc(alloc), _action(action),
|
||||
driver(driver), port(port), capacity(capacity)
|
||||
{
|
||||
_partitions_rom.sigh(sigh);
|
||||
process_part_block_report();
|
||||
_partitions.sigh(_partitions_handler);
|
||||
_partitions_handler.local_submit();
|
||||
}
|
||||
|
||||
~Storage_device()
|
||||
@ -255,13 +260,8 @@ void Sculpt::Storage_device::gen_part_block_start_content(Xml_generator &xml) co
|
||||
xml.node("route", [&] {
|
||||
|
||||
gen_service_node<Block::Session>(xml, [&] {
|
||||
if (provider == Provider::PARENT)
|
||||
xml.node("parent", [&] {
|
||||
xml.attribute("label", label); });
|
||||
else
|
||||
gen_named_node(xml, "child", label, [&] {
|
||||
xml.attribute("label", port); });
|
||||
});
|
||||
gen_named_node(xml, "child", driver, [&] {
|
||||
xml.attribute("label", port); }); });
|
||||
|
||||
gen_parent_rom_route(xml, "part_block");
|
||||
gen_parent_rom_route(xml, "ld.lib.so");
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define _MODEL__STORAGE_DEVICES_
|
||||
|
||||
#include <types.h>
|
||||
#include <model/block_device.h>
|
||||
#include <model/ahci_device.h>
|
||||
#include <model/nvme_device.h>
|
||||
#include <model/mmc_device.h>
|
||||
@ -24,58 +23,32 @@
|
||||
namespace Sculpt { struct Storage_devices; }
|
||||
|
||||
|
||||
struct Sculpt::Storage_devices
|
||||
struct Sculpt::Storage_devices : Noncopyable
|
||||
{
|
||||
Block_devices block_devices { };
|
||||
Storage_device::Action &_action;
|
||||
|
||||
Storage_devices(Storage_device::Action &action) : _action(action) { }
|
||||
|
||||
Ahci_devices ahci_devices { };
|
||||
Nvme_devices nvme_devices { };
|
||||
Mmc_devices mmc_devices { };
|
||||
Usb_storage_devices usb_storage_devices { };
|
||||
|
||||
bool _block_devices_report_valid = false;
|
||||
bool _usb_active_config_valid = false;
|
||||
struct Discovered { bool ahci, nvme, mmc, usb; } _discovered { };
|
||||
|
||||
bool usb_present = false;
|
||||
unsigned num_usb_devices = 0;
|
||||
|
||||
/**
|
||||
* Update 'block_devices' from 'block_devices' report
|
||||
*/
|
||||
void update_block_devices_from_xml(Env &env, Allocator &alloc, Xml_node node,
|
||||
Signal_context_capability sigh)
|
||||
Progress update_ahci(Env &env, Allocator &alloc, Xml_node const &node)
|
||||
{
|
||||
block_devices.update_from_xml(node,
|
||||
_discovered.ahci |= (!node.has_type("empty"));
|
||||
|
||||
/* create */
|
||||
[&] (Xml_node const &node) -> Block_device & {
|
||||
return *new (alloc)
|
||||
Block_device(env, alloc, sigh,
|
||||
node.attribute_value("label", Block_device::Label()),
|
||||
node.attribute_value("model", Block_device::Model()),
|
||||
Capacity { node.attribute_value("block_size", 0ULL)
|
||||
* node.attribute_value("block_count", 0ULL) });
|
||||
},
|
||||
|
||||
/* destroy */
|
||||
[&] (Block_device &b) { destroy(alloc, &b); },
|
||||
|
||||
/* update */
|
||||
[&] (Block_device &, Xml_node const &) { }
|
||||
);
|
||||
|
||||
if (node.has_type("block_devices"))
|
||||
_block_devices_report_valid = true;
|
||||
}
|
||||
|
||||
bool update_ahci_devices_from_xml(Env &env, Allocator &alloc, Xml_node node,
|
||||
Signal_context_capability sigh)
|
||||
{
|
||||
bool progress = false;
|
||||
ahci_devices.update_from_xml(node,
|
||||
|
||||
/* create */
|
||||
[&] (Xml_node const &node) -> Ahci_device & {
|
||||
progress = true;
|
||||
return *new (alloc) Ahci_device(env, alloc, sigh, node);
|
||||
return *new (alloc) Ahci_device(env, alloc, node, _action);
|
||||
},
|
||||
|
||||
/* destroy */
|
||||
@ -87,12 +60,13 @@ struct Sculpt::Storage_devices
|
||||
/* update */
|
||||
[&] (Ahci_device &, Xml_node const &) { }
|
||||
);
|
||||
return progress;
|
||||
return { progress };
|
||||
}
|
||||
|
||||
bool update_nvme_devices_from_xml(Env &env, Allocator &alloc, Xml_node node,
|
||||
Signal_context_capability sigh)
|
||||
Progress update_nvme(Env &env, Allocator &alloc, Xml_node const &node)
|
||||
{
|
||||
_discovered.nvme |= !node.has_type("empty");
|
||||
|
||||
auto const model = node.attribute_value("model", Nvme_device::Model());
|
||||
|
||||
bool progress = false;
|
||||
@ -101,7 +75,7 @@ struct Sculpt::Storage_devices
|
||||
/* create */
|
||||
[&] (Xml_node const &node) -> Nvme_device & {
|
||||
progress = true;
|
||||
return *new (alloc) Nvme_device(env, alloc, sigh, model, node);
|
||||
return *new (alloc) Nvme_device(env, alloc, model, node, _action);
|
||||
},
|
||||
|
||||
/* destroy */
|
||||
@ -113,19 +87,20 @@ struct Sculpt::Storage_devices
|
||||
/* update */
|
||||
[&] (Nvme_device &, Xml_node const &) { }
|
||||
);
|
||||
return progress;
|
||||
return { progress };
|
||||
}
|
||||
|
||||
bool update_mmc_devices_from_xml(Env &env, Allocator &alloc, Xml_node node,
|
||||
Signal_context_capability sigh)
|
||||
Progress update_mmc(Env &env, Allocator &alloc, Xml_node const &node)
|
||||
{
|
||||
_discovered.mmc |= !node.has_type("empty");
|
||||
|
||||
bool progress = false;
|
||||
mmc_devices.update_from_xml(node,
|
||||
|
||||
/* create */
|
||||
[&] (Xml_node const &node) -> Mmc_device & {
|
||||
progress = true;
|
||||
return *new (alloc) Mmc_device(env, alloc, sigh, node);
|
||||
return *new (alloc) Mmc_device(env, alloc, node, _action);
|
||||
},
|
||||
|
||||
/* destroy */
|
||||
@ -137,7 +112,7 @@ struct Sculpt::Storage_devices
|
||||
/* update */
|
||||
[&] (Mmc_device &, Xml_node const &) { }
|
||||
);
|
||||
return progress;
|
||||
return { progress };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,29 +120,24 @@ struct Sculpt::Storage_devices
|
||||
*
|
||||
* \return true if USB storage device was added or vanished
|
||||
*/
|
||||
bool update_usb_storage_devices_from_xml(Env &env, Allocator &alloc, Xml_node node,
|
||||
Signal_context_capability sigh)
|
||||
Progress update_usb(Env &env, Allocator &alloc, Xml_node const &node)
|
||||
{
|
||||
using Label = Usb_storage_device::Label;
|
||||
|
||||
bool device_added_or_vanished = false;
|
||||
_discovered.usb |= !node.has_type("empty");
|
||||
|
||||
bool progress = false;
|
||||
usb_storage_devices.update_from_xml(node,
|
||||
|
||||
/* create */
|
||||
[&] (Xml_node const &node) -> Usb_storage_device &
|
||||
{
|
||||
device_added_or_vanished = true;
|
||||
|
||||
return *new (alloc)
|
||||
Usb_storage_device(env, alloc, sigh,
|
||||
node.attribute_value("name", Label()));
|
||||
progress = true;
|
||||
return *new (alloc) Usb_storage_device(env, alloc, node, _action);
|
||||
},
|
||||
|
||||
/* destroy */
|
||||
[&] (Usb_storage_device &elem)
|
||||
{
|
||||
device_added_or_vanished = true;
|
||||
progress = true;
|
||||
destroy(alloc, &elem);
|
||||
},
|
||||
|
||||
@ -175,13 +145,11 @@ struct Sculpt::Storage_devices
|
||||
[&] (Usb_storage_device &, Xml_node const &) { }
|
||||
);
|
||||
|
||||
_usb_active_config_valid = true;
|
||||
|
||||
usb_present = false;
|
||||
num_usb_devices = 0;
|
||||
usb_storage_devices.for_each([&] (Storage_device const &) {
|
||||
usb_present = true; });
|
||||
num_usb_devices++; });
|
||||
|
||||
return device_added_or_vanished;
|
||||
return { progress };
|
||||
}
|
||||
|
||||
void gen_usb_storage_policies(Xml_generator &xml) const
|
||||
@ -190,18 +158,8 @@ struct Sculpt::Storage_devices
|
||||
device.gen_usb_policy(xml); });
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true as soon as the storage-device information from the drivers
|
||||
* subsystem is complete.
|
||||
*/
|
||||
bool all_devices_enumerated() const
|
||||
{
|
||||
return _block_devices_report_valid && _usb_active_config_valid;
|
||||
}
|
||||
|
||||
void for_each(auto const &fn) const
|
||||
{
|
||||
block_devices .for_each([&] (Storage_device const &dev) { fn(dev); });
|
||||
ahci_devices .for_each([&] (Storage_device const &dev) { fn(dev); });
|
||||
nvme_devices .for_each([&] (Storage_device const &dev) { fn(dev); });
|
||||
mmc_devices .for_each([&] (Storage_device const &dev) { fn(dev); });
|
||||
@ -210,7 +168,6 @@ struct Sculpt::Storage_devices
|
||||
|
||||
void for_each(auto const &fn)
|
||||
{
|
||||
block_devices .for_each([&] (Storage_device &dev) { fn(dev); });
|
||||
ahci_devices .for_each([&] (Storage_device &dev) { fn(dev); });
|
||||
nvme_devices .for_each([&] (Storage_device &dev) { fn(dev); });
|
||||
mmc_devices .for_each([&] (Storage_device &dev) { fn(dev); });
|
||||
|
@ -22,26 +22,26 @@ namespace Sculpt { struct Storage_target; }
|
||||
|
||||
struct Sculpt::Storage_target
|
||||
{
|
||||
using Label = String<Storage_device::Label::capacity() + 5>;
|
||||
using Label = String<Storage_device::Driver::capacity() + 5>;
|
||||
|
||||
Storage_device::Label device;
|
||||
Storage_device::Port port;
|
||||
Partition::Number partition;
|
||||
Storage_device::Driver driver;
|
||||
Storage_device::Port port;
|
||||
Partition::Number partition;
|
||||
|
||||
bool operator == (Storage_target const &other) const
|
||||
{
|
||||
return (device == other.device)
|
||||
return (driver == other.driver)
|
||||
&& (port == other.port)
|
||||
&& (partition == other.partition);
|
||||
}
|
||||
|
||||
bool operator != (Storage_target const &other) const { return !(*this == other); }
|
||||
|
||||
bool valid() const { return device.valid(); }
|
||||
bool valid() const { return driver.valid(); }
|
||||
|
||||
Label device_and_port() const
|
||||
Label driver_and_port() const
|
||||
{
|
||||
return port.valid() ? Label { device, "-", port } : Label { device };
|
||||
return port.valid() ? Label { driver, "-", port } : Label { driver };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,42 +49,32 @@ struct Sculpt::Storage_target
|
||||
*/
|
||||
Label label() const
|
||||
{
|
||||
return partition.valid() ? Label(device_and_port(), ".", partition)
|
||||
: Label(device_and_port());
|
||||
return partition.valid() ? Label(driver_and_port(), ".", partition)
|
||||
: Label(driver_and_port());
|
||||
}
|
||||
|
||||
bool ram_fs() const { return device == "ram_fs"; }
|
||||
bool ram_fs() const { return driver == "ram_fs"; }
|
||||
|
||||
Label fs() const { return ram_fs() ? label() : Label(label(), ".fs"); }
|
||||
|
||||
void gen_block_session_route(Xml_generator &xml) const
|
||||
{
|
||||
bool const usb = (Label(Cstring(device.string(), 3)) == "usb");
|
||||
bool const ahci = (Label(Cstring(device.string(), 4)) == "ahci");
|
||||
bool const nvme = (Label(Cstring(device.string(), 4)) == "nvme");
|
||||
bool const mmc = (Label(Cstring(device.string(), 3)) == "mmc");
|
||||
|
||||
bool const whole_device = !partition.valid();
|
||||
|
||||
xml.node("service", [&] {
|
||||
xml.attribute("name", Block::Session::service_name());
|
||||
|
||||
if (whole_device) {
|
||||
|
||||
if (usb || ahci || nvme || mmc)
|
||||
xml.node("child", [&] {
|
||||
xml.attribute("name", device);
|
||||
if (port.valid())
|
||||
xml.attribute("label", port);
|
||||
});
|
||||
else
|
||||
xml.node("parent", [&] { xml.attribute("label", device); });
|
||||
xml.node("child", [&] {
|
||||
xml.attribute("name", driver);
|
||||
if (port.valid())
|
||||
xml.attribute("label", port); });
|
||||
}
|
||||
|
||||
/* access partition */
|
||||
else {
|
||||
xml.node("child", [&] {
|
||||
xml.attribute("name", Label(device_and_port(), ".part"));
|
||||
xml.attribute("name", Label(driver_and_port(), ".part"));
|
||||
xml.attribute("label", partition);
|
||||
});
|
||||
}
|
||||
|
@ -46,21 +46,31 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
|
||||
{ }
|
||||
};
|
||||
|
||||
Env &_env;
|
||||
|
||||
/* information provided asynchronously by usb_block_drv */
|
||||
Constructible<Driver_info> driver_info { };
|
||||
|
||||
Attached_rom_dataspace _driver_report_rom;
|
||||
Attached_rom_dataspace _report {
|
||||
_env, String<80>("report -> runtime/", driver, "/devices").string() };
|
||||
|
||||
void process_driver_report()
|
||||
Signal_handler<Usb_storage_device> _report_handler {
|
||||
_env.ep(), *this, &Usb_storage_device::_handle_report };
|
||||
|
||||
void _handle_report()
|
||||
{
|
||||
_driver_report_rom.update();
|
||||
_report.update();
|
||||
_action.storage_device_discovered();
|
||||
}
|
||||
|
||||
Xml_node report = _driver_report_rom.xml();
|
||||
void process_report()
|
||||
{
|
||||
Xml_node report = _report.xml();
|
||||
|
||||
if (!report.has_sub_node("device"))
|
||||
return;
|
||||
|
||||
Xml_node device = report.sub_node("device");
|
||||
Xml_node const device = report.sub_node("device");
|
||||
|
||||
capacity = Capacity { device.attribute_value("block_count", 0ULL)
|
||||
* device.attribute_value("block_size", 0ULL) };
|
||||
@ -102,18 +112,19 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
|
||||
|
||||
bool discarded() const { return Storage_device::state == FAILED; }
|
||||
|
||||
Label usb_block_drv_name() const { return label; }
|
||||
|
||||
Usb_storage_device(Env &env, Allocator &alloc, Signal_context_capability sigh,
|
||||
Label const &label)
|
||||
:
|
||||
Storage_device(env, alloc, Storage_device::Provider::RUNTIME, label,
|
||||
Port { }, Capacity{0}, sigh),
|
||||
_driver_report_rom(env, String<80>("report -> runtime/", usb_block_drv_name(),
|
||||
"/devices").string())
|
||||
static Driver _driver(Xml_node const &node)
|
||||
{
|
||||
_driver_report_rom.sigh(sigh);
|
||||
process_driver_report();
|
||||
return node.attribute_value("name", Driver());
|
||||
}
|
||||
|
||||
Usb_storage_device(Env &env, Allocator &alloc, Xml_node const &node,
|
||||
Storage_device::Action &action)
|
||||
:
|
||||
Storage_device(env, alloc, _driver(node), Port { }, Capacity{0}, action),
|
||||
_env(env)
|
||||
{
|
||||
_report.sigh(_report_handler);
|
||||
_report_handler.local_submit();
|
||||
}
|
||||
|
||||
inline void gen_usb_block_drv_start_content(Xml_generator &xml) const;
|
||||
@ -121,9 +132,9 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
|
||||
void gen_usb_policy(Xml_generator &xml) const
|
||||
{
|
||||
xml.node("policy", [&] {
|
||||
xml.attribute("label_prefix", label);
|
||||
xml.attribute("label_prefix", driver);
|
||||
xml.node("device", [&] {
|
||||
xml.attribute("name", label); }); });
|
||||
xml.attribute("name", driver); }); });
|
||||
}
|
||||
|
||||
static bool type_matches(Xml_node const &device)
|
||||
@ -137,17 +148,13 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
|
||||
return storage_device;
|
||||
}
|
||||
|
||||
bool matches(Xml_node node) const
|
||||
{
|
||||
return node.attribute_value("name", Label()) == label;
|
||||
}
|
||||
bool matches(Xml_node node) const { return _driver(node) == driver; }
|
||||
};
|
||||
|
||||
|
||||
void Sculpt::Usb_storage_device::gen_usb_block_drv_start_content(Xml_generator &xml) const
|
||||
{
|
||||
gen_common_start_content(xml, usb_block_drv_name(),
|
||||
Cap_quota{100}, Ram_quota{6*1024*1024},
|
||||
gen_common_start_content(xml, driver, Cap_quota{100}, Ram_quota{6*1024*1024},
|
||||
Priority::STORAGE);
|
||||
|
||||
gen_named_node(xml, "binary", "usb_block_drv");
|
||||
|
@ -40,7 +40,7 @@ void Sculpt::_gen_gpt_write_start_content(Xml_generator &xml,
|
||||
|
||||
xml.node("route", [&] {
|
||||
|
||||
Storage_target const target { device.label, device.port, Partition::Number { } };
|
||||
Storage_target const target { device.driver, device.port, Partition::Number { } };
|
||||
target.gen_block_session_route(xml);
|
||||
|
||||
gen_parent_rom_route(xml, "gpt_write");
|
||||
|
@ -21,7 +21,7 @@ static void for_each_inspected_storage_target(Storage_devices const &devices, au
|
||||
devices.for_each([&] (Storage_device const &device) {
|
||||
device.for_each_partition([&] (Partition const &partition) {
|
||||
if (partition.file_system.inspected)
|
||||
fn(Storage_target { device.label, device.port, partition.number }); }); });
|
||||
fn(Storage_target { device.driver, device.port, partition.number }); }); });
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,84 +14,44 @@
|
||||
/* local includes */
|
||||
#include <storage.h>
|
||||
|
||||
using namespace Sculpt;
|
||||
|
||||
void Sculpt::Storage::update(Xml_node const &usb_devices,
|
||||
Xml_node const &ahci_ports,
|
||||
Xml_node const &nvme_namespaces,
|
||||
Xml_node const &mmc_devices,
|
||||
Xml_node const &block_devices,
|
||||
Signal_context_capability sigh)
|
||||
|
||||
Progress Storage::update(Xml_node const &usb, Xml_node const &ahci,
|
||||
Xml_node const &nvme, Xml_node const &mmc)
|
||||
{
|
||||
bool reconfigure_runtime = false;
|
||||
bool progress = false;
|
||||
|
||||
auto process_part_block_report = [&] (Storage_device &dev)
|
||||
{
|
||||
progress |= _storage_devices.update_ahci(_env, _alloc, ahci).progress;
|
||||
progress |= _storage_devices.update_nvme(_env, _alloc, nvme).progress;
|
||||
progress |= _storage_devices.update_mmc (_env, _alloc, mmc) .progress;
|
||||
progress |= _storage_devices.update_usb (_env, _alloc, usb) .progress;
|
||||
|
||||
_storage_devices.for_each([&] (Storage_device &dev) {
|
||||
Storage_device::State const orig_state = dev.state;
|
||||
dev.process_partitions();
|
||||
progress |= (dev.state != orig_state);
|
||||
});
|
||||
|
||||
dev.process_part_block_report();
|
||||
|
||||
if (dev.state != orig_state
|
||||
|| dev.state == Storage_device::UNKNOWN)
|
||||
reconfigure_runtime = true;
|
||||
};
|
||||
|
||||
{
|
||||
reconfigure_runtime |=
|
||||
_storage_devices.update_ahci_devices_from_xml(_env, _alloc, ahci_ports,
|
||||
sigh);
|
||||
|
||||
_storage_devices.ahci_devices.for_each([&] (Ahci_device &dev) {
|
||||
process_part_block_report(dev); });
|
||||
}
|
||||
|
||||
{
|
||||
reconfigure_runtime |=
|
||||
_storage_devices.update_nvme_devices_from_xml(_env, _alloc, nvme_namespaces,
|
||||
sigh);
|
||||
|
||||
_storage_devices.nvme_devices.for_each([&] (Nvme_device &dev) {
|
||||
process_part_block_report(dev); });
|
||||
}
|
||||
|
||||
{
|
||||
reconfigure_runtime |=
|
||||
_storage_devices.update_mmc_devices_from_xml(_env, _alloc, mmc_devices,
|
||||
sigh);
|
||||
|
||||
_storage_devices.mmc_devices.for_each([&] (Mmc_device &dev) {
|
||||
process_part_block_report(dev); });
|
||||
}
|
||||
|
||||
{
|
||||
_storage_devices.update_block_devices_from_xml(_env, _alloc, block_devices,
|
||||
sigh);
|
||||
|
||||
_storage_devices.block_devices.for_each([&] (Block_device &dev) {
|
||||
process_part_block_report(dev); });
|
||||
}
|
||||
|
||||
{
|
||||
bool const usb_storage_added_or_vanished =
|
||||
_storage_devices.update_usb_storage_devices_from_xml(_env, _alloc,
|
||||
usb_devices,
|
||||
sigh);
|
||||
|
||||
if (usb_storage_added_or_vanished)
|
||||
reconfigure_runtime = true;
|
||||
|
||||
_storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device &dev) {
|
||||
dev.process_driver_report();
|
||||
process_part_block_report(dev);
|
||||
});
|
||||
}
|
||||
_storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device &dev) {
|
||||
dev.process_report(); });
|
||||
|
||||
if (!_sculpt_partition.valid()) {
|
||||
|
||||
Storage_target const default_target =
|
||||
_discovery_state.detect_default_target(_storage_devices);
|
||||
bool const all_devices_enumerated = !usb .has_type("empty")
|
||||
&& !ahci.has_type("empty")
|
||||
&& !nvme.has_type("empty")
|
||||
&& !mmc .has_type("empty");
|
||||
if (all_devices_enumerated) {
|
||||
|
||||
if (default_target.valid())
|
||||
use(default_target);
|
||||
Storage_target const default_target =
|
||||
_discovery_state.detect_default_target(_storage_devices);
|
||||
|
||||
if (default_target.valid()) {
|
||||
_sculpt_partition = default_target;
|
||||
progress |= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -99,7 +59,7 @@ void Sculpt::Storage::update(Xml_node const &usb_devices,
|
||||
* the '_sculpt_partition' to enable the selection of another storage
|
||||
* target to use.
|
||||
*/
|
||||
if (_sculpt_partition.valid()) {
|
||||
else if (_sculpt_partition.valid()) {
|
||||
|
||||
bool sculpt_partition_exists = false;
|
||||
|
||||
@ -108,24 +68,22 @@ void Sculpt::Storage::update(Xml_node const &usb_devices,
|
||||
|
||||
_storage_devices.for_each([&] (Storage_device const &device) {
|
||||
device.for_each_partition([&] (Partition const &partition) {
|
||||
if (device.label == _sculpt_partition.device
|
||||
if (device.driver == _sculpt_partition.driver
|
||||
&& partition.number == _sculpt_partition.partition)
|
||||
sculpt_partition_exists = true; }); });
|
||||
|
||||
if (!sculpt_partition_exists) {
|
||||
warning("sculpt partition unexpectedly vanished");
|
||||
_sculpt_partition = Storage_target { };
|
||||
progress |= true;
|
||||
}
|
||||
}
|
||||
|
||||
_action.refresh_storage_dialog();
|
||||
|
||||
if (reconfigure_runtime)
|
||||
_runtime.generate_runtime_config();
|
||||
return { progress };
|
||||
}
|
||||
|
||||
|
||||
void Sculpt::Storage::gen_runtime_start_nodes(Xml_generator &xml) const
|
||||
void Storage::gen_runtime_start_nodes(Xml_generator &xml) const
|
||||
{
|
||||
xml.node("start", [&] {
|
||||
gen_ram_fs_start_content(xml, _ram_fs_state); });
|
||||
@ -135,11 +93,8 @@ void Sculpt::Storage::gen_runtime_start_nodes(Xml_generator &xml) const
|
||||
if (!_sculpt_partition.valid())
|
||||
return false;
|
||||
|
||||
if (device.provider == Storage_device::Provider::PARENT)
|
||||
return (device.label == _sculpt_partition.device);
|
||||
|
||||
return (device.port == _sculpt_partition.port)
|
||||
&& (device.label == _sculpt_partition.device);
|
||||
return (device.port == _sculpt_partition.port)
|
||||
&& (device.driver == _sculpt_partition.driver);
|
||||
};
|
||||
|
||||
_storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device const &device) {
|
||||
@ -163,7 +118,7 @@ void Sculpt::Storage::gen_runtime_start_nodes(Xml_generator &xml) const
|
||||
|
||||
device.for_each_partition([&] (Partition const &partition) {
|
||||
|
||||
Storage_target const target { .device = device.label,
|
||||
Storage_target const target { .driver = device.driver,
|
||||
.port = device.port,
|
||||
.partition = partition.number };
|
||||
|
||||
|
@ -14,36 +14,20 @@
|
||||
#ifndef _STORAGE_H_
|
||||
#define _STORAGE_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/reporter.h>
|
||||
|
||||
/* local includes */
|
||||
#include <model/discovery_state.h>
|
||||
#include <view/storage_widget.h>
|
||||
#include <view/ram_fs_widget.h>
|
||||
#include <runtime.h>
|
||||
|
||||
namespace Sculpt { struct Storage; }
|
||||
|
||||
|
||||
struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
struct Sculpt::Storage : Noncopyable
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
Allocator &_alloc;
|
||||
|
||||
struct Action : Interface
|
||||
{
|
||||
virtual void use_storage_target(Storage_target const &) = 0;
|
||||
virtual void refresh_storage_dialog() = 0;
|
||||
};
|
||||
|
||||
Action &_action;
|
||||
|
||||
Runtime_config_generator &_runtime;
|
||||
|
||||
Storage_devices _storage_devices { };
|
||||
Storage_devices _storage_devices;
|
||||
|
||||
Ram_fs_state _ram_fs_state;
|
||||
|
||||
@ -53,10 +37,8 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
|
||||
Inspect_view_version _inspect_view_version { 0 };
|
||||
|
||||
void update(Xml_node const &usb_devices, Xml_node const &ahci_ports,
|
||||
Xml_node const &nvme_namespaces, Xml_node const &mmc_devices,
|
||||
Xml_node const &block_devices,
|
||||
Signal_context_capability sigh);
|
||||
Progress update(Xml_node const &usb_devices, Xml_node const &ahci_ports,
|
||||
Xml_node const &nvme_namespaces, Xml_node const &mmc_devices);
|
||||
|
||||
/*
|
||||
* Determine whether showing the file-system browser or not
|
||||
@ -81,7 +63,7 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
{
|
||||
_storage_devices.for_each([&] (Storage_device &device) {
|
||||
|
||||
if (target.device != device.label)
|
||||
if (target.driver != device.driver)
|
||||
return;
|
||||
|
||||
device.for_each_partition([&] (Partition &partition) {
|
||||
@ -89,27 +71,22 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
bool const whole_device = !target.partition.valid()
|
||||
&& !partition.number.valid();
|
||||
|
||||
bool const partition_matches = (device.label == target.device)
|
||||
bool const partition_matches = (device.driver == target.driver)
|
||||
&& (partition.number == target.partition);
|
||||
|
||||
if (whole_device || partition_matches) {
|
||||
if (whole_device || partition_matches)
|
||||
fn(partition);
|
||||
_runtime.generate_runtime_config();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage_widget::Action interface
|
||||
*/
|
||||
void format(Storage_target const &target) override
|
||||
void format(Storage_target const &target)
|
||||
{
|
||||
_apply_partition(target, [&] (Partition &partition) {
|
||||
partition.format_in_progress = true; });
|
||||
}
|
||||
|
||||
void cancel_format(Storage_target const &target) override
|
||||
void cancel_format(Storage_target const &target)
|
||||
{
|
||||
_apply_partition(target, [&] (Partition &partition) {
|
||||
|
||||
@ -120,13 +97,13 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
});
|
||||
}
|
||||
|
||||
void expand(Storage_target const &target) override
|
||||
void expand(Storage_target const &target)
|
||||
{
|
||||
_apply_partition(target, [&] (Partition &partition) {
|
||||
partition.gpt_expand_in_progress = true; });
|
||||
}
|
||||
|
||||
void cancel_expand(Storage_target const &target) override
|
||||
void cancel_expand(Storage_target const &target)
|
||||
{
|
||||
_apply_partition(target, [&] (Partition &partition) {
|
||||
|
||||
@ -138,16 +115,14 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
});
|
||||
}
|
||||
|
||||
void check(Storage_target const &target) override
|
||||
void check(Storage_target const &target)
|
||||
{
|
||||
_apply_partition(target, [&] (Partition &partition) {
|
||||
partition.check_in_progress = true; });
|
||||
}
|
||||
|
||||
void toggle_inspect_view(Storage_target const &target) override
|
||||
void toggle_inspect_view(Storage_target const &target)
|
||||
{
|
||||
Inspect_view_version const orig_version = _inspect_view_version;
|
||||
|
||||
if (target.ram_fs()) {
|
||||
_ram_fs_state.inspected = !_ram_fs_state.inspected;
|
||||
_inspect_view_version.value++;
|
||||
@ -157,35 +132,23 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
partition.file_system.inspected = !partition.file_system.inspected;
|
||||
_inspect_view_version.value++;
|
||||
});
|
||||
|
||||
if (orig_version.value == _inspect_view_version.value)
|
||||
return;
|
||||
|
||||
_runtime.generate_runtime_config();
|
||||
}
|
||||
|
||||
void toggle_default_storage_target(Storage_target const &target) override
|
||||
void toggle_default_storage_target(Storage_target const &target)
|
||||
{
|
||||
_apply_partition(target, [&] (Partition &partition) {
|
||||
partition.toggle_default_label(); });
|
||||
}
|
||||
|
||||
void use(Storage_target const &target) override
|
||||
{
|
||||
_action.use_storage_target(target);
|
||||
}
|
||||
|
||||
void reset_ram_fs() override
|
||||
void reset_ram_fs()
|
||||
{
|
||||
_ram_fs_state.trigger_restart();
|
||||
|
||||
_runtime.generate_runtime_config();
|
||||
}
|
||||
|
||||
Storage(Env &env, Allocator &alloc, Registry<Child_state> &child_states,
|
||||
Action &action, Runtime_config_generator &runtime)
|
||||
Storage_device::Action &action)
|
||||
:
|
||||
_env(env), _alloc(alloc), _action(action), _runtime(runtime),
|
||||
_env(env), _alloc(alloc), _storage_devices(action),
|
||||
_ram_fs_state(child_states, "ram_fs")
|
||||
{ }
|
||||
};
|
||||
|
@ -86,6 +86,8 @@ namespace Sculpt {
|
||||
void operator () (ARGS &&... args) const override { _fn(args...); }
|
||||
};
|
||||
};
|
||||
|
||||
struct Progress { bool progress; };
|
||||
}
|
||||
|
||||
#endif /* _TYPES_H_ */
|
||||
|
@ -25,13 +25,13 @@ void Partition_operations::view(Scope<Vbox> &s,
|
||||
Partition const &partition,
|
||||
Storage_target const &used_target) const
|
||||
{
|
||||
String<16> const version(device.label, ".", partition.number);
|
||||
String<16> const version(device.driver, ".", partition.number);
|
||||
|
||||
bool const whole_device = !partition.number.valid();
|
||||
|
||||
Storage_target const target { device.label, device.port, partition.number };
|
||||
Storage_target const target { device.driver, device.port, partition.number };
|
||||
|
||||
bool const device_in_use = (used_target.device == device.label);
|
||||
bool const device_in_use = (used_target.driver == device.driver);
|
||||
|
||||
bool const target_in_use = (used_target == target)
|
||||
|| (whole_device && device_in_use)
|
||||
|
@ -34,7 +34,7 @@ struct Sculpt::Partition_operations
|
||||
void view(Scope<Vbox> &s, Storage_device const &, Partition const &,
|
||||
Storage_target const &used_target) const;
|
||||
|
||||
struct Action : Fs_operations::Action
|
||||
struct Action : virtual Fs_operations::Action
|
||||
{
|
||||
virtual void format(Storage_target const &) = 0;
|
||||
virtual void cancel_format(Storage_target const &) = 0;
|
||||
|
@ -37,7 +37,7 @@ struct Dialog::Partition_button : Widget<Hbox>
|
||||
if (partition.label.length() > 1)
|
||||
s.sub_scope<Label>(String<80>(" (", partition.label, ") "));
|
||||
|
||||
Storage_target const target { device.label, device.port, partition.number };
|
||||
Storage_target const target { device.driver, device.port, partition.number };
|
||||
if (used_target == target)
|
||||
s.sub_scope<Label>("* ");
|
||||
});
|
||||
|
@ -39,7 +39,7 @@ struct Sculpt::Storage_device_widget : Widget<Vbox>
|
||||
{
|
||||
Id const partition_id = at.matching_id<Vbox, Hbox>();
|
||||
|
||||
Storage_target const selected_target { device.label, device.port, _selected_partition };
|
||||
Storage_target const selected_target { device.driver, device.port, _selected_partition };
|
||||
|
||||
if (partition_id.valid()) {
|
||||
_selected_partition = (partition_id.value == _selected_partition)
|
||||
@ -54,7 +54,7 @@ struct Sculpt::Storage_device_widget : Widget<Vbox>
|
||||
|
||||
void clack(Clacked_at const &at, Storage_device const &device, Action &action)
|
||||
{
|
||||
Storage_target const selected_target { device.label, device.port, _selected_partition };
|
||||
Storage_target const selected_target { device.driver, device.port, _selected_partition };
|
||||
|
||||
_partition_operations.clack(at, selected_target, action);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ struct Sculpt::Storage_devices_widget_base : Widget<Vbox>
|
||||
|
||||
Constructible<Hosted<Vbox, Frame, Storage_device_widget>> _storage_device_widget { };
|
||||
|
||||
Block_device::Label _selected_device { };
|
||||
Storage_target::Label _selected_device { };
|
||||
|
||||
Storage_devices_widget_base(Storage_devices const &storage_devices,
|
||||
Storage_target const &used_target)
|
||||
@ -118,7 +118,7 @@ struct Sculpt::Storage_device_button : Widget<Button>
|
||||
s.sub_scope<Label>(dev.name());
|
||||
if (model.length() > 1)
|
||||
s.sub_scope<Label>(String<80>(" (", model, ") "));
|
||||
if (used_target.device_and_port() == dev.name())
|
||||
if (used_target.driver_and_port() == dev.name())
|
||||
s.sub_scope<Label>("* ");
|
||||
});
|
||||
|
||||
@ -130,33 +130,6 @@ struct Sculpt::Storage_device_button : Widget<Button>
|
||||
};
|
||||
|
||||
|
||||
namespace Sculpt { struct Block_devices_widget; }
|
||||
|
||||
struct Sculpt::Block_devices_widget : Storage_devices_widget_base
|
||||
{
|
||||
using Storage_devices_widget_base::Storage_devices_widget_base;
|
||||
|
||||
void view(Scope<Vbox> &s) const
|
||||
{
|
||||
s.sub_scope<Min_ex>(35);
|
||||
_storage_devices.block_devices.for_each([&] (Block_device const &dev) {
|
||||
Hosted<Vbox, Storage_device_button> button { Id { dev.name() }, dev.model };
|
||||
_view_device(s, dev, button);
|
||||
});
|
||||
}
|
||||
|
||||
void click(Clicked_at const &at, Storage_device_widget::Action &action)
|
||||
{
|
||||
_click_device<Storage_device_button>(at, action);
|
||||
}
|
||||
|
||||
void clack(Clacked_at const &at, Storage_device_widget::Action &action)
|
||||
{
|
||||
_clack_device(at, action);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace Sculpt { struct Ahci_devices_widget; }
|
||||
|
||||
struct Sculpt::Ahci_devices_widget : Storage_devices_widget_base
|
||||
@ -258,7 +231,7 @@ struct Sculpt::Usb_storage_device_button : Widget<Button>
|
||||
String<16> const vendor { dev.driver_info->vendor };
|
||||
s.sub_scope<Label>(String<64>(" (", vendor, ") "));
|
||||
}
|
||||
if (used_target.device_and_port() == dev.name())
|
||||
if (used_target.driver_and_port() == dev.name())
|
||||
s.sub_scope<Label>("* ");
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user