2018-04-03 13:59:35 +00:00
|
|
|
/*
|
|
|
|
* \brief Cross-plugin VFS environment
|
|
|
|
* \author Emery Hemingway
|
2022-12-02 08:53:16 +00:00
|
|
|
* \author Norman Feske
|
2018-04-03 13:59:35 +00:00
|
|
|
* \date 2018-04-04
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Genode Labs GmbH
|
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__VFS__SIMPLE_ENV_H_
|
|
|
|
#define _INCLUDE__VFS__SIMPLE_ENV_H_
|
|
|
|
|
|
|
|
#include <vfs/file_system_factory.h>
|
|
|
|
#include <vfs/dir_file_system.h>
|
|
|
|
#include <vfs/env.h>
|
|
|
|
|
|
|
|
namespace Vfs { struct Simple_env; }
|
|
|
|
|
2022-12-02 08:53:16 +00:00
|
|
|
|
2022-12-07 13:06:35 +00:00
|
|
|
class Vfs::Simple_env : public Vfs::Env, private Vfs::Env::Io, private Vfs::Env::User
|
2018-04-03 13:59:35 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
Genode::Env &_env;
|
|
|
|
Genode::Allocator &_alloc;
|
2022-12-07 13:06:35 +00:00
|
|
|
Vfs::Env::User &_user;
|
2018-04-03 13:59:35 +00:00
|
|
|
|
2022-12-02 08:53:16 +00:00
|
|
|
Global_file_system_factory _fs_factory { _alloc };
|
|
|
|
|
|
|
|
Dir_file_system _root_dir;
|
|
|
|
|
|
|
|
using Deferred_wakeups = Remote_io::Deferred_wakeups;
|
2018-04-03 13:59:35 +00:00
|
|
|
|
2022-12-02 08:53:16 +00:00
|
|
|
Deferred_wakeups _deferred_wakeups { };
|
2018-04-03 13:59:35 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Simple_env(Genode::Env &env,
|
|
|
|
Genode::Allocator &alloc,
|
2022-12-07 13:06:35 +00:00
|
|
|
Genode::Xml_node config,
|
|
|
|
Vfs::Env::User &user)
|
2018-04-03 13:59:35 +00:00
|
|
|
:
|
2022-12-07 13:06:35 +00:00
|
|
|
_env(env), _alloc(alloc), _user(user), _root_dir(*this, config, _fs_factory)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
Simple_env(Genode::Env &env, Genode::Allocator &alloc, Genode::Xml_node config)
|
|
|
|
:
|
|
|
|
Simple_env(env, alloc, config, *this)
|
2018-04-03 13:59:35 +00:00
|
|
|
{ }
|
|
|
|
|
2018-04-16 09:18:29 +00:00
|
|
|
void apply_config(Genode::Xml_node const &config)
|
|
|
|
{
|
|
|
|
_root_dir.apply_config(config);
|
|
|
|
}
|
|
|
|
|
2022-12-02 08:53:16 +00:00
|
|
|
Genode::Env &env() override { return _env; }
|
|
|
|
Genode::Allocator &alloc() override { return _alloc; }
|
|
|
|
Vfs::File_system &root_dir() override { return _root_dir; }
|
|
|
|
Deferred_wakeups &deferred_wakeups() override { return _deferred_wakeups; }
|
|
|
|
Vfs::Env::Io &io() override { return *this; }
|
2022-12-07 13:06:35 +00:00
|
|
|
Vfs::Env::User &user() override { return _user; }
|
2022-12-02 08:53:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Vfs::Env::Io interface
|
|
|
|
*/
|
2022-12-03 17:50:25 +00:00
|
|
|
void commit() override { _deferred_wakeups.trigger(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Vfs::Env::Io interface
|
|
|
|
*/
|
|
|
|
void commit_and_wait() override
|
2022-12-02 08:53:16 +00:00
|
|
|
{
|
|
|
|
_deferred_wakeups.trigger();
|
|
|
|
_env.ep().wait_and_dispatch_one_io_signal();
|
|
|
|
}
|
2022-12-07 13:06:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Vfs::Env::User interface
|
|
|
|
*
|
|
|
|
* Fallback implementation used if no 'user' is specified at
|
|
|
|
* construction time.
|
|
|
|
*/
|
|
|
|
void wakeup_vfs_user() override { };
|
2018-04-03 13:59:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__VFS__SIMPLE_ENV_H_ */
|