mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 09:46:20 +00:00
parent
915adcd0dd
commit
ecd0066e80
@ -29,7 +29,6 @@ namespace Usb_filter {
|
||||
using Genode::Xml_node;
|
||||
using Genode::Xml_generator;
|
||||
using Genode::Attached_rom_dataspace;
|
||||
using Genode::snprintf;
|
||||
using Genode::error;
|
||||
using Genode::log;
|
||||
using Genode::warning;
|
||||
@ -120,29 +119,30 @@ class Usb_filter::Device_registry
|
||||
(vendor == entry.vendor && product == entry.product);
|
||||
}
|
||||
|
||||
static void _gen_dev_attributes(Xml_generator &xml, Xml_node const &node)
|
||||
{
|
||||
auto copy_attr = [&] (auto name)
|
||||
{
|
||||
using Value = Genode::String<32>;
|
||||
xml.attribute(name, node.attribute_value(name, Value()));
|
||||
};
|
||||
|
||||
copy_attr("vendor_id");
|
||||
copy_attr("product_id");
|
||||
copy_attr("bus");
|
||||
copy_attr("dev");
|
||||
}
|
||||
|
||||
static void _gen_policy_entry(Xml_generator &xml, Xml_node &node,
|
||||
Entry const &, char const *label)
|
||||
{
|
||||
xml.node("policy", [&] {
|
||||
char buf[MAX_LABEL_LEN + 16];
|
||||
|
||||
unsigned const bus = _get_value(node, "bus");
|
||||
unsigned const dev = _get_value(node, "dev");
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s -> usb-%d-%d", label, bus, dev);
|
||||
xml.attribute("label", buf);
|
||||
xml.attribute("label", Label(label, " -> usb-", bus, "-", dev));
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", _get_value(node, "vendor_id"));
|
||||
xml.attribute("vendor_id", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", _get_value(node, "product_id"));
|
||||
xml.attribute("product_id", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", bus);
|
||||
xml.attribute("bus", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", dev);
|
||||
xml.attribute("dev", buf);
|
||||
_gen_dev_attributes(xml, node);
|
||||
});
|
||||
}
|
||||
|
||||
@ -272,25 +272,12 @@ class Usb_filter::Device_registry
|
||||
Entry const &)
|
||||
{
|
||||
xml.node("device", [&] {
|
||||
char buf[16];
|
||||
|
||||
unsigned const bus = _get_value(node, "bus");
|
||||
unsigned const dev = _get_value(node, "dev");
|
||||
|
||||
snprintf(buf, sizeof(buf), "usb-%d-%d", bus, dev);
|
||||
xml.attribute("label", buf);
|
||||
xml.attribute("label", Label("usb-", bus, "-", dev));
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", _get_value(node, "vendor_id"));
|
||||
xml.attribute("vendor_id", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", _get_value(node, "product_id"));
|
||||
xml.attribute("product_id", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", bus);
|
||||
xml.attribute("bus", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%4x", dev);
|
||||
xml.attribute("dev", buf);
|
||||
_gen_dev_attributes(xml, node);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1605,9 +1605,7 @@ class Acpi_table
|
||||
static void attribute_hex(Xml_generator &xml, char const *name,
|
||||
unsigned long long value)
|
||||
{
|
||||
char buf[32];
|
||||
Genode::snprintf(buf, sizeof(buf), "0x%llx", value);
|
||||
xml.attribute(name, buf);
|
||||
xml.attribute(name, String<32>(Hex(value)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,9 +151,9 @@ struct Virtdev_rom::Main
|
||||
|
||||
xml.node("device", [&] ()
|
||||
{
|
||||
static char name[DEVICE_NAME_LEN];
|
||||
snprintf(name, sizeof(name), "%s%u", _name_for_id(id), device_type_idx[id - 1]++);
|
||||
xml.attribute("name", name);
|
||||
using Name = String<DEVICE_NAME_LEN>;
|
||||
|
||||
xml.attribute("name", Name(_name_for_id(id), device_type_idx[id - 1]++));
|
||||
xml.attribute("type", _name_for_id(id));
|
||||
xml.node("io_mem", [&] () {
|
||||
xml.attribute("address", addr);
|
||||
|
@ -116,11 +116,7 @@ Vfs::Global_file_system_factory::_try_create(Vfs::Env &env,
|
||||
*/
|
||||
Library_name Vfs::Global_file_system_factory::_library_name(Node_name const &node_name)
|
||||
{
|
||||
char lib_name [Library_name::capacity()];
|
||||
Genode::snprintf(lib_name, sizeof(lib_name), "vfs_%s.lib.so",
|
||||
node_name.string());
|
||||
|
||||
return Library_name(lib_name);
|
||||
return Library_name("vfs_", node_name, ".lib.so");
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/registry.h>
|
||||
#include <util/formatted_output.h>
|
||||
#include <rtc_session/connection.h>
|
||||
#include <vfs/file_system.h>
|
||||
|
||||
@ -60,10 +61,31 @@ class Vfs::Rtc_file_system : public Single_file_system
|
||||
|
||||
Rtc::Timestamp ts = _rtc.current_time();
|
||||
|
||||
char buf[TIMESTAMP_LEN+1];
|
||||
char *b = buf;
|
||||
size_t n = Genode::snprintf(buf, sizeof(buf), "%04u-%02u-%02u %02u:%02u:%02u\n",
|
||||
ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second);
|
||||
struct Padded
|
||||
{
|
||||
unsigned pad, value;
|
||||
|
||||
void print(Genode::Output &out) const
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
unsigned const len = printed_length(value);
|
||||
if (len < pad)
|
||||
Genode::print(out, Repeated(pad - len, Char('0')));
|
||||
|
||||
Genode::print(out, value);
|
||||
}
|
||||
};
|
||||
|
||||
String<TIMESTAMP_LEN+1> string { Padded { 4, ts.year }, "-",
|
||||
Padded { 2, ts.month }, "-",
|
||||
Padded { 2, ts.day }, " ",
|
||||
Padded { 2, ts.hour }, ":",
|
||||
Padded { 2, ts.minute }, ":",
|
||||
Padded { 2, ts.second }, "\n" };
|
||||
char const *b = string.string();
|
||||
size_t n = string.length();
|
||||
|
||||
n -= size_t(seek());
|
||||
b += seek();
|
||||
|
||||
|
@ -26,11 +26,13 @@ namespace Genode {
|
||||
{
|
||||
public:
|
||||
|
||||
enum { LABEL_LEN = 64 };
|
||||
enum { LABEL_LEN = 64u };
|
||||
|
||||
private:
|
||||
|
||||
char _label[LABEL_LEN];
|
||||
using Label = Genode::String<LABEL_LEN>;
|
||||
Label const _label;
|
||||
|
||||
Terminal::Connection &_terminal;
|
||||
|
||||
public:
|
||||
@ -39,7 +41,10 @@ namespace Genode {
|
||||
* Constructor
|
||||
*/
|
||||
Termlog_component(const char *label, Terminal::Connection &terminal)
|
||||
: _terminal(terminal) { snprintf(_label, LABEL_LEN, "[%s] ", label); }
|
||||
:
|
||||
_label("[", label, "] "),
|
||||
_terminal(terminal)
|
||||
{ }
|
||||
|
||||
|
||||
/*****************
|
||||
@ -76,7 +81,7 @@ namespace Genode {
|
||||
return;
|
||||
}
|
||||
|
||||
_terminal.write(_label, strlen(_label));
|
||||
_terminal.write(_label.string(), strlen(_label.string()));
|
||||
_terminal.write(string, len);
|
||||
|
||||
/* if last character of string was not a line break, add one */
|
||||
|
@ -100,12 +100,7 @@ class Test::Subsystem
|
||||
|
||||
bool _expect_import = true;
|
||||
|
||||
Label _session_label()
|
||||
{
|
||||
char buf[Label::capacity()];
|
||||
snprintf(buf, sizeof(buf), "%s -> clipboard", _name.string());
|
||||
return Label(Cstring(buf));
|
||||
}
|
||||
Label _session_label() { return Label(_name, " -> clipboard"); }
|
||||
|
||||
Attached_rom_dataspace _import_rom;
|
||||
|
||||
|
@ -542,7 +542,7 @@ void Component::construct(Genode::Env &env)
|
||||
vfs_env.io().commit_and_wait();
|
||||
};
|
||||
|
||||
char path[Vfs::MAX_PATH_LEN];
|
||||
String<Vfs::MAX_PATH_LEN> path { };
|
||||
|
||||
MAX_DEPTH = config_xml.attribute_value("depth", 16U);
|
||||
|
||||
@ -563,11 +563,11 @@ void Component::construct(Genode::Env &env)
|
||||
elapsed_ms = timer.elapsed_ms();
|
||||
|
||||
for (int i = 0; i < ROOT_TREE_COUNT; ++i) {
|
||||
snprintf(path, 3, "/%d", i);
|
||||
path = { "/", i };
|
||||
Vfs::Vfs_handle *dir_handle;
|
||||
vfs_root.opendir(path, true, &dir_handle, heap);
|
||||
vfs_root.opendir(path.string(), true, &dir_handle, heap);
|
||||
dir_handle->close();
|
||||
Mkdir_test test(vfs_root, heap, path);
|
||||
Mkdir_test test(vfs_root, heap, path.string());
|
||||
count += test.wait();
|
||||
}
|
||||
elapsed_ms = timer.elapsed_ms() - elapsed_ms;
|
||||
@ -590,8 +590,8 @@ void Component::construct(Genode::Env &env)
|
||||
elapsed_ms = timer.elapsed_ms();
|
||||
|
||||
for (int i = 0; i < ROOT_TREE_COUNT; ++i) {
|
||||
snprintf(path, 3, "/%d", i);
|
||||
Populate_test test(vfs_root, heap, path);
|
||||
path = { "/", i };
|
||||
Populate_test test(vfs_root, heap, path.string());
|
||||
count += test.wait();
|
||||
}
|
||||
|
||||
@ -621,8 +621,8 @@ void Component::construct(Genode::Env &env)
|
||||
elapsed_ms = timer.elapsed_ms();
|
||||
|
||||
for (int i = 0; i < ROOT_TREE_COUNT; ++i) {
|
||||
snprintf(path, 3, "/%d", i);
|
||||
Write_test test(vfs_root, heap, path, vfs_env.io());
|
||||
path = { "/", i };
|
||||
Write_test test(vfs_root, heap, path.string(), vfs_env.io());
|
||||
count += test.wait();
|
||||
|
||||
}
|
||||
@ -657,8 +657,8 @@ void Component::construct(Genode::Env &env)
|
||||
elapsed_ms = timer.elapsed_ms();
|
||||
|
||||
for (int i = 0; i < ROOT_TREE_COUNT; ++i) {
|
||||
snprintf(path, 3, "/%d", i);
|
||||
Read_test test(vfs_root, heap, path, vfs_env.io());
|
||||
path = { "/", i };
|
||||
Read_test test(vfs_root, heap, path.string(), vfs_env.io());
|
||||
count += test.wait();
|
||||
}
|
||||
|
||||
@ -693,8 +693,8 @@ void Component::construct(Genode::Env &env)
|
||||
elapsed_ms = timer.elapsed_ms();
|
||||
|
||||
for (int i = 0; i < ROOT_TREE_COUNT; ++i) {
|
||||
snprintf(path, 3, "/%d", i);
|
||||
Unlink_test test(vfs_root, heap, path, vfs_env.io());
|
||||
path = { "/", i };
|
||||
Unlink_test test(vfs_root, heap, path.string(), vfs_env.io());
|
||||
count += test.wait();
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user