mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
Simplify use of namespace Genode within Noux
This commit is contained in:
parent
4c4d4e5c63
commit
5bedeef814
@ -17,6 +17,6 @@
|
||||
#include <base/capability.h>
|
||||
#include <noux_session/noux_session.h>
|
||||
|
||||
namespace Noux { typedef Genode::Capability<Session> Session_capability; }
|
||||
namespace Noux { typedef Capability<Session> Session_capability; }
|
||||
|
||||
#endif /* _INCLUDE__NOUX_SESSION__CAPABILITY_H_ */
|
||||
|
@ -21,13 +21,13 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
struct Session_client : Genode::Rpc_client<Session>
|
||||
struct Session_client : Rpc_client<Session>
|
||||
{
|
||||
explicit Session_client(Session_capability session)
|
||||
: Genode::Rpc_client<Session>(session) { }
|
||||
: Rpc_client<Session>(session) { }
|
||||
|
||||
|
||||
Genode::Dataspace_capability sysio_dataspace()
|
||||
Dataspace_capability sysio_dataspace()
|
||||
{
|
||||
return call<Rpc_sysio_dataspace>();
|
||||
}
|
||||
|
@ -23,13 +23,15 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Session : Genode::Session
|
||||
{
|
||||
static const char *service_name() { return "Noux"; }
|
||||
|
||||
virtual ~Session() { }
|
||||
|
||||
virtual Genode::Dataspace_capability sysio_dataspace() = 0;
|
||||
virtual Dataspace_capability sysio_dataspace() = 0;
|
||||
|
||||
enum Syscall {
|
||||
SYSCALL_GETCWD,
|
||||
@ -96,7 +98,7 @@ namespace Noux {
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
|
||||
GENODE_RPC(Rpc_sysio_dataspace, Genode::Dataspace_capability, sysio_dataspace);
|
||||
GENODE_RPC(Rpc_sysio_dataspace, Dataspace_capability, sysio_dataspace);
|
||||
GENODE_RPC(Rpc_syscall, bool, syscall, Syscall);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_sysio_dataspace, Rpc_syscall);
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Sysio
|
||||
{
|
||||
/*
|
||||
@ -65,7 +67,7 @@ namespace Noux {
|
||||
|
||||
struct Stat
|
||||
{
|
||||
Genode::size_t size;
|
||||
size_t size;
|
||||
unsigned mode;
|
||||
unsigned uid;
|
||||
unsigned gid;
|
||||
@ -148,7 +150,7 @@ namespace Noux {
|
||||
* Return total number of file descriptors contained in the array
|
||||
*/
|
||||
size_t total_fds() const {
|
||||
return Genode::min(num_rd + num_wr + num_ex, (size_t)MAX_FDS); }
|
||||
return min(num_rd + num_wr + num_ex, (size_t)MAX_FDS); }
|
||||
|
||||
/**
|
||||
* Check for maximum population of fds array
|
||||
@ -240,7 +242,7 @@ namespace Noux {
|
||||
|
||||
SYSIO_DECL(fchdir, { int fd; }, { });
|
||||
|
||||
SYSIO_DECL(read, { int fd; Genode::size_t count; },
|
||||
SYSIO_DECL(read, { int fd; size_t count; },
|
||||
{ Chunk chunk; size_t count; });
|
||||
|
||||
SYSIO_DECL(execve, { Path filename; Args args; Env env; }, { });
|
||||
@ -248,8 +250,8 @@ namespace Noux {
|
||||
SYSIO_DECL(select, { Select_fds fds; Select_timeout timeout; },
|
||||
{ Select_fds fds; });
|
||||
|
||||
SYSIO_DECL(fork, { Genode::addr_t ip; Genode::addr_t sp;
|
||||
Genode::addr_t parent_cap_addr; },
|
||||
SYSIO_DECL(fork, { addr_t ip; addr_t sp;
|
||||
addr_t parent_cap_addr; },
|
||||
{ int pid; });
|
||||
|
||||
SYSIO_DECL(getpid, { }, { int pid; });
|
||||
|
@ -25,11 +25,11 @@ namespace Noux {
|
||||
{
|
||||
protected:
|
||||
|
||||
char * const _buf;
|
||||
Genode::size_t const _buf_size;
|
||||
Genode::size_t _len;
|
||||
char * const _buf;
|
||||
size_t const _buf_size;
|
||||
size_t _len;
|
||||
|
||||
Genode::size_t _free_size() const
|
||||
size_t _free_size() const
|
||||
{
|
||||
/*
|
||||
* Keep space for two trailing zeros, indicating the end of the
|
||||
@ -49,7 +49,7 @@ namespace Noux {
|
||||
* \param buf_size size of argument buffer in character,
|
||||
* must be at least 2
|
||||
*/
|
||||
Args(char *buf, Genode::size_t buf_size)
|
||||
Args(char *buf, size_t buf_size)
|
||||
: _buf(buf), _buf_size(buf_size), _len(0)
|
||||
{
|
||||
if (buf_size <= 2)
|
||||
@ -67,18 +67,18 @@ namespace Noux {
|
||||
|
||||
bool valid() const { return _buf_size > 0; }
|
||||
|
||||
Genode::size_t len() const { return _len; }
|
||||
size_t len() const { return _len; }
|
||||
|
||||
char const * const base() const { return _buf; }
|
||||
|
||||
void append(char const *arg)
|
||||
{
|
||||
Genode::size_t const arg_len = Genode::strlen(arg);
|
||||
size_t const arg_len = strlen(arg);
|
||||
|
||||
if (arg_len > _free_size())
|
||||
throw Overrun();
|
||||
|
||||
Genode::strncpy(_buf + _len, arg, _buf_size - _len);
|
||||
strncpy(_buf + _len, arg, _buf_size - _len);
|
||||
|
||||
_len += arg_len + 1; /* keep null termination between strings */
|
||||
|
||||
@ -89,27 +89,27 @@ namespace Noux {
|
||||
void dump()
|
||||
{
|
||||
for (unsigned i = 0, j = 0; _buf[i] && (i < _buf_size - 2);
|
||||
i += Genode::strlen(&_buf[i]) + 1, j++)
|
||||
i += strlen(&_buf[i]) + 1, j++)
|
||||
PINF("arg(%u): \"%s\"", j, &_buf[i]);
|
||||
}
|
||||
};
|
||||
|
||||
class Args_dataspace : private Genode::Attached_ram_dataspace, public Args
|
||||
class Args_dataspace : private Attached_ram_dataspace, public Args
|
||||
{
|
||||
public:
|
||||
|
||||
Args_dataspace(Genode::size_t size, Args const &from = Args())
|
||||
Args_dataspace(size_t size, Args const &from = Args())
|
||||
:
|
||||
Genode::Attached_ram_dataspace(Genode::env()->ram_session(), size),
|
||||
Attached_ram_dataspace(env()->ram_session(), size),
|
||||
Args(local_addr<char>(), size)
|
||||
{
|
||||
if (from.len() > size - 2)
|
||||
throw Overrun();
|
||||
|
||||
Genode::memcpy(_buf, from.base(), from.len() + 1);
|
||||
memcpy(_buf, from.base(), from.len() + 1);
|
||||
}
|
||||
|
||||
using Genode::Attached_ram_dataspace::cap;
|
||||
using Attached_ram_dataspace::cap;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**
|
||||
* Allocator for process IDs
|
||||
*/
|
||||
@ -92,12 +89,12 @@ namespace Noux {
|
||||
init_process_exited();
|
||||
} else {
|
||||
/* destroy 'Noux::Child' */
|
||||
destroy(Genode::env()->heap(), _child);
|
||||
destroy(env()->heap(), _child);
|
||||
|
||||
PINF("destroy %p", _child);
|
||||
PINF("quota: avail=%zd, used=%zd",
|
||||
Genode::env()->ram_session()->avail(),
|
||||
Genode::env()->ram_session()->used());
|
||||
env()->ram_session()->avail(),
|
||||
env()->ram_session()->used());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
class Dataspace_registry;
|
||||
|
||||
|
||||
@ -96,7 +93,7 @@ namespace Noux {
|
||||
return;
|
||||
|
||||
_pool.remove(info);
|
||||
destroy(Genode::env()->heap(), info);
|
||||
destroy(env()->heap(), info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@ namespace Noux {
|
||||
*/
|
||||
struct Directory_service
|
||||
{
|
||||
virtual Genode::Dataspace_capability dataspace(char const *path) = 0;
|
||||
virtual void release(Genode::Dataspace_capability) = 0;
|
||||
virtual Dataspace_capability dataspace(char const *path) = 0;
|
||||
virtual void release(Dataspace_capability) = 0;
|
||||
|
||||
virtual Vfs_handle *open(Sysio *sysio, char const *path) = 0;
|
||||
|
||||
|
@ -27,8 +27,7 @@ namespace Noux {
|
||||
/**
|
||||
* Front-end for PWD environment variable
|
||||
*/
|
||||
class Environment : private Genode::Attached_ram_dataspace,
|
||||
public Pwd
|
||||
class Environment : private Attached_ram_dataspace, public Pwd
|
||||
{
|
||||
private:
|
||||
|
||||
@ -44,14 +43,13 @@ namespace Noux {
|
||||
* \param env comma-separated list of environment variables
|
||||
*/
|
||||
Environment(char const *env) :
|
||||
Genode::Attached_ram_dataspace(Genode::env()->ram_session(),
|
||||
ENV_DS_SIZE),
|
||||
Attached_ram_dataspace(Genode::env()->ram_session(), ENV_DS_SIZE),
|
||||
_env(local_addr<char>())
|
||||
{
|
||||
Genode::strncpy(_env, env, ENV_DS_SIZE);
|
||||
strncpy(_env, env, ENV_DS_SIZE);
|
||||
}
|
||||
|
||||
using Genode::Attached_ram_dataspace::cap;
|
||||
using Attached_ram_dataspace::cap;
|
||||
|
||||
/**
|
||||
* Return list of environment variables as comma-separated list
|
||||
@ -88,7 +86,7 @@ namespace Noux {
|
||||
return;
|
||||
}
|
||||
|
||||
Genode::Arg_string::set_arg(_env, ENV_DS_SIZE, "PWD", quoted);
|
||||
Arg_string::set_arg(_env, ENV_DS_SIZE, "PWD", quoted);
|
||||
PINF("changed current work directory to %s", _pwd_path.base());
|
||||
}
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-2012 Genode Labs GmbH
|
||||
* Copyright (C) 2011-2012 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.
|
||||
@ -27,7 +27,7 @@
|
||||
namespace Noux {
|
||||
|
||||
class File_system : public Directory_service, public File_io_service,
|
||||
public Genode::List<File_system>::Element
|
||||
public List<File_system>::Element
|
||||
{
|
||||
private:
|
||||
|
||||
@ -38,7 +38,6 @@ namespace Noux {
|
||||
*/
|
||||
void _strip_trailing_slashes_from_mount_point()
|
||||
{
|
||||
using namespace Genode;
|
||||
size_t len;
|
||||
while ((len = strlen(_mount_point)) && (_mount_point[len - 1] == '/'))
|
||||
_mount_point[len - 1] = 0;
|
||||
@ -46,7 +45,7 @@ namespace Noux {
|
||||
|
||||
public:
|
||||
|
||||
File_system(Genode::Xml_node config)
|
||||
File_system(Xml_node config)
|
||||
{
|
||||
enum { TYPE_MAX_LEN = 64 };
|
||||
char type[TYPE_MAX_LEN];
|
||||
@ -60,7 +59,7 @@ namespace Noux {
|
||||
|
||||
File_system(char const *mount_point)
|
||||
{
|
||||
Genode::strncpy(_mount_point, mount_point, sizeof(_mount_point));
|
||||
strncpy(_mount_point, mount_point, sizeof(_mount_point));
|
||||
_strip_trailing_slashes_from_mount_point();
|
||||
}
|
||||
|
||||
@ -78,8 +77,6 @@ namespace Noux {
|
||||
*/
|
||||
char const *local_path(char const *global_path)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
size_t const mount_point_len = strlen(_mount_point);
|
||||
|
||||
if (strlen(global_path) < mount_point_len)
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
/**
|
||||
* Input/output channel interface
|
||||
*/
|
||||
|
@ -23,9 +23,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
class Rm_dataspace_info : public Dataspace_info
|
||||
{
|
||||
private:
|
||||
@ -59,7 +56,7 @@ namespace Noux {
|
||||
~Rm_dataspace_info()
|
||||
{
|
||||
_ep.dissolve(_sub_rm);
|
||||
destroy(Genode::env()->heap(), _sub_rm);
|
||||
destroy(env()->heap(), _sub_rm);
|
||||
}
|
||||
|
||||
Rm_session_capability rm_cap() { return _rm_cap; }
|
||||
@ -138,7 +135,7 @@ namespace Noux {
|
||||
Dataspace_info *info = _ds_registry.lookup_info(ds_cap);
|
||||
if (info) {
|
||||
_ds_registry.remove(info);
|
||||
destroy(Genode::env()->heap(), info);
|
||||
destroy(env()->heap(), info);
|
||||
} else {
|
||||
PWRN("Could not lookup dataspace info for local RM session");
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace Noux {
|
||||
|
||||
static bool ends_with(char c, char const *path)
|
||||
{
|
||||
return path[0] && (path[Genode::strlen(path) - 1] == c);
|
||||
return path[0] && (path[strlen(path) - 1] == c);
|
||||
}
|
||||
|
||||
static void remove_char(char *buf)
|
||||
@ -70,7 +70,7 @@ namespace Noux {
|
||||
|
||||
static bool is_empty(char const *path)
|
||||
{
|
||||
return Genode::strlen(path) == 0;
|
||||
return strlen(path) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,8 +133,8 @@ namespace Noux {
|
||||
|
||||
Path_base(const Path_base &);
|
||||
|
||||
char * const _path;
|
||||
Genode::size_t const _path_max_len;
|
||||
char * const _path;
|
||||
size_t const _path_max_len;
|
||||
|
||||
/**
|
||||
* Append 'path'
|
||||
@ -143,12 +143,12 @@ namespace Noux {
|
||||
*/
|
||||
void _append(char const *path)
|
||||
{
|
||||
Genode::size_t const orig_len = Genode::strlen(_path);
|
||||
size_t const orig_len = strlen(_path);
|
||||
|
||||
if (Genode::strlen(path) + orig_len + 1 >= _path_max_len)
|
||||
if (strlen(path) + orig_len + 1 >= _path_max_len)
|
||||
throw Path_too_long();
|
||||
|
||||
Genode::strncpy(_path + orig_len, path, _path_max_len - orig_len);
|
||||
strncpy(_path + orig_len, path, _path_max_len - orig_len);
|
||||
}
|
||||
|
||||
void _append_slash_if_needed()
|
||||
@ -175,14 +175,14 @@ namespace Noux {
|
||||
* Validate 'pwd' argument, if not supplied, enforce invariant
|
||||
* that 'pwd' is an absolute path.
|
||||
*/
|
||||
if (!pwd || Genode::strlen(pwd) == 0)
|
||||
if (!pwd || strlen(pwd) == 0)
|
||||
pwd = "/";
|
||||
|
||||
/*
|
||||
* Use argument path if absolute
|
||||
*/
|
||||
if (is_absolute(path))
|
||||
Genode::strncpy(_path, path, _path_max_len);
|
||||
strncpy(_path, path, _path_max_len);
|
||||
|
||||
/*
|
||||
* Otherwise, concatenate current working directory with
|
||||
@ -191,7 +191,7 @@ namespace Noux {
|
||||
else {
|
||||
const char *const relative_path = path;
|
||||
|
||||
Genode::strncpy(_path, pwd, _path_max_len);
|
||||
strncpy(_path, pwd, _path_max_len);
|
||||
|
||||
if (!is_empty(relative_path)) {
|
||||
|
||||
@ -207,7 +207,7 @@ namespace Noux {
|
||||
|
||||
public:
|
||||
|
||||
Path_base(char *buf, Genode::size_t buf_len,
|
||||
Path_base(char *buf, size_t buf_len,
|
||||
char const *path, char const *pwd = 0)
|
||||
:
|
||||
_path(buf), _path_max_len(buf_len)
|
||||
@ -217,8 +217,8 @@ namespace Noux {
|
||||
|
||||
void import(char const *path) { _import(path); }
|
||||
|
||||
char *base() { return _path; }
|
||||
Genode::size_t max_len() { return _path_max_len; }
|
||||
char *base() { return _path; }
|
||||
size_t max_len() { return _path_max_len; }
|
||||
|
||||
void remove_trailing(char c) { remove_trailing(c, _path); }
|
||||
|
||||
@ -231,15 +231,15 @@ namespace Noux {
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
bool equals(Path_base const &ref) const { return Genode::strcmp(ref._path, _path) == 0; }
|
||||
bool equals(Path_base const &ref) const { return strcmp(ref._path, _path) == 0; }
|
||||
|
||||
bool equals(char const *str) const { return Genode::strcmp(str, _path) == 0; }
|
||||
bool equals(char const *str) const { return strcmp(str, _path) == 0; }
|
||||
|
||||
bool strip_prefix(char const *prefix)
|
||||
{
|
||||
unsigned prefix_len = Genode::strlen(prefix);
|
||||
unsigned prefix_len = strlen(prefix);
|
||||
|
||||
if (Genode::strcmp(prefix, _path, prefix_len) != 0)
|
||||
if (strcmp(prefix, _path, prefix_len) != 0)
|
||||
return false;
|
||||
|
||||
if (prefix_len > 0 && ends_with('/', prefix))
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
class Pipe : public Reference_counter
|
||||
{
|
||||
private:
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Ram_dataspace_info : Dataspace_info,
|
||||
List<Ram_dataspace_info>::Element
|
||||
{
|
||||
@ -57,19 +55,19 @@ namespace Noux {
|
||||
|
||||
void *src = 0;
|
||||
try {
|
||||
src = Genode::env()->rm_session()->attach(ds_cap());
|
||||
src = env()->rm_session()->attach(ds_cap());
|
||||
} catch (...) { }
|
||||
|
||||
void *dst = 0;
|
||||
try {
|
||||
dst = Genode::env()->rm_session()->attach(dst_ds);
|
||||
dst = env()->rm_session()->attach(dst_ds);
|
||||
} catch (...) { }
|
||||
|
||||
if (src && dst)
|
||||
memcpy(dst, src, size);
|
||||
|
||||
if (src) Genode::env()->rm_session()->detach(src);
|
||||
if (dst) Genode::env()->rm_session()->detach(dst);
|
||||
if (src) env()->rm_session()->detach(src);
|
||||
if (dst) env()->rm_session()->detach(dst);
|
||||
|
||||
if (!src || !dst) {
|
||||
Ram_session_client(ram).free(dst_ds);
|
||||
@ -88,13 +86,13 @@ namespace Noux {
|
||||
|
||||
char *dst = 0;
|
||||
try {
|
||||
dst = Genode::env()->rm_session()->attach(ds_cap());
|
||||
dst = env()->rm_session()->attach(ds_cap());
|
||||
} catch (...) { }
|
||||
|
||||
if (src && dst)
|
||||
memcpy(dst + dst_offset, src, len);
|
||||
|
||||
if (dst) Genode::env()->rm_session()->detach(dst);
|
||||
if (dst) env()->rm_session()->detach(dst);
|
||||
}
|
||||
};
|
||||
|
||||
@ -167,7 +165,7 @@ namespace Noux {
|
||||
_used_quota -= ds_info->size();
|
||||
|
||||
env()->ram_session()->free(ds_cap);
|
||||
Genode::destroy(env()->heap(), ds_info);
|
||||
destroy(env()->heap(), ds_info);
|
||||
}
|
||||
|
||||
int ref_account(Ram_session_capability) { return 0; }
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
class Rm_session_component : public Rpc_object<Rm_session>
|
||||
{
|
||||
private:
|
||||
@ -207,7 +205,7 @@ namespace Noux {
|
||||
* Record attachement for later replay (needed during
|
||||
* fork)
|
||||
*/
|
||||
_regions.insert(new (Genode::env()->heap())
|
||||
_regions.insert(new (env()->heap())
|
||||
Region(ds, size, offset, local_addr));
|
||||
return local_addr;
|
||||
}
|
||||
@ -224,7 +222,7 @@ namespace Noux {
|
||||
}
|
||||
|
||||
_regions.remove(region);
|
||||
destroy(Genode::env()->heap(), region);
|
||||
destroy(env()->heap(), region);
|
||||
}
|
||||
|
||||
Pager_capability add_client(Thread_capability thread)
|
||||
|
@ -27,7 +27,7 @@ namespace Noux {
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Lock _lock;
|
||||
Lock _lock;
|
||||
|
||||
public:
|
||||
|
||||
@ -49,7 +49,7 @@ namespace Noux {
|
||||
|
||||
bool dirent(Sysio *sysio, char const *path)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
int const index = sysio->dirent_in.index;
|
||||
if (index) {
|
||||
@ -58,8 +58,8 @@ namespace Noux {
|
||||
}
|
||||
sysio->dirent_out.entry.fileno = 13;
|
||||
|
||||
Genode::strncpy(sysio->dirent_out.entry.name, "test",
|
||||
sizeof(sysio->dirent_out.entry.name));
|
||||
strncpy(sysio->dirent_out.entry.name, "test",
|
||||
sizeof(sysio->dirent_out.entry.name));
|
||||
|
||||
sysio->dirent_out.entry.type = Sysio::DIRENT_TYPE_DIRECTORY;
|
||||
return true;
|
||||
@ -67,18 +67,18 @@ namespace Noux {
|
||||
|
||||
Vfs_handle *open(Sysio *sysio, char const *path)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
if (Genode::strcmp(path, "/") == 0)
|
||||
return new (Genode::env()->heap()) Vfs_handle(this, this, 0);
|
||||
if (strcmp(path, "/") == 0)
|
||||
return new (env()->heap()) Vfs_handle(this, this, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void close(Vfs_handle *handle)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Genode::destroy(Genode::env()->heap(), handle);
|
||||
Lock::Guard guard(_lock);
|
||||
destroy(env()->heap(), handle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,14 +32,14 @@ namespace Noux {
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Lock _lock;
|
||||
long _value;
|
||||
Lock _lock;
|
||||
long _value;
|
||||
|
||||
friend class Shared_pointer_base;
|
||||
|
||||
void _inc_ref_count()
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Lock::Guard guard(_lock);
|
||||
_value++;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Noux {
|
||||
*/
|
||||
long _dec_ref_count()
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Lock::Guard guard(_lock);
|
||||
return --_value;
|
||||
}
|
||||
|
||||
@ -82,8 +82,8 @@ namespace Noux {
|
||||
{
|
||||
private:
|
||||
|
||||
T *_ptr;
|
||||
Genode::Allocator *_alloc;
|
||||
T *_ptr;
|
||||
Allocator *_alloc;
|
||||
|
||||
void _dec_ref_count()
|
||||
{
|
||||
@ -92,7 +92,7 @@ namespace Noux {
|
||||
if (0)
|
||||
PINF("ref count for %p reached zero -> delete object", _ptr);
|
||||
|
||||
Genode::destroy(_alloc, _ptr);
|
||||
destroy(_alloc, _ptr);
|
||||
_ptr = 0;
|
||||
_alloc = 0;
|
||||
_ref_counter = 0;
|
||||
@ -103,7 +103,7 @@ namespace Noux {
|
||||
|
||||
Shared_pointer() : Shared_pointer_base(0), _ptr(0), _alloc(0) { }
|
||||
|
||||
Shared_pointer(T *ptr, Genode::Allocator *alloc)
|
||||
Shared_pointer(T *ptr, Allocator *alloc)
|
||||
: Shared_pointer_base(ptr), _ptr(ptr), _alloc(alloc)
|
||||
{
|
||||
_inc_ref_count();
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
struct Signal_dispatcher : public Genode::Signal_context
|
||||
struct Signal_dispatcher : public Signal_context
|
||||
{
|
||||
virtual void dispatch() = 0;
|
||||
};
|
||||
|
@ -27,23 +27,22 @@ namespace Noux {
|
||||
|
||||
class Tar_file_system : public File_system
|
||||
{
|
||||
Genode::Lock _lock;
|
||||
Lock _lock;
|
||||
|
||||
struct Rom_name
|
||||
{
|
||||
enum { ROM_NAME_MAX_LEN = 64 };
|
||||
char name[ROM_NAME_MAX_LEN];
|
||||
|
||||
Rom_name(Genode::Xml_node config) {
|
||||
Rom_name(Xml_node config) {
|
||||
config.attribute("name").value(name, sizeof(name));
|
||||
}
|
||||
} _rom_name;
|
||||
|
||||
Genode::Rom_connection _rom;
|
||||
Rom_connection _rom;
|
||||
|
||||
|
||||
char *_tar_base;
|
||||
Genode::size_t _tar_size;
|
||||
char *_tar_base;
|
||||
size_t _tar_size;
|
||||
|
||||
class Record
|
||||
{
|
||||
@ -70,10 +69,10 @@ namespace Noux {
|
||||
* large enough to host an additional zero.
|
||||
*/
|
||||
char buf[sizeof(field) + 1];
|
||||
Genode::strncpy(buf, field, sizeof(buf));
|
||||
strncpy(buf, field, sizeof(buf));
|
||||
|
||||
unsigned long value = 0;
|
||||
Genode::ascii_to(buf, &value, 8);
|
||||
ascii_to(buf, &value, 8);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -86,7 +85,7 @@ namespace Noux {
|
||||
enum { TYPE_FILE = 0, TYPE_HARDLINK = 1,
|
||||
TYPE_SYMLINK = 2, TYPE_DIR = 5 };
|
||||
|
||||
Genode::size_t size() const { return _read(_size); }
|
||||
size_t size() const { return _read(_size); }
|
||||
unsigned uid() const { return _read(_uid); }
|
||||
unsigned gid() const { return _read(_gid); }
|
||||
unsigned mode() const { return _read(_mode); }
|
||||
@ -131,7 +130,6 @@ namespace Noux {
|
||||
|
||||
static void _remove_trailing_slashes(char *str)
|
||||
{
|
||||
using namespace Genode;
|
||||
size_t len = 0;
|
||||
while ((len = strlen(str)) && (str[len - 1] == '/'))
|
||||
str[len - 1] = 0;
|
||||
@ -207,7 +205,7 @@ namespace Noux {
|
||||
if (criterion->match(record->name()))
|
||||
return record;
|
||||
|
||||
Genode::size_t file_size = record->size();
|
||||
size_t file_size = record->size();
|
||||
|
||||
/* some datablocks */ /* one metablock */
|
||||
block_id = block_id + (file_size / Record::BLOCK_LEN) + 1;
|
||||
@ -231,11 +229,11 @@ namespace Noux {
|
||||
|
||||
public:
|
||||
|
||||
Tar_file_system(Genode::Xml_node config)
|
||||
Tar_file_system(Xml_node config)
|
||||
:
|
||||
File_system(config), _rom_name(config), _rom(_rom_name.name),
|
||||
_tar_base(Genode::env()->rm_session()->attach(_rom.dataspace())),
|
||||
_tar_size(Genode::Dataspace_client(_rom.dataspace()).size())
|
||||
_tar_base(env()->rm_session()->attach(_rom.dataspace())),
|
||||
_tar_size(Dataspace_client(_rom.dataspace()).size())
|
||||
{
|
||||
PINF("tar archive '%s' local at %p, size is %zd",
|
||||
_rom_name.name, _tar_base, _tar_size);
|
||||
@ -246,10 +244,8 @@ namespace Noux {
|
||||
** Directory-service interface **
|
||||
*********************************/
|
||||
|
||||
Genode::Dataspace_capability dataspace(char const *path)
|
||||
Dataspace_capability dataspace(char const *path)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
/*
|
||||
* Walk hardlinks until we reach a file
|
||||
*/
|
||||
@ -288,7 +284,7 @@ namespace Noux {
|
||||
return Dataspace_capability();
|
||||
}
|
||||
|
||||
void release(Genode::Dataspace_capability ds_cap)
|
||||
void release(Dataspace_capability ds_cap)
|
||||
{
|
||||
env()->ram_session()->free(static_cap_cast<Ram_dataspace>(ds_cap));
|
||||
}
|
||||
@ -321,7 +317,7 @@ namespace Noux {
|
||||
|
||||
bool dirent(Sysio *sysio, char const *path)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
int const index = sysio->dirent_in.index;
|
||||
|
||||
@ -345,9 +341,9 @@ namespace Noux {
|
||||
absolute_path.keep_only_last_element();
|
||||
absolute_path.remove_trailing('/');
|
||||
|
||||
Genode::strncpy(sysio->dirent_out.entry.name,
|
||||
absolute_path.base() + 1,
|
||||
sizeof(sysio->dirent_out.entry.name));
|
||||
strncpy(sysio->dirent_out.entry.name,
|
||||
absolute_path.base() + 1,
|
||||
sizeof(sysio->dirent_out.entry.name));
|
||||
|
||||
PWRN("direntry in %s: %s", path, absolute_path.base() + 1);
|
||||
return true;
|
||||
@ -355,14 +351,14 @@ namespace Noux {
|
||||
|
||||
Vfs_handle *open(Sysio *sysio, char const *path)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
PDBG("open %s", path);
|
||||
|
||||
Lookup_exact lookup_criterion(path);
|
||||
Record *record = 0;
|
||||
if ((record = _lookup(&lookup_criterion)))
|
||||
return new (Genode::env()->heap())
|
||||
return new (env()->heap())
|
||||
Tar_vfs_handle(this, 0, record);
|
||||
|
||||
sysio->error.open = Sysio::OPEN_ERR_UNACCESSIBLE;
|
||||
@ -371,8 +367,8 @@ namespace Noux {
|
||||
|
||||
void close(Vfs_handle *handle)
|
||||
{
|
||||
Genode::Lock::Guard guard(_lock);
|
||||
Genode::destroy(Genode::env()->heap(), handle);
|
||||
Lock::Guard guard(_lock);
|
||||
destroy(env()->heap(), handle);
|
||||
}
|
||||
|
||||
|
||||
@ -388,8 +384,6 @@ namespace Noux {
|
||||
|
||||
bool read(Sysio *sysio, Vfs_handle *vfs_handle)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
Tar_vfs_handle const *handle = static_cast<Tar_vfs_handle *>(vfs_handle);
|
||||
|
||||
size_t const record_size = handle->record()->size();
|
||||
|
@ -27,14 +27,14 @@ namespace Noux {
|
||||
|
||||
struct Terminal_io_channel : Io_channel, Signal_dispatcher
|
||||
{
|
||||
Terminal::Session &terminal;
|
||||
Genode::Signal_receiver &sig_rec;
|
||||
bool eof;
|
||||
Terminal::Session &terminal;
|
||||
Signal_receiver &sig_rec;
|
||||
bool eof;
|
||||
|
||||
enum Type { STDIN, STDOUT, STDERR } type;
|
||||
|
||||
Terminal_io_channel(Terminal::Session &terminal, Type type,
|
||||
Genode::Signal_receiver &sig_rec)
|
||||
Signal_receiver &sig_rec)
|
||||
: terminal(terminal), sig_rec(sig_rec), eof(false), type(type)
|
||||
{
|
||||
/*
|
||||
@ -76,9 +76,9 @@ namespace Noux {
|
||||
return true;
|
||||
}
|
||||
|
||||
Genode::size_t const max_count =
|
||||
Genode::min(sysio->read_in.count,
|
||||
sizeof(sysio->read_out.chunk));
|
||||
size_t const max_count =
|
||||
min(sysio->read_in.count,
|
||||
sizeof(sysio->read_out.chunk));
|
||||
|
||||
sysio->read_out.count =
|
||||
terminal.read(sysio->read_out.chunk, max_count);
|
||||
|
@ -31,23 +31,23 @@ namespace Noux {
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::List<File_system> _file_systems;
|
||||
List<File_system> _file_systems;
|
||||
|
||||
public:
|
||||
|
||||
Genode::Dataspace_capability dataspace_from_file(char const *filename)
|
||||
Dataspace_capability dataspace_from_file(char const *filename)
|
||||
{
|
||||
for (File_system *fs = _file_systems.first(); fs; fs = fs->next()) {
|
||||
char const *fs_local_path = fs->local_path(filename);
|
||||
Genode::Dataspace_capability ds_cap;
|
||||
Dataspace_capability ds_cap;
|
||||
if (fs_local_path && (ds_cap = fs->dataspace(fs_local_path)).valid())
|
||||
return ds_cap;
|
||||
}
|
||||
return Genode::Dataspace_capability();
|
||||
return Dataspace_capability();
|
||||
}
|
||||
|
||||
void release_dataspace_for_file(char const *filename,
|
||||
Genode::Dataspace_capability ds_cap)
|
||||
Dataspace_capability ds_cap)
|
||||
{
|
||||
for (File_system *fs = _file_systems.first(); fs; fs = fs->next()) {
|
||||
char const *fs_local_path = fs->local_path(filename);
|
||||
|
@ -34,7 +34,7 @@ namespace Noux {
|
||||
Directory_service *_ds;
|
||||
File_io_service *_fs;
|
||||
int _status_flags;
|
||||
Genode::size_t _seek;
|
||||
size_t _seek;
|
||||
|
||||
friend class Vfs_io_channel; /* for modifying '_seek' */
|
||||
|
||||
@ -45,13 +45,13 @@ namespace Noux {
|
||||
static bool _msg(char const *sc) {
|
||||
PERR("%s not supported by directory service", sc); return false; }
|
||||
|
||||
Genode::Dataspace_capability dataspace(char const *)
|
||||
Dataspace_capability dataspace(char const *)
|
||||
{
|
||||
_msg("dataspace");
|
||||
return Genode::Dataspace_capability();
|
||||
return Dataspace_capability();
|
||||
}
|
||||
|
||||
void release(Genode::Dataspace_capability) { }
|
||||
void release(Dataspace_capability) { }
|
||||
|
||||
bool stat(Sysio *, char const *) { return _msg("stat"); }
|
||||
Vfs_handle *open(Sysio *, char const *) { _msg("open"); return 0; }
|
||||
@ -93,7 +93,7 @@ namespace Noux {
|
||||
|
||||
int status_flags() { return _status_flags; }
|
||||
|
||||
Genode::size_t seek() const { return _seek; }
|
||||
size_t seek() const { return _seek; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,9 @@ namespace Noux {
|
||||
unsigned const index = sysio->dirent_in.index;
|
||||
if (index < 2) {
|
||||
sysio->dirent_out.entry.type = Sysio::DIRENT_TYPE_DIRECTORY;
|
||||
Genode::strncpy(sysio->dirent_out.entry.name,
|
||||
index ? ".." : ".",
|
||||
sizeof(sysio->dirent_out.entry.name));
|
||||
strncpy(sysio->dirent_out.entry.name,
|
||||
index ? ".." : ".",
|
||||
sizeof(sysio->dirent_out.entry.name));
|
||||
|
||||
sysio->dirent_out.entry.fileno = 1;
|
||||
return true;
|
||||
|
@ -20,11 +20,11 @@
|
||||
|
||||
namespace Noux {
|
||||
|
||||
struct Wake_up_notifier : Genode::List<Wake_up_notifier>::Element
|
||||
struct Wake_up_notifier : List<Wake_up_notifier>::Element
|
||||
{
|
||||
Genode::Semaphore *semaphore;
|
||||
Semaphore *semaphore;
|
||||
|
||||
Wake_up_notifier(Genode::Semaphore *semaphore = 0)
|
||||
Wake_up_notifier(Semaphore *semaphore = 0)
|
||||
: semaphore(semaphore) { }
|
||||
|
||||
void wake_up()
|
||||
|
Loading…
x
Reference in New Issue
Block a user