2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Plugin implementation
|
|
|
|
* \author Christian Prochaska
|
|
|
|
* \date 2010-01-21
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
#include <base/log.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* libc plugin interface */
|
|
|
|
#include <libc-plugin/fd_alloc.h>
|
|
|
|
#include <libc-plugin/plugin_registry.h>
|
|
|
|
#include <libc-plugin/plugin.h>
|
|
|
|
|
2019-04-26 12:47:33 +02:00
|
|
|
/* local includes */
|
libc: split task.cc into multiple files
This patch is the first step of re-organizing the internal structure of
the libc. The original version involved many direct calls of global
functions (often with side effects) across compilation units, which
made the control flow (e.g., the initialization sequence) hard to
follow.
The new version replaces those ad-hoc interactions with dedicated
interfaces (like suspend.h, resume.h, select.h, current_time.h). The
underlying facilities are provided by the central Libc::Kernel and
selectively propagated to the various compilation units. The latter is
done by a sequence of 'init_*' calls, which eventually will be replaced
by constructor calls.
The addition of new headers increases the chance for name clashes with
existing (public) headers. To disambiguate libc-internal header files
from public headers, this patch moves the former into a new 'internal/'
subdirectory. This makes the include directives easier to follow and the
libc's source-tree structure more tidy.
There are still a few legacies left, which cannot easily be removed
right now (e.g., because noux relies on them). However, the patch moves
those bad apples to legacy.h and legacy.cc, which highlights the
deprecation of those functions.
Issue #3497
2019-09-18 20:19:10 +02:00
|
|
|
#include <internal/init.h>
|
|
|
|
#include <internal/resume.h>
|
2019-04-26 12:47:33 +02:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
using namespace Genode;
|
|
|
|
using namespace Libc;
|
|
|
|
|
|
|
|
|
libc: split task.cc into multiple files
This patch is the first step of re-organizing the internal structure of
the libc. The original version involved many direct calls of global
functions (often with side effects) across compilation units, which
made the control flow (e.g., the initialization sequence) hard to
follow.
The new version replaces those ad-hoc interactions with dedicated
interfaces (like suspend.h, resume.h, select.h, current_time.h). The
underlying facilities are provided by the central Libc::Kernel and
selectively propagated to the various compilation units. The latter is
done by a sequence of 'init_*' calls, which eventually will be replaced
by constructor calls.
The addition of new headers increases the chance for name clashes with
existing (public) headers. To disambiguate libc-internal header files
from public headers, this patch moves the former into a new 'internal/'
subdirectory. This makes the include directives easier to follow and the
libc's source-tree structure more tidy.
There are still a few legacies left, which cannot easily be removed
right now (e.g., because noux relies on them). However, the patch moves
those bad apples to legacy.h and legacy.cc, which highlights the
deprecation of those functions.
Issue #3497
2019-09-18 20:19:10 +02:00
|
|
|
static Libc::Resume *_resume_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
void Libc::init_plugin(Resume &resume)
|
|
|
|
{
|
|
|
|
_resume_ptr = &resume;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-26 12:47:33 +02:00
|
|
|
void Plugin::resume_all()
|
|
|
|
{
|
libc: split task.cc into multiple files
This patch is the first step of re-organizing the internal structure of
the libc. The original version involved many direct calls of global
functions (often with side effects) across compilation units, which
made the control flow (e.g., the initialization sequence) hard to
follow.
The new version replaces those ad-hoc interactions with dedicated
interfaces (like suspend.h, resume.h, select.h, current_time.h). The
underlying facilities are provided by the central Libc::Kernel and
selectively propagated to the various compilation units. The latter is
done by a sequence of 'init_*' calls, which eventually will be replaced
by constructor calls.
The addition of new headers increases the chance for name clashes with
existing (public) headers. To disambiguate libc-internal header files
from public headers, this patch moves the former into a new 'internal/'
subdirectory. This makes the include directives easier to follow and the
libc's source-tree structure more tidy.
There are still a few legacies left, which cannot easily be removed
right now (e.g., because noux relies on them). However, the patch moves
those bad apples to legacy.h and legacy.cc, which highlights the
deprecation of those functions.
Issue #3497
2019-09-18 20:19:10 +02:00
|
|
|
struct Missing_call_of_init_plugin : Exception { };
|
|
|
|
if (!_resume_ptr)
|
|
|
|
throw Missing_call_of_init_plugin();
|
|
|
|
|
|
|
|
_resume_ptr->resume_all();
|
2019-04-26 12:47:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
Plugin::Plugin(int priority)
|
|
|
|
: _priority(priority)
|
|
|
|
{
|
|
|
|
plugin_registry()->insert(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Plugin::~Plugin()
|
|
|
|
{
|
|
|
|
plugin_registry()->remove(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Plugin::priority()
|
|
|
|
{
|
|
|
|
return _priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-18 11:10:29 +02:00
|
|
|
bool Plugin::supports_access(char const *path, int amode)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
bool Plugin::supports_mkdir(const char *, mode_t)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Plugin::supports_open(const char *, int)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Plugin::supports_pipe()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-26 12:47:33 +02:00
|
|
|
bool Plugin::supports_poll()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-15 14:40:37 +02:00
|
|
|
bool Plugin::supports_readlink(const char *path, char *buf, ::size_t bufsiz)
|
2012-10-08 14:44:31 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
bool Plugin::supports_rename(const char *, const char *)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-18 22:58:04 +02:00
|
|
|
bool Plugin::supports_rmdir(const char*)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
bool Plugin::supports_select(int, fd_set *, fd_set *,
|
|
|
|
fd_set *, struct timeval *)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Plugin::supports_socket(int, int, int)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Plugin::supports_stat(const char*)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-08 14:44:31 +02:00
|
|
|
bool Plugin::supports_symlink(const char*, const char *)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-17 08:27:15 +02:00
|
|
|
|
2012-10-08 14:44:31 +02:00
|
|
|
bool Plugin::supports_unlink(const char*)
|
2012-08-17 08:27:15 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-08 14:44:31 +02:00
|
|
|
bool Plugin::supports_mmap()
|
2012-01-09 21:30:25 +01:00
|
|
|
{
|
2012-10-08 14:44:31 +02:00
|
|
|
return false;
|
2012-01-09 21:30:25 +01:00
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-10-08 14:44:31 +02:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/**
|
|
|
|
* Generate dummy member function of Plugin class
|
|
|
|
*/
|
|
|
|
#define DUMMY(ret_type, ret_val, name, args) \
|
|
|
|
ret_type Plugin::name args \
|
|
|
|
{ \
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::error(__func__, ": " #name " not implemented"); \
|
2011-12-22 16:19:25 +01:00
|
|
|
return ret_val; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions returning a 'File_descriptor'
|
|
|
|
*/
|
2012-11-09 17:39:04 +01:00
|
|
|
DUMMY(File_descriptor *, 0, dup, (File_descriptor *));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(File_descriptor *, 0, open, (const char *, int));
|
|
|
|
DUMMY(File_descriptor *, 0, socket, (int, int, int));
|
|
|
|
DUMMY(File_descriptor *, 0, accept, (File_descriptor *, struct sockaddr *, socklen_t *));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions taking a file descriptor as first argument
|
|
|
|
*/
|
|
|
|
DUMMY(int, -1, bind, (File_descriptor *, const struct sockaddr *, socklen_t));
|
|
|
|
DUMMY(int, -1, close, (File_descriptor *));
|
|
|
|
DUMMY(int, -1, connect, (File_descriptor *, const struct sockaddr *, socklen_t));
|
|
|
|
DUMMY(int, -1, dup2, (File_descriptor *, File_descriptor *new_fd));
|
|
|
|
DUMMY(int, -1, fstatfs, (File_descriptor *, struct statfs *));
|
|
|
|
DUMMY(int, -1, fcntl, (File_descriptor *, int cmd, long arg));
|
|
|
|
DUMMY(int, -1, fstat, (File_descriptor *, struct stat *));
|
|
|
|
DUMMY(int, -1, fsync, (File_descriptor *));
|
2012-08-02 15:17:24 +02:00
|
|
|
DUMMY(int, -1, ftruncate, (File_descriptor *, ::off_t));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(ssize_t, -1, getdirentries, (File_descriptor *, char *, ::size_t, ::off_t *));
|
|
|
|
DUMMY(int, -1, getpeername, (File_descriptor *, struct sockaddr *, socklen_t *));
|
|
|
|
DUMMY(int, -1, getsockname, (File_descriptor *, struct sockaddr *, socklen_t *));
|
|
|
|
DUMMY(int, -1, getsockopt, (File_descriptor *, int, int, void *, socklen_t *));
|
|
|
|
DUMMY(int, -1, ioctl, (File_descriptor *, int, char*));
|
|
|
|
DUMMY(int, -1, listen, (File_descriptor *, int));
|
|
|
|
DUMMY(::off_t, -1, lseek, (File_descriptor *, ::off_t, int));
|
|
|
|
DUMMY(ssize_t, -1, read, (File_descriptor *, void *, ::size_t));
|
|
|
|
DUMMY(ssize_t, -1, recv, (File_descriptor *, void *, ::size_t, int));
|
|
|
|
DUMMY(ssize_t, -1, recvfrom, (File_descriptor *, void *, ::size_t, int, struct sockaddr *, socklen_t *));
|
2012-05-24 15:26:59 +02:00
|
|
|
DUMMY(ssize_t, -1, recvmsg, (File_descriptor *, struct msghdr *, int));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(ssize_t, -1, send, (File_descriptor *, const void *, ::size_t, int));
|
|
|
|
DUMMY(ssize_t, -1, sendto, (File_descriptor *, const void *, ::size_t, int, const struct sockaddr *, socklen_t));
|
|
|
|
DUMMY(int, -1, setsockopt, (File_descriptor *, int, int, const void *, socklen_t));
|
2012-05-24 15:26:59 +02:00
|
|
|
DUMMY(int, -1, shutdown, (File_descriptor *, int));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(ssize_t, -1, write, (File_descriptor *, const void *, ::size_t));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Misc
|
|
|
|
*/
|
2015-09-18 11:10:29 +02:00
|
|
|
DUMMY(int, -1, access, (char const *, int));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(int, -1, mkdir, (const char*, mode_t));
|
|
|
|
DUMMY(void *, (void *)(-1), mmap, (void *addr, ::size_t length, int prot, int flags,
|
|
|
|
File_descriptor *, ::off_t offset));
|
2012-08-17 08:27:15 +02:00
|
|
|
DUMMY(int, -1, munmap, (void *, ::size_t));
|
2017-07-26 01:53:01 +02:00
|
|
|
DUMMY(int, -1, msync, (void *addr, ::size_t len, int flags));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(int, -1, pipe, (File_descriptor*[2]));
|
2019-04-26 12:47:33 +02:00
|
|
|
DUMMY(bool, 0, poll, (File_descriptor &, struct pollfd &));
|
2016-09-15 14:40:37 +02:00
|
|
|
DUMMY(ssize_t, -1, readlink, (const char *, char *, ::size_t));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(int, -1, rename, (const char *, const char *));
|
2014-04-18 22:58:04 +02:00
|
|
|
DUMMY(int, -1, rmdir, (const char*));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(int, -1, select, (int, fd_set *, fd_set *, fd_set *, struct timeval *));
|
|
|
|
DUMMY(int, -1, stat, (const char*, struct stat*));
|
2012-10-08 14:44:31 +02:00
|
|
|
DUMMY(int, -1, symlink, (const char*, const char*));
|
2011-12-22 16:19:25 +01:00
|
|
|
DUMMY(int, -1, unlink, (const char*));
|