mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-01 16:58:29 +00:00
Move Session_label from os to base
Session_label constructor now takes a bare string rather than a serialized argument buffer. Replace all instances of previous constructor with 'label_from_args' function. Issue #1787
This commit is contained in:
parent
88b358c5ef
commit
f8337b511b
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include <base/tslab.h>
|
#include <base/tslab.h>
|
||||||
#include <base/lock.h>
|
#include <base/lock.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
|
#include <base/session_label.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <pager.h>
|
#include <pager.h>
|
||||||
@ -38,13 +39,9 @@ namespace Genode { class Cpu_session_component; }
|
|||||||
|
|
||||||
class Genode::Cpu_session_component : public Rpc_object<Cpu_session>
|
class Genode::Cpu_session_component : public Rpc_object<Cpu_session>
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
|
|
||||||
typedef Cpu_thread_component::Session_label Session_label;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Session_label _label;
|
Session_label const _label;
|
||||||
Rpc_entrypoint *_session_ep;
|
Rpc_entrypoint *_session_ep;
|
||||||
Rpc_entrypoint *_thread_ep;
|
Rpc_entrypoint *_thread_ep;
|
||||||
Pager_entrypoint *_pager_ep;
|
Pager_entrypoint *_pager_ep;
|
||||||
|
@ -739,7 +739,7 @@ Platform::Platform() :
|
|||||||
uint64_t execution_time = 0;
|
uint64_t execution_time = 0;
|
||||||
Nova::sc_ctrl(sc_sel, execution_time);
|
Nova::sc_ctrl(sc_sel, execution_time);
|
||||||
|
|
||||||
return { Trace::Session_label("kernel"), Trace::Thread_name(name),
|
return { Session_label("kernel"), Trace::Thread_name(name),
|
||||||
Trace::Execution_time(execution_time), affinity };
|
Trace::Execution_time(execution_time), affinity };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
80
repos/base/include/base/session_label.h
Normal file
80
repos/base/include/base/session_label.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* \brief Session label utility class
|
||||||
|
* \author Emery Hemingway
|
||||||
|
* \date 2016-07-01
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE__BASE__SESSION_LABEL_H_
|
||||||
|
#define _INCLUDE__BASE__SESSION_LABEL_H_
|
||||||
|
|
||||||
|
#include <base/snprintf.h>
|
||||||
|
#include <util/arg_string.h>
|
||||||
|
#include <util/string.h>
|
||||||
|
|
||||||
|
namespace Genode { struct Session_label; }
|
||||||
|
|
||||||
|
struct Genode::Session_label : String<160>
|
||||||
|
{
|
||||||
|
typedef String<capacity()> String;
|
||||||
|
|
||||||
|
using String::String;
|
||||||
|
|
||||||
|
char const *last_element() const
|
||||||
|
{
|
||||||
|
char const * const full = string();
|
||||||
|
char const * const separator = " -> ";
|
||||||
|
|
||||||
|
size_t const full_len = strlen(full);
|
||||||
|
size_t const separator_len = strlen(separator);
|
||||||
|
|
||||||
|
if (full_len < separator_len)
|
||||||
|
return full;
|
||||||
|
|
||||||
|
for (unsigned i = full_len - separator_len; i > 0; --i)
|
||||||
|
if (!strcmp(separator, full + i, separator_len))
|
||||||
|
return full + i + separator_len;
|
||||||
|
|
||||||
|
return full;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract label from session arguments in the form of 'label="..."'
|
||||||
|
*/
|
||||||
|
inline Session_label label_from_args(char const *args)
|
||||||
|
{
|
||||||
|
char buf[Session_label::capacity()];
|
||||||
|
Arg_string::find_arg(args, "label").string(buf, sizeof(buf), "");
|
||||||
|
|
||||||
|
return Session_label(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a compound label in the form of 'prefix -> label'
|
||||||
|
*/
|
||||||
|
inline Session_label prefixed_label(char const *prefix, char const *label)
|
||||||
|
{
|
||||||
|
if (!*prefix)
|
||||||
|
return Session_label(label);
|
||||||
|
|
||||||
|
if (!*label)
|
||||||
|
return Session_label(prefix);
|
||||||
|
|
||||||
|
char buf[Session_label::capacity()];
|
||||||
|
snprintf(buf, sizeof(buf), "%s -> %s", prefix, label);
|
||||||
|
|
||||||
|
return Session_label(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__BASE__SESSION_LABEL_H_ */
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Genode Labs GmbH
|
* Copyright (C) 2013-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -17,6 +17,7 @@
|
|||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <base/affinity.h>
|
#include <base/affinity.h>
|
||||||
|
#include <base/session_label.h>
|
||||||
|
|
||||||
namespace Genode { namespace Trace {
|
namespace Genode { namespace Trace {
|
||||||
|
|
||||||
@ -33,7 +34,6 @@ namespace Genode { namespace Trace {
|
|||||||
struct Traced_by_other_session : Exception { };
|
struct Traced_by_other_session : Exception { };
|
||||||
struct Subject_not_traced : Exception { };
|
struct Subject_not_traced : Exception { };
|
||||||
|
|
||||||
typedef String<160> Session_label;
|
|
||||||
typedef String<32> Thread_name;
|
typedef String<32> Thread_name;
|
||||||
|
|
||||||
struct Policy_id;
|
struct Policy_id;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -246,6 +246,7 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint *session_ep,
|
|||||||
Affinity const &affinity,
|
Affinity const &affinity,
|
||||||
size_t const quota)
|
size_t const quota)
|
||||||
:
|
:
|
||||||
|
_label(label_from_args(args)),
|
||||||
_session_ep(session_ep),
|
_session_ep(session_ep),
|
||||||
_thread_ep(thread_ep), _pager_ep(pager_ep),
|
_thread_ep(thread_ep), _pager_ep(pager_ep),
|
||||||
_md_alloc(md_alloc, remaining_session_ram_quota(args)),
|
_md_alloc(md_alloc, remaining_session_ram_quota(args)),
|
||||||
@ -257,11 +258,6 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint *session_ep,
|
|||||||
_trace_sources(trace_sources), _quota(quota), _ref(0),
|
_trace_sources(trace_sources), _quota(quota), _ref(0),
|
||||||
_native_cpu(*this, args)
|
_native_cpu(*this, args)
|
||||||
{
|
{
|
||||||
/* remember session label */
|
|
||||||
char buf[Session_label::size()];
|
|
||||||
Arg_string::find_arg(args, "label").string(buf, sizeof(buf), "");
|
|
||||||
_label = Session_label(buf);
|
|
||||||
|
|
||||||
Arg a = Arg_string::find_arg(args, "priority");
|
Arg a = Arg_string::find_arg(args, "priority");
|
||||||
if (a.valid()) {
|
if (a.valid()) {
|
||||||
_priority = a.ulong_value(0);
|
_priority = a.ulong_value(0);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -20,6 +20,7 @@
|
|||||||
#include <base/lock.h>
|
#include <base/lock.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
#include <cpu_session/cpu_session.h>
|
#include <cpu_session/cpu_session.h>
|
||||||
|
#include <base/session_label.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <pager.h>
|
#include <pager.h>
|
||||||
@ -37,13 +38,9 @@ namespace Genode { class Cpu_session_component; }
|
|||||||
class Genode::Cpu_session_component : public Rpc_object<Cpu_session>,
|
class Genode::Cpu_session_component : public Rpc_object<Cpu_session>,
|
||||||
public List<Cpu_session_component>::Element
|
public List<Cpu_session_component>::Element
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
|
|
||||||
typedef Cpu_thread_component::Session_label Session_label;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Session_label _label;
|
Session_label const _label;
|
||||||
Rpc_entrypoint * const _session_ep;
|
Rpc_entrypoint * const _session_ep;
|
||||||
Rpc_entrypoint *_thread_ep;
|
Rpc_entrypoint *_thread_ep;
|
||||||
Pager_entrypoint *_pager_ep;
|
Pager_entrypoint *_pager_ep;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <util/list.h>
|
#include <util/list.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
#include <cpu_thread/cpu_thread.h>
|
#include <cpu_thread/cpu_thread.h>
|
||||||
|
#include <base/session_label.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <pager.h>
|
#include <pager.h>
|
||||||
@ -36,7 +37,6 @@ class Genode::Cpu_thread_component : public Rpc_object<Cpu_thread>,
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef Trace::Session_label Session_label;
|
|
||||||
typedef Trace::Thread_name Thread_name;
|
typedef Trace::Thread_name Thread_name;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -38,15 +38,12 @@ class Genode::Trace::Root : public Genode::Root_component<Session_component>
|
|||||||
size_t arg_buffer_size = Arg_string::find_arg(args, "arg_buffer_size").ulong_value(0);
|
size_t arg_buffer_size = Arg_string::find_arg(args, "arg_buffer_size").ulong_value(0);
|
||||||
unsigned parent_levels = Arg_string::find_arg(args, "parent_levels").ulong_value(0);
|
unsigned parent_levels = Arg_string::find_arg(args, "parent_levels").ulong_value(0);
|
||||||
|
|
||||||
char label[Trace::Session_label::size()];
|
|
||||||
Arg_string::find_arg(args, "label").string(label, sizeof(label), "");
|
|
||||||
|
|
||||||
if (arg_buffer_size > ram_quota)
|
if (arg_buffer_size > ram_quota)
|
||||||
throw Root::Invalid_args();
|
throw Root::Invalid_args();
|
||||||
|
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Session_component(*md_alloc(), ram_quota, arg_buffer_size,
|
Session_component(*md_alloc(), ram_quota, arg_buffer_size,
|
||||||
parent_levels, label, _sources, _policies);
|
parent_levels, label_from_args(args).string(), _sources, _policies);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _upgrade_session(Session_component *s, const char *args)
|
void _upgrade_session(Session_component *s, const char *args)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Genode Labs GmbH
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -790,10 +790,10 @@ class Usb::Root : public Genode::Root_component<Session_component>
|
|||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
Session_label const label = label_from_args(args);
|
||||||
try {
|
try {
|
||||||
Xml_node config_node = Lx_kit::env().config_rom().xml();
|
Xml_node config_node = Lx_kit::env().config_rom().xml();
|
||||||
Xml_node raw = config_node.sub_node("raw");
|
Xml_node raw = config_node.sub_node("raw");
|
||||||
Genode::Session_label label(args);
|
|
||||||
Genode::Session_policy policy(label, raw);
|
Genode::Session_policy policy(label, raw);
|
||||||
|
|
||||||
size_t ram_quota = Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
size_t ram_quota = Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
||||||
@ -822,7 +822,7 @@ class Usb::Root : public Genode::Root_component<Session_component>
|
|||||||
return session;
|
return session;
|
||||||
} catch (Genode::Session_policy::No_policy_defined) {
|
} catch (Genode::Session_policy::No_policy_defined) {
|
||||||
error("Invalid session request, no matching policy for '",
|
error("Invalid session request, no matching policy for '",
|
||||||
Genode::Session_label(args).string(), "'");
|
label.string(), "'");
|
||||||
throw Genode::Root::Unavailable();
|
throw Genode::Root::Unavailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Genode Labs GmbH
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -374,7 +374,7 @@ class File_system::Root : public Root_component<Session_component>
|
|||||||
Genode::Path<MAX_PATH_LEN> session_root;
|
Genode::Path<MAX_PATH_LEN> session_root;
|
||||||
bool writeable = false;
|
bool writeable = false;
|
||||||
|
|
||||||
Session_label const label(args);
|
Session_label const label = label_from_args(args);
|
||||||
|
|
||||||
size_t ram_quota =
|
size_t ram_quota =
|
||||||
Arg_string::find_arg(args, "ram_quota").aligned_size();
|
Arg_string::find_arg(args, "ram_quota").aligned_size();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
* Copyright (C) 2012 Intel Corporation
|
* Copyright (C) 2012 Intel Corporation
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
@ -87,7 +87,7 @@ struct Launcher::Main
|
|||||||
|
|
||||||
void _handle_exited_child(unsigned)
|
void _handle_exited_child(unsigned)
|
||||||
{
|
{
|
||||||
auto kill_child_fn = [&] (Child_base::Label label) { _panel_dialog.kill(label); };
|
auto kill_child_fn = [&] (Label const &label) { _panel_dialog.kill(label); };
|
||||||
|
|
||||||
_subsystem_manager.for_each_exited_child(kill_child_fn);
|
_subsystem_manager.for_each_exited_child(kill_child_fn);
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,7 @@ class Launcher::Panel_dialog : Input_event_handler, Dialog_generator,
|
|||||||
_context_dialog.visible(false);
|
_context_dialog.visible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kill(Child_base::Label const &label)
|
void kill(Label const &label)
|
||||||
{
|
{
|
||||||
_kill(label);
|
_kill(label);
|
||||||
}
|
}
|
||||||
|
@ -204,8 +204,8 @@ class Launcher::Subsystem_manager
|
|||||||
{
|
{
|
||||||
Child::Binary_name const binary_name = _binary_name(subsystem);
|
Child::Binary_name const binary_name = _binary_name(subsystem);
|
||||||
|
|
||||||
Child::Label const label = string_attribute(subsystem, "name",
|
Label const label = string_attribute(subsystem, "name",
|
||||||
Child::Label(""));
|
Label(""));
|
||||||
|
|
||||||
Ram_config const ram_config = _ram_config(subsystem);
|
Ram_config const ram_config = _ram_config(subsystem);
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ class Launcher::Subsystem_manager
|
|||||||
void kill(char const *label)
|
void kill(char const *label)
|
||||||
{
|
{
|
||||||
for (Child *c = _children.first(); c; c = c->next()) {
|
for (Child *c = _children.first(); c; c = c->next()) {
|
||||||
if (c->label() == Child::Label(label)) {
|
if (c->label() == Label(label)) {
|
||||||
_children.remove(c);
|
_children.remove(c);
|
||||||
destroy(env()->heap(), c);
|
destroy(env()->heap(), c);
|
||||||
return;
|
return;
|
||||||
@ -248,7 +248,7 @@ class Launcher::Subsystem_manager
|
|||||||
/**
|
/**
|
||||||
* Call functor for each exited child
|
* Call functor for each exited child
|
||||||
*
|
*
|
||||||
* The functor takes a 'Child_base::Label' as argument.
|
* The functor takes a 'Label' as argument.
|
||||||
*/
|
*/
|
||||||
template <typename FUNC>
|
template <typename FUNC>
|
||||||
void for_each_exited_child(FUNC const &func)
|
void for_each_exited_child(FUNC const &func)
|
||||||
@ -257,7 +257,7 @@ class Launcher::Subsystem_manager
|
|||||||
for (Child *child = _children.first(); child; child = next) {
|
for (Child *child = _children.first(); child; child = next) {
|
||||||
next = child->next();
|
next = child->next();
|
||||||
if (child->exited())
|
if (child->exited())
|
||||||
func(child->label());
|
func(Label(child->label().string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -228,7 +228,7 @@ namespace Terminal {
|
|||||||
Genode::size_t io_buffer_size = 4096;
|
Genode::size_t io_buffer_size = 4096;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Genode::Session_label label(args);
|
Genode::Session_label label = Genode::label_from_args(args);
|
||||||
Genode::Session_policy policy(label);
|
Genode::Session_policy policy(label);
|
||||||
|
|
||||||
char filename[256];
|
char filename[256];
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2013 Genode Labs GmbH
|
* Copyright (C) 2011-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -469,26 +469,28 @@ namespace Terminal {
|
|||||||
|
|
||||||
Session_component *_create_session(const char *args)
|
Session_component *_create_session(const char *args)
|
||||||
{
|
{
|
||||||
|
using namespace Genode;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX read I/O buffer size from args
|
* XXX read I/O buffer size from args
|
||||||
*/
|
*/
|
||||||
Genode::size_t io_buffer_size = 4096;
|
size_t io_buffer_size = 4096;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Genode::Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
Genode::Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
unsigned tcp_port = 0;
|
unsigned tcp_port = 0;
|
||||||
policy.attribute("port").value(&tcp_port);
|
policy.attribute("port").value(&tcp_port);
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Session_component(io_buffer_size, tcp_port);
|
Session_component(io_buffer_size, tcp_port);
|
||||||
|
|
||||||
} catch (Genode::Xml_node::Nonexistent_attribute) {
|
} catch (Xml_node::Nonexistent_attribute) {
|
||||||
PERR("Missing \"port\" attribute in policy definition");
|
error("Missing \"port\" attribute in policy definition");
|
||||||
throw Genode::Root::Unavailable();
|
throw Root::Unavailable();
|
||||||
} catch (Genode::Session_policy::No_policy_defined) {
|
} catch (Session_policy::No_policy_defined) {
|
||||||
PERR("Invalid session request, no matching policy");
|
error("Invalid session request, no matching policy");
|
||||||
throw Genode::Root::Unavailable();
|
throw Root::Unavailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Genode Labs GmbH
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -1108,8 +1108,8 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
|||||||
Genode::Session_capability session(Session_args const &args,
|
Genode::Session_capability session(Session_args const &args,
|
||||||
Affinity const &affinity) override
|
Affinity const &affinity) override
|
||||||
{
|
{
|
||||||
Genode::Session_label session_label(args.string());
|
Genode::Session_label const session_label =
|
||||||
|
Genode::label_from_args(args.string());
|
||||||
|
|
||||||
enum Role { ROLE_DECORATOR, ROLE_LAYOUTER, ROLE_REGULAR, ROLE_DIRECT };
|
enum Role { ROLE_DECORATOR, ROLE_LAYOUTER, ROLE_REGULAR, ROLE_DIRECT };
|
||||||
Role role = ROLE_REGULAR;
|
Role role = ROLE_REGULAR;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2013 Genode Labs GmbH
|
* Copyright (C) 2012-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -877,7 +877,7 @@ namespace File_system {
|
|||||||
char root[ROOT_MAX_LEN];
|
char root[ROOT_MAX_LEN];
|
||||||
root[0] = 0;
|
root[0] = 0;
|
||||||
|
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
try {
|
try {
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Genode Labs GmbH
|
* Copyright (C) 2013-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -446,7 +446,7 @@ class File_system::Root : public Root_component<Session_component>
|
|||||||
char root[ROOT_MAX_LEN];
|
char root[ROOT_MAX_LEN];
|
||||||
root[0] = 0;
|
root[0] = 0;
|
||||||
|
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
try {
|
try {
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2013 Genode Labs GmbH
|
* Copyright (C) 2010-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -177,10 +177,8 @@ namespace Init {
|
|||||||
if (!service_matches)
|
if (!service_matches)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
typedef Genode::String<128> Label;
|
Genode::Session_label const session_label(skip_label_prefix(
|
||||||
|
child_name, Genode::label_from_args(args).string()));
|
||||||
Label const session_label =
|
|
||||||
Label(skip_label_prefix(child_name, Genode::Session_label(args).string()));
|
|
||||||
|
|
||||||
return !Genode::Xml_node_label_score(service_node, session_label).conflict();
|
return !Genode::Xml_node_label_score(service_node, session_label).conflict();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <base/service.h>
|
#include <base/service.h>
|
||||||
#include <base/child.h>
|
#include <base/child.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
|
#include <base/session_label.h>
|
||||||
#include <util/arg_string.h>
|
#include <util/arg_string.h>
|
||||||
#include <rom_session/connection.h>
|
#include <rom_session/connection.h>
|
||||||
|
|
||||||
@ -93,17 +94,13 @@ class Init::Child_policy_enforce_labeling
|
|||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
char label_buf[Parent::Session_args::MAX_SIZE];
|
Session_label const old_label = label_from_args(args);
|
||||||
Arg_string::find_arg(args, "label").string(label_buf, sizeof(label_buf), "");
|
if (old_label == "") {
|
||||||
|
Arg_string::set_arg_string(args, args_len, "label", _name);
|
||||||
char value_buf[Parent::Session_args::MAX_SIZE];
|
} else {
|
||||||
Genode::snprintf(value_buf, sizeof(value_buf),
|
Session_label const new_label = prefixed_label(_name, old_label.string());
|
||||||
"\"%s%s%s\"",
|
Arg_string::set_arg_string(args, args_len, "label", new_label.string());
|
||||||
_name,
|
}
|
||||||
Genode::strcmp(label_buf, "") == 0 ? "" : " -> ",
|
|
||||||
label_buf);
|
|
||||||
|
|
||||||
Arg_string::set_arg(args, args_len, "label", value_buf);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
#include <util/arg_string.h>
|
#include <util/arg_string.h>
|
||||||
#include <os/config.h>
|
#include <os/config.h>
|
||||||
|
#include <base/session_label.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
struct Xml_node_label_score;
|
struct Xml_node_label_score;
|
||||||
struct Session_label;
|
|
||||||
class Session_policy;
|
class Session_policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,30 +153,6 @@ struct Genode::Xml_node_label_score
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Genode::Session_label : String<128>
|
|
||||||
{
|
|
||||||
Session_label() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* \param args session arguments as null-terminated string
|
|
||||||
*
|
|
||||||
* The constructor extracts the label from the supplied session-argument
|
|
||||||
* string.
|
|
||||||
*/
|
|
||||||
explicit Session_label(char const *args)
|
|
||||||
{
|
|
||||||
typedef String<128> String;
|
|
||||||
|
|
||||||
char buf[String::capacity()];
|
|
||||||
Arg_string::find_arg(args, "label").string(buf, sizeof(buf),
|
|
||||||
"<undefined>");
|
|
||||||
*static_cast<String *>(this) = String(buf);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query server-side policy for a session request
|
* Query server-side policy for a session request
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Genode Labs GmbH
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -116,7 +116,7 @@ struct Report::Root : Genode::Root_component<Session_component>
|
|||||||
Arg_string::find_arg(args, "buffer_size").ulong_value(0);
|
Arg_string::find_arg(args, "buffer_size").ulong_value(0);
|
||||||
|
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Session_component(Genode::Session_label(args), buffer_size,
|
Session_component(label_from_args(args), buffer_size,
|
||||||
_rom_registry, _verbose);
|
_rom_registry, _verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ class Rom::Root : public Genode::Root_component<Session_component>
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Session_component(_registry, Session_label(args));
|
Session_component(_registry, label_from_args(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -504,7 +504,8 @@ namespace Platform {
|
|||||||
_device_slab(&_md_alloc),
|
_device_slab(&_md_alloc),
|
||||||
_device_pd_ep(device_pd_ep),
|
_device_pd_ep(device_pd_ep),
|
||||||
_resources(_md_alloc),
|
_resources(_md_alloc),
|
||||||
_label(args), _policy(_label)
|
_label(Genode::label_from_args(args)),
|
||||||
|
_policy(_label)
|
||||||
{
|
{
|
||||||
/* non-pci devices */
|
/* non-pci devices */
|
||||||
_policy.for_each_sub_node("device", [&] (Genode::Xml_node device_node) {
|
_policy.for_each_sub_node("device", [&] (Genode::Xml_node device_node) {
|
||||||
@ -1073,7 +1074,7 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
|||||||
args, _device_pd_ep);
|
args, _device_pd_ep);
|
||||||
} catch (Genode::Session_policy::No_policy_defined) {
|
} catch (Genode::Session_policy::No_policy_defined) {
|
||||||
PERR("Invalid session request, no matching policy for '%s'",
|
PERR("Invalid session request, no matching policy for '%s'",
|
||||||
Genode::Session_label(args).string());
|
Genode::label_from_args(args).string());
|
||||||
throw Genode::Root::Unavailable();
|
throw Genode::Root::Unavailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ namespace Uart {
|
|||||||
Session_component *_create_session(const char *args)
|
Session_component *_create_session(const char *args)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Session_label label(args);
|
Session_label label = label_from_args(args);
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 Genode Labs GmbH
|
* Copyright (C) 2015-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -72,7 +72,7 @@ class Fs_log::Root_component :
|
|||||||
dir_path[0] = '/';
|
dir_path[0] = '/';
|
||||||
|
|
||||||
bool truncate = false;
|
bool truncate = false;
|
||||||
Session_label session_label(args);
|
Session_label const session_label = label_from_args(args);
|
||||||
char const *label_str = session_label.string();
|
char const *label_str = session_label.string();
|
||||||
char const *label_prefix = "";
|
char const *label_prefix = "";
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <util/avl_string.h>
|
#include <util/avl_string.h>
|
||||||
#include <util/misc_math.h>
|
#include <util/misc_math.h>
|
||||||
#include <os/attached_ram_dataspace.h>
|
#include <os/attached_ram_dataspace.h>
|
||||||
|
#inlcude <base/session_label.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include "iso9660.h"
|
#include "iso9660.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2013 Genode Labs GmbH
|
* Copyright (C) 2012-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -336,7 +336,7 @@ class File_system::Root : public Root_component<Session_component>
|
|||||||
char root[ROOT_MAX_LEN];
|
char root[ROOT_MAX_LEN];
|
||||||
root[0] = 0;
|
root[0] = 0;
|
||||||
|
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
try {
|
try {
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2013 Genode Labs GmbH
|
* Copyright (C) 2010-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -198,14 +198,12 @@ class Net::Root : public Genode::Root_component<Net::Session_component>
|
|||||||
memset(ip_addr, 0, MAX_IP_ADDR_LENGTH);
|
memset(ip_addr, 0, MAX_IP_ADDR_LENGTH);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
Session_policy policy(label, _config);
|
Session_policy policy(label, _config);
|
||||||
policy.attribute("ip_addr").value(ip_addr, sizeof(ip_addr));
|
policy.attribute("ip_addr").value(ip_addr, sizeof(ip_addr));
|
||||||
} catch (Xml_node::Nonexistent_attribute) {
|
} catch (Xml_node::Nonexistent_attribute) {
|
||||||
Genode::log("Missing \"ip_addr\" attribute in policy definition");
|
Genode::log("Missing \"ip_addr\" attribute in policy definition");
|
||||||
} catch (Session_policy::No_policy_defined) {
|
} catch (Session_policy::No_policy_defined) { }
|
||||||
Genode::log("Invalid session request, no matching policy");;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ram_quota =
|
size_t ram_quota =
|
||||||
Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -30,7 +30,7 @@ struct Background : private Texture_base, Session, View
|
|||||||
*/
|
*/
|
||||||
Background(Area size)
|
Background(Area size)
|
||||||
:
|
:
|
||||||
Texture_base(Area(0, 0)), Session(Genode::Session_label("label=\"\"")),
|
Texture_base(Area(0, 0)), Session(Genode::Session_label()),
|
||||||
View(*this, View::NOT_TRANSPARENT, View::BACKGROUND, 0),
|
View(*this, View::NOT_TRANSPARENT, View::BACKGROUND, 0),
|
||||||
color(25, 37, 50)
|
color(25, 37, 50)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -1037,11 +1037,11 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
|
|||||||
|
|
||||||
size_t const unused_quota = ram_quota - required_quota;
|
size_t const unused_quota = ram_quota - required_quota;
|
||||||
|
|
||||||
Session_label const label(args);
|
Genode::Session_label const label = Genode::label_from_args(args);
|
||||||
bool const provides_default_bg = (strcmp(label.string(), "backdrop") == 0);
|
bool const provides_default_bg = (label == "backdrop");
|
||||||
|
|
||||||
Session_component *session = new (md_alloc())
|
Session_component *session = new (md_alloc())
|
||||||
Session_component(Session_label(args), _view_stack, _mode,
|
Session_component(label, _view_stack, _mode,
|
||||||
_pointer_origin, *ep(), _framebuffer,
|
_pointer_origin, *ep(), _framebuffer,
|
||||||
provides_default_bg, *md_alloc(), unused_quota,
|
provides_default_bg, *md_alloc(), unused_quota,
|
||||||
_focus_reporter);
|
_focus_reporter);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Genode Labs GmbH
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -21,7 +21,7 @@ struct Pointer_origin : Session, View
|
|||||||
{
|
{
|
||||||
Pointer_origin()
|
Pointer_origin()
|
||||||
:
|
:
|
||||||
Session(Genode::Session_label("")),
|
Session(Genode::Session_label()),
|
||||||
View(*this, View::TRANSPARENT, View::NOT_BACKGROUND, 0)
|
View(*this, View::TRANSPARENT, View::NOT_BACKGROUND, 0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2013-2015 Genode Labs GmbH
|
* Copyright (C) 2013-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -208,7 +208,7 @@ class Block::Root :
|
|||||||
{
|
{
|
||||||
long num = -1;
|
long num = -1;
|
||||||
|
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
char const *label_str = label.string();
|
char const *label_str = label.string();
|
||||||
try {
|
try {
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2013 Genode Labs GmbH
|
* Copyright (C) 2012-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -433,7 +433,7 @@ namespace File_system {
|
|||||||
char root[ROOT_MAX_LEN];
|
char root[ROOT_MAX_LEN];
|
||||||
root[0] = 0;
|
root[0] = 0;
|
||||||
|
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
try {
|
try {
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Genode Labs GmbH
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -947,7 +947,7 @@ class File_system::Root : public Root_component<Session_component>
|
|||||||
Genode::Number_of_bytes buffer_size_max = 1 * (1 << 20); /* 1 MiB */
|
Genode::Number_of_bytes buffer_size_max = 1 * (1 << 20); /* 1 MiB */
|
||||||
unsigned trace_parent_levels = 0;
|
unsigned trace_parent_levels = 0;
|
||||||
|
|
||||||
Session_label label(args);
|
Session_label const label = label_from_args(args);
|
||||||
try {
|
try {
|
||||||
Session_policy policy(label);
|
Session_policy policy(label);
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ class Vfs_server::Root :
|
|||||||
Path session_root;
|
Path session_root;
|
||||||
bool writeable = false;
|
bool writeable = false;
|
||||||
|
|
||||||
Session_label const label(args);
|
Session_label const label = label_from_args(args);
|
||||||
|
|
||||||
char tmp[MAX_PATH_LEN];
|
char tmp[MAX_PATH_LEN];
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user