mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-03 12:34:12 +00:00
parent
9b21c88bc6
commit
5d434944eb
@ -44,6 +44,7 @@ namespace Libc {
|
|||||||
|
|
||||||
virtual int priority();
|
virtual int priority();
|
||||||
|
|
||||||
|
virtual bool supports_access(char const *path, int amode);
|
||||||
virtual bool supports_execve(char const *filename, char *const argv[],
|
virtual bool supports_execve(char const *filename, char *const argv[],
|
||||||
char *const envp[]);
|
char *const envp[]);
|
||||||
virtual bool supports_mkdir(const char *path, mode_t mode);
|
virtual bool supports_mkdir(const char *path, mode_t mode);
|
||||||
@ -70,6 +71,7 @@ namespace Libc {
|
|||||||
virtual File_descriptor *accept(File_descriptor *,
|
virtual File_descriptor *accept(File_descriptor *,
|
||||||
struct ::sockaddr *addr,
|
struct ::sockaddr *addr,
|
||||||
socklen_t *addrlen);
|
socklen_t *addrlen);
|
||||||
|
virtual int access(char const *, int);
|
||||||
virtual int bind(File_descriptor *,
|
virtual int bind(File_descriptor *,
|
||||||
const struct ::sockaddr *addr,
|
const struct ::sockaddr *addr,
|
||||||
socklen_t addrlen);
|
socklen_t addrlen);
|
||||||
|
@ -25,6 +25,7 @@ namespace Libc {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Plugin *get_plugin_for_access(char const *pathname, int amode);
|
||||||
Plugin *get_plugin_for_execve(char const *filename, char *const argv[],
|
Plugin *get_plugin_for_execve(char const *filename, char *const argv[],
|
||||||
char *const envp[]);
|
char *const envp[]);
|
||||||
Plugin *get_plugin_for_freeaddrinfo(struct addrinfo *res);
|
Plugin *get_plugin_for_freeaddrinfo(struct addrinfo *res);
|
||||||
|
@ -43,7 +43,6 @@ ret_type name args \
|
|||||||
return ret_val; \
|
return ret_val; \
|
||||||
}
|
}
|
||||||
|
|
||||||
DUMMY(int , -1, access, (const char *, int))
|
|
||||||
DUMMY(int , -1, chmod, (const char *, mode_t))
|
DUMMY(int , -1, chmod, (const char *, mode_t))
|
||||||
DUMMY(int , -1, chown, (const char *, uid_t, gid_t))
|
DUMMY(int , -1, chown, (const char *, uid_t, gid_t))
|
||||||
DUMMY(int , -1, chroot, (const char *))
|
DUMMY(int , -1, chroot, (const char *))
|
||||||
|
@ -214,6 +214,19 @@ static void resolve_symlinks_except_last_element(char const *path, Absolute_path
|
|||||||
** Libc functions **
|
** Libc functions **
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
|
extern "C" int access(const char *path, int amode)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Absolute_path resolved_path;
|
||||||
|
resolve_symlinks(path, resolved_path);
|
||||||
|
FNAME_FUNC_WRAPPER(access, resolved_path.base(), amode);
|
||||||
|
} catch (Symlink_resolve_error) {
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" int chdir(const char *path)
|
extern "C" int chdir(const char *path)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
@ -42,6 +42,12 @@ int Plugin::priority()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Plugin::supports_access(char const *path, int amode)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Plugin::supports_execve(char const *filename, char *const argv[],
|
bool Plugin::supports_execve(char const *filename, char *const argv[],
|
||||||
char *const envp[])
|
char *const envp[])
|
||||||
{
|
{
|
||||||
@ -189,6 +195,7 @@ DUMMY(ssize_t, -1, write, (File_descriptor *, const void *, ::size_t));
|
|||||||
/*
|
/*
|
||||||
* Misc
|
* Misc
|
||||||
*/
|
*/
|
||||||
|
DUMMY(int, -1, access, (char const *, int));
|
||||||
DUMMY(int, -1, execve, (char const *, char *const[], char *const[]));
|
DUMMY(int, -1, execve, (char const *, char *const[], char *const[]));
|
||||||
DUMMY(void, , freeaddrinfo, (struct ::addrinfo *));
|
DUMMY(void, , freeaddrinfo, (struct ::addrinfo *));
|
||||||
DUMMY(int, -1, getaddrinfo, (const char *, const char *, const struct ::addrinfo *, struct ::addrinfo **));
|
DUMMY(int, -1, getaddrinfo, (const char *, const char *, const struct ::addrinfo *, struct ::addrinfo **));
|
||||||
|
@ -37,6 +37,9 @@ using namespace Libc;
|
|||||||
} \
|
} \
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
Plugin *Plugin_registry::get_plugin_for_access(char const *path, int amode) {
|
||||||
|
GET_PLUGIN_FOR(access, path, amode) }
|
||||||
|
|
||||||
Plugin *Plugin_registry::get_plugin_for_execve(char const *filename, char *const argv[],
|
Plugin *Plugin_registry::get_plugin_for_execve(char const *filename, char *const argv[],
|
||||||
char *const envp[]) {
|
char *const envp[]) {
|
||||||
GET_PLUGIN_FOR(execve, filename, argv, envp) }
|
GET_PLUGIN_FOR(execve, filename, argv, envp) }
|
||||||
|
@ -210,6 +210,7 @@ class Libc::Vfs_plugin : public Libc::Plugin
|
|||||||
|
|
||||||
~Vfs_plugin() { }
|
~Vfs_plugin() { }
|
||||||
|
|
||||||
|
bool supports_access(const char *, int) override { return true; }
|
||||||
bool supports_mkdir(const char *, mode_t) override { return true; }
|
bool supports_mkdir(const char *, mode_t) override { return true; }
|
||||||
bool supports_open(const char *, int) override { return true; }
|
bool supports_open(const char *, int) override { return true; }
|
||||||
bool supports_readlink(const char *, char *, size_t) override { return true; }
|
bool supports_readlink(const char *, char *, size_t) override { return true; }
|
||||||
@ -227,6 +228,7 @@ class Libc::Vfs_plugin : public Libc::Plugin
|
|||||||
return open(path, flags, Libc::ANY_FD);
|
return open(path, flags, Libc::ANY_FD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int access(char const *, int) override;
|
||||||
int close(Libc::File_descriptor *) override;
|
int close(Libc::File_descriptor *) override;
|
||||||
int dup2(Libc::File_descriptor *, Libc::File_descriptor *) override;
|
int dup2(Libc::File_descriptor *, Libc::File_descriptor *) override;
|
||||||
int fcntl(Libc::File_descriptor *, int, long) override;
|
int fcntl(Libc::File_descriptor *, int, long) override;
|
||||||
@ -251,6 +253,10 @@ class Libc::Vfs_plugin : public Libc::Plugin
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int Libc::Vfs_plugin::access(const char *path, int amode) {
|
||||||
|
return _root_dir.leaf_path(path) ? 0 : -1; }
|
||||||
|
|
||||||
|
|
||||||
Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags,
|
Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags,
|
||||||
int libc_fd)
|
int libc_fd)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user