noux: enable strict warnings

This commit is contained in:
Norman Feske 2019-01-18 16:18:19 +01:00
parent e889c58bbc
commit 3da6aab353
29 changed files with 161 additions and 150 deletions

View File

@ -73,7 +73,7 @@ class Noux::Args
size_t len() const { return _len; }
char const * const base() const { return _buf; }
char const *base() const { return _buf; }
void append(char const *arg)
{

View File

@ -23,7 +23,7 @@ class Noux::Armed_timeout : Noncopyable
{
public:
struct State : Noncopyable { bool timed_out; };
struct State : Noncopyable { bool timed_out { }; };
private:

View File

@ -70,13 +70,11 @@ class Noux::Pid_allocator
{
private:
Lock _lock;
int _num_pids;
Lock _lock { };
int _num_pids { 0 };
public:
Pid_allocator() : _num_pids(0) { }
int alloc()
{
Lock::Guard guard(_lock);
@ -110,6 +108,12 @@ class Noux::Child : public Rpc_object<Session>,
{
private:
/*
* Noncopyable
*/
Child(Child const &);
Child &operator = (Child const &);
Child_policy::Name const _name;
Verbose const &_verbose;
@ -127,7 +131,7 @@ class Noux::Child : public Rpc_object<Session>,
Vfs::File_system &_root_dir;
Vfs_io_waiter_registry &_vfs_io_waiter_registry;
Vfs_handle_context _vfs_handle_context;
Vfs_handle_context _vfs_handle_context { };
Destruct_queue &_destruct_queue;
@ -210,7 +214,7 @@ class Noux::Child : public Rpc_object<Session>,
typedef Ring_buffer<enum Sysio::Signal, Sysio::SIGNAL_QUEUE_SIZE>
Signal_queue;
Signal_queue _pending_signals;
Signal_queue _pending_signals { };
Parent_services &_parent_services;

View File

@ -37,9 +37,9 @@ class Noux::Child_env
{
private:
enum { MAX_LEN_INTERPRETER_LINE = 128 };
static unsigned constexpr MAX_LEN_INTERPRETER_LINE = 128;
char const *_binary_name;
char const *_binary_name { nullptr };
char _args[ARGS_SIZE + MAX_LEN_INTERPRETER_LINE];
Sysio::Env _env;

View File

@ -41,6 +41,12 @@ class Noux::Child_policy : public Genode::Child_policy
{
private:
/**
* Noncopyable
*/
Child_policy(Child_policy const &);
Child_policy &operator = (Child_policy const &);
Name const _name;
bool _forked;
Init::Child_policy_provide_rom_file _args_policy;
@ -124,7 +130,7 @@ class Noux::Child_policy : public Genode::Child_policy
Pd_session &ref_pd() override { return _ref_pd; }
Pd_session_capability ref_pd_cap() const override { return _ref_pd_cap; }
void init(Pd_session &session, Pd_session_capability cap) override
void init(Pd_session &session, Pd_session_capability) override
{
session.ref_account(_ref_pd_cap);
}

View File

@ -50,10 +50,10 @@ class Noux::Cpu_session_component : public Rpc_object<Cpu_session>
enum { MAX_THREADS = 8, MAIN_THREAD_IDX = 0 };
Thread_capability _threads[MAX_THREADS];
Dataspace_capability _trace_control;
Dataspace_capability _trace_control { };
Dataspace_registry &_registry;
Constructible<Static_dataspace_info> _ds_info;
Constructible<Static_dataspace_info> _ds_info { };
public:

View File

@ -29,8 +29,11 @@ namespace Noux {
}
struct Noux::Dataspace_user : List<Dataspace_user>::Element
struct Noux::Dataspace_user : Interface, private List<Dataspace_user>::Element
{
friend class Dataspace_info;
friend class List<Dataspace_user>;
virtual void dissolve(Dataspace_info &ds) = 0;
};
@ -41,8 +44,8 @@ class Noux::Dataspace_info : public Object_pool<Dataspace_info>::Entry
size_t _size;
Dataspace_capability _ds_cap;
Lock _users_lock;
List<Dataspace_user> _users;
Lock _users_lock { };
List<Dataspace_user> _users { };
public:
@ -126,7 +129,7 @@ class Noux::Dataspace_info : public Object_pool<Dataspace_info>::Entry
*
* \param addr address that is covered by the requested region map
*/
virtual Capability<Region_map> lookup_region_map(addr_t const addr)
virtual Capability<Region_map> lookup_region_map(addr_t)
{
/* by default a dataspace is no sub region map, so return invalid */
return Capability<Region_map>();

View File

@ -25,8 +25,9 @@ class Noux::Destruct_queue
{
public:
struct Element_base : Genode::List<Element_base>::Element
struct Element_base : Interface, private Genode::List<Element_base>::Element
{
friend class List<Noux::Destruct_queue::Element_base>;
virtual void destroy() = 0;
};
@ -67,8 +68,8 @@ class Noux::Destruct_queue
private:
Genode::List<Element_base> _destruct_list;
Genode::Lock _destruct_list_lock;
Genode::List<Element_base> _destruct_list { };
Genode::Lock _destruct_list_lock { };
Signal_context_capability _sigh;
public:

View File

@ -42,7 +42,7 @@ class Noux::Empty_rom_factory : public Empty_rom_service::Factory
Empty_rom_factory(Allocator &alloc, Rpc_entrypoint &ep)
: _alloc(alloc), _ep(ep) { }
Empty_rom_session_component &create(Args const &args, Affinity) override
Empty_rom_session_component &create(Args const &, Affinity) override
{
try {
return *new (_alloc) Empty_rom_session_component(_ep); }

View File

@ -27,11 +27,13 @@ namespace Noux {
}
class Noux::Environment : private Attached_ram_dataspace
class Noux::Environment : Noncopyable
{
private:
Sysio::Env *_env;
Attached_ram_dataspace _ds;
Sysio::Env &_env { *_ds.local_addr<Sysio::Env>() };
public:
@ -41,19 +43,17 @@ class Noux::Environment : private Attached_ram_dataspace
* \param env comma-separated list of environment variables
*/
Environment(Ram_allocator &ram, Region_map &local_rm, Sysio::Env const &env)
:
Attached_ram_dataspace(ram, local_rm, sizeof(Sysio::Env)),
_env(local_addr<Sysio::Env>())
: _ds(ram, local_rm, sizeof(Sysio::Env))
{
memcpy(_env, env, sizeof(Sysio::Env));
memcpy(&_env, &env, sizeof(Sysio::Env));
}
using Attached_ram_dataspace::cap;
Dataspace_capability cap() { return _ds.cap(); }
/**
* Return list of environment variables as zero-separated list
*/
Sysio::Env const &env() { return *_env; }
Sysio::Env const &env() { return _env; }
};
#endif /* _NOUX__ENVIRONMENT_H_ */

View File

@ -25,17 +25,19 @@
namespace Noux { class Family_member; }
class Noux::Family_member : public List<Family_member>::Element,
class Noux::Family_member : private List<Family_member>::Element,
public Parent_exit,
public Parent_execve
{
private:
friend class List<Noux::Family_member>;
int const _pid;
Lock _lock;
List<Family_member> _list;
bool _has_exited;
int _exit_status;
Lock _lock { };
List<Family_member> _list { };
bool _has_exited { false };
int _exit_status { 0 };
protected:
@ -43,13 +45,11 @@ class Noux::Family_member : public List<Family_member>::Element,
* Lock used for implementing blocking syscalls,
* i.e., select, wait4, ...
*/
Lock _blocker;
Lock _blocker { };
public:
Family_member(int pid)
: _pid(pid), _has_exited(false), _exit_status(0)
{ }
Family_member(int pid) : _pid(pid) { }
virtual ~Family_member() { }

View File

@ -32,7 +32,7 @@ class Noux::File_descriptor_registry
bool allocated;
bool close_on_execve;
Shared_pointer<Io_channel> io_channel;
} _fds[MAX_FILE_DESCRIPTORS];
} _fds[MAX_FILE_DESCRIPTORS] { };
bool _valid_fd(int fd) const
{
@ -71,6 +71,8 @@ class Noux::File_descriptor_registry
flush();
}
virtual ~File_descriptor_registry() { }
/**
* Associate I/O channel with file descriptor
*

View File

@ -18,7 +18,7 @@
namespace Noux {
struct Interrupt_handler
struct Interrupt_handler : Genode::Interface
{
virtual void handle_interrupt(Sysio::Signal) = 0;
};

View File

@ -53,18 +53,20 @@ struct Noux::Io_channel_backend
/**
* Input/output channel interface
*/
class Noux::Io_channel : public Reference_counter
class Noux::Io_channel : private Reference_counter
{
private:
friend class Shared_pointer<Io_channel>;
/**
* List of notifiers (i.e., processes) used by threads that block
* for an I/O-channel event
*/
List<Wake_up_notifier> _notifiers;
Lock _notifiers_lock;
List<Io_channel_listener> _interrupt_handlers;
Lock _interrupt_handlers_lock;
List<Wake_up_notifier> _notifiers { };
Lock _notifiers_lock { };
List<Io_channel_listener> _interrupt_handlers { };
Lock _interrupt_handlers_lock { };
public:
@ -72,14 +74,14 @@ class Noux::Io_channel : public Reference_counter
virtual Io_channel_backend *backend() { return nullptr; }
virtual bool write(Sysio &sysio) { return false; }
virtual bool read(Sysio &sysio) { return false; }
virtual bool fstat(Sysio &sysio) { return false; }
virtual bool ftruncate(Sysio &sysio) { return false; }
virtual bool fcntl(Sysio &sysio) { return false; }
virtual bool dirent(Sysio &sysio) { return false; }
virtual bool ioctl(Sysio &sysio) { return false; }
virtual bool lseek(Sysio &sysio) { return false; }
virtual bool write(Sysio &) { return false; }
virtual bool read(Sysio &) { return false; }
virtual bool fstat(Sysio &) { return false; }
virtual bool ftruncate(Sysio &) { return false; }
virtual bool fcntl(Sysio &) { return false; }
virtual bool dirent(Sysio &) { return false; }
virtual bool ioctl(Sysio &) { return false; }
virtual bool lseek(Sysio &) { return false; }
/**
* Return true if an unblocking condition of the channel is satisfied
@ -88,7 +90,7 @@ class Noux::Io_channel : public Reference_counter
* \param wr if true, check for readiness for writing
* \param ex if true, check for exceptions
*/
virtual bool check_unblock(bool rd, bool wr, bool ex) const {
virtual bool check_unblock(bool /* rd */, bool /* wr */, bool /* ex */) const {
return false; }
/**
@ -193,7 +195,7 @@ class Noux::Io_channel : public Reference_counter
* This function is used to simplify the implemenation of SYSCALL_FSTAT
* and is only implemented by Vfs_io_channel.
*/
virtual bool path(char *path, size_t len) { return false; }
virtual bool path(char * /* path */, size_t /* len */) { return false; }
};
#endif /* _NOUX__IO_CHANNEL_H_ */

View File

@ -47,8 +47,8 @@ class Noux::Io_receptor_registry
{
private:
List<Io_receptor> _receptors;
Lock _receptors_lock;
List<Io_receptor> _receptors { };
Lock _receptors_lock { };
public:

View File

@ -19,7 +19,7 @@
namespace Noux {
struct Kill_broadcaster
struct Kill_broadcaster : Genode::Interface
{
virtual bool kill(int pid, Noux::Sysio::Signal sig) = 0;
};

View File

@ -95,7 +95,6 @@ connect_stdio(Genode::Env &env,
Genode::Constructible<Terminal::Connection> &terminal,
Genode::Xml_node config,
Vfs::File_system &root,
Noux::Vfs_handle_context &vfs_handle_context,
Noux::Vfs_io_waiter_registry &vfs_io_waiter_registry,
Noux::Terminal_io_channel::Type type,
Genode::Allocator &alloc)
@ -141,7 +140,7 @@ connect_stdio(Genode::Env &env,
}
return *new (alloc)
Vfs_io_channel(path.string(), root.leaf_path(path.string()), &root,
Vfs_io_channel(path.string(), root.leaf_path(path.string()),
vfs_handle, vfs_io_waiter_registry, env.ep());
}
@ -170,7 +169,7 @@ struct Noux::Main
Heap _heap { _env.ram(), _env.rm() };
/* whitelist of service requests to be routed to the parent */
Noux::Parent_services _parent_services;
Noux::Parent_services _parent_services { };
Noux::Parent_service _log_parent_service { _parent_services, "LOG" };
Noux::Parent_service _timer_parent_service { _parent_services, "Timer" };
@ -215,7 +214,7 @@ struct Noux::Main
struct Io_response_handler : Vfs::Io_response_handler
{
Vfs_io_waiter_registry io_waiter_registry;
Vfs_io_waiter_registry io_waiter_registry { };
void handle_io_response(Vfs::Vfs_handle::Context *context) override
{
@ -230,7 +229,7 @@ struct Noux::Main
});
}
} _io_response_handler;
} _io_response_handler { };
struct Vfs_env : Vfs::Env, Vfs::Watch_response_handler
{
@ -260,9 +259,7 @@ struct Noux::Main
Vfs::File_system &_root_dir = _vfs_env.root_dir();
Vfs_handle_context _vfs_handle_context;
Pid_allocator _pid_allocator;
Pid_allocator _pid_allocator { };
Timer::Connection _timer_connection { _env };
@ -295,7 +292,7 @@ struct Noux::Main
return init_process->deliver_kill(pid, sig);
}
} _kill_broadcaster;
} _kill_broadcaster { };
Noux::Child _init_child { _name_of_init_process(),
_verbose,
@ -318,7 +315,7 @@ struct Noux::Main
false,
_destruct_queue };
Constructible<Terminal::Connection> _terminal;
Constructible<Terminal::Connection> _terminal { };
/*
* I/O channels must be dynamically allocated to handle cases where the
@ -328,13 +325,13 @@ struct Noux::Main
Shared_pointer<Io_channel>
_channel_0 { &connect_stdio(_env, _terminal, _config.xml(), _root_dir,
_vfs_handle_context, _io_response_handler.io_waiter_registry,
_io_response_handler.io_waiter_registry,
Tio::STDIN, _heap), _heap },
_channel_1 { &connect_stdio(_env, _terminal, _config.xml(), _root_dir,
_vfs_handle_context, _io_response_handler.io_waiter_registry,
_io_response_handler.io_waiter_registry,
Tio::STDOUT, _heap), _heap },
_channel_2 { &connect_stdio(_env, _terminal, _config.xml(), _root_dir,
_vfs_handle_context, _io_response_handler.io_waiter_registry,
_io_response_handler.io_waiter_registry,
Tio::STDERR, _heap), _heap };
Main(Env &env) : _env(env)

View File

@ -23,7 +23,7 @@ namespace Noux {
}
struct Noux::Parent_execve
struct Noux::Parent_execve : Genode::Interface
{
virtual void execve_child(Family_member &child,
const char *filename,

View File

@ -14,11 +14,13 @@
#ifndef _NOUX__PARENT_EXIT__H_
#define _NOUX__PARENT_EXIT__H_
#include <util/interface.h>
namespace Noux {
struct Family_member;
struct Parent_exit
struct Parent_exit : Genode::Interface
{
/*
* Handle the exiting of a child

View File

@ -40,8 +40,10 @@ namespace Noux {
struct Noux::Ram_dataspace_info : Dataspace_info,
List<Ram_dataspace_info>::Element
private List<Ram_dataspace_info>::Element
{
friend class List<Ram_dataspace_info>;
Ram_dataspace_info(Ram_dataspace_capability ds_cap)
: Dataspace_info(ds_cap) { }
@ -111,7 +113,7 @@ class Noux::Pd_session_component : public Rpc_object<Pd_session>
Ram_quota _used_ram_quota { 0 };
List<Ram_dataspace_info> _ds_list;
List<Ram_dataspace_info> _ds_list { };
Dataspace_registry &_ds_registry;
@ -259,9 +261,9 @@ class Noux::Pd_session_component : public Rpc_object<Pd_session>
Capability<Region_map> linker_area() override {
return _linker_area.Rpc_object<Region_map>::cap(); }
void ref_account(Capability<Pd_session> pd) override { }
void ref_account(Capability<Pd_session>) override { }
void transfer_quota(Capability<Pd_session> pd, Cap_quota amount) override { }
void transfer_quota(Capability<Pd_session>, Cap_quota) override { }
Cap_quota cap_quota() const { return _pd.cap_quota(); }
Cap_quota used_caps() const { return _pd.used_caps(); }

View File

@ -28,18 +28,18 @@ class Noux::Pipe : public Reference_counter
{
private:
Lock mutable _lock;
Lock mutable _lock { };
enum { BUFFER_SIZE = 4096 };
char _buffer[BUFFER_SIZE];
unsigned _read_offset;
unsigned _write_offset;
unsigned _read_offset { 0 };
unsigned _write_offset { 0 };
Signal_context_capability _read_ready_sigh;
Signal_context_capability _write_ready_sigh;
Signal_context_capability _read_ready_sigh { };
Signal_context_capability _write_ready_sigh { };
bool _writer_is_gone;
bool _writer_is_gone { false };
/**
* Return space available in the buffer for writing, in bytes
@ -75,9 +75,6 @@ class Noux::Pipe : public Reference_counter
public:
Pipe()
: _read_offset(0), _write_offset(0), _writer_is_gone(false) { }
~Pipe()
{
Lock::Guard guard(_lock);
@ -237,7 +234,7 @@ class Noux::Pipe_sink_io_channel : public Io_channel
~Pipe_sink_io_channel() { _pipe->writer_close(); }
bool check_unblock(bool rd, bool wr, bool ex) const override
bool check_unblock(bool, bool wr, bool) const override
{
return wr && _pipe->any_space_avail_for_writing();
}
@ -292,7 +289,7 @@ class Noux::Pipe_source_io_channel : public Io_channel
~Pipe_source_io_channel() { _pipe->reader_close(); }
bool check_unblock(bool rd, bool wr, bool ex) const override
bool check_unblock(bool rd, bool, bool) const override
{
/* unblock if the writer has already closed its pipe end */
if (_pipe->writer_is_gone())

View File

@ -29,14 +29,14 @@ struct Noux::Range_checked_index
Range_checked_index(T value, T max) : value(value), max(max) { }
T operator++ (int)
Range_checked_index<T> operator++ (int)
{
T old_value = value;
if (++value >= max)
throw Index_out_of_range();
return old_value;
return Range_checked_index<T>(old_value, max);
}
operator T () { return value; }

View File

@ -46,8 +46,11 @@ class Noux::Region_map_component : public Rpc_object<Region_map>,
/**
* Record of an attached dataspace
*/
struct Region : List<Region>::Element, Dataspace_user
struct Region : private List<Region>::Element, private Dataspace_user
{
friend class Region_map_component; /* list operations */
friend class List<Noux::Region_map_component::Region>;
Region_map_component &rm;
Dataspace_capability ds;
size_t size;
@ -76,11 +79,11 @@ class Noux::Region_map_component : public Rpc_object<Region_map>,
return List<Region>::Element::next();
}
inline void dissolve(Dataspace_info &ds);
void dissolve(Dataspace_info &ds) override;
};
Lock _region_lock;
List<Region> _regions;
Lock _region_lock { };
List<Region> _regions { };
Region *_lookup_region_by_addr(addr_t local_addr)
{
@ -413,7 +416,7 @@ class Noux::Region_map_component : public Rpc_object<Region_map>,
};
inline void Noux::Region_map_component::Region::dissolve(Dataspace_info &ds)
inline void Noux::Region_map_component::Region::dissolve(Dataspace_info &)
{
rm.detach(local_addr);
}

View File

@ -44,7 +44,7 @@ struct Noux::Vfs_dataspace
Genode::Region_map &rm;
Genode::Allocator &alloc;
Dataspace_capability ds;
Dataspace_capability ds { };
bool got_ds_from_vfs { true };
Vfs_dataspace(Vfs::File_system &root_dir,
@ -154,7 +154,7 @@ struct Noux::Rom_dataspace_info : Dataspace_info
return ds_cap();
}
void poke(Region_map &, addr_t dst_offset, char const *src, size_t len)
void poke(Region_map &, addr_t, char const *, size_t) override
{
error("attempt to poke onto a ROM dataspace");
}
@ -183,12 +183,12 @@ class Noux::Rom_session_component : public Rpc_object<Rom_session>
Vfs_io_waiter_registry &_vfs_io_waiter_registry;
Dataspace_registry &_ds_registry;
Constructible<Vfs_dataspace> _rom_from_vfs;
Constructible<Vfs_dataspace> _rom_from_vfs { };
/**
* Wrapped ROM session at core
*/
Constructible<Rom_connection> _rom_from_parent;
Constructible<Rom_connection> _rom_from_parent { };
Dataspace_capability _init_ds_cap(Env &env, Name const &name)
{

View File

@ -33,7 +33,7 @@ class Noux::Reference_counter
{
private:
Lock _lock;
Lock _lock { };
long _value;
friend class Shared_pointer_base;

View File

@ -227,7 +227,7 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
Shared_pointer<Io_channel>
channel(new (_heap) Vfs_io_channel(_sysio.open_in.path,
leaf_path, &_root_dir,
leaf_path,
vfs_handle,
_vfs_io_waiter_registry,
_env.ep()),

View File

@ -3,6 +3,4 @@ LIBS = base vfs
SRC_CC = main.cc syscall.cc
INC_DIR += $(PRG_DIR)
vpath %.cc $(PRG_DIR)
CC_CXX_WARN_STRICT =
vpath %.cc $(PRG_DIR)

View File

@ -41,7 +41,7 @@ struct Noux::Terminal_io_channel : Io_channel
enum Type { STDIN, STDOUT, STDERR } type;
Ring_buffer<char, Sysio::CHUNK_SIZE + 1> read_buffer;
Ring_buffer<char, Sysio::CHUNK_SIZE + 1> read_buffer { };
Terminal_io_channel(Terminal::Session &terminal, Type type,
Entrypoint &ep)
@ -160,7 +160,7 @@ struct Noux::Terminal_io_channel : Io_channel
return true;
}
bool check_unblock(bool rd, bool wr, bool ex) const override
bool check_unblock(bool rd, bool wr, bool) const override
{
/* never block for writing */
if (wr) return true;

View File

@ -31,24 +31,18 @@ class Noux::Vfs_io_waiter
{
private:
Genode::Semaphore _sem;
Genode::Semaphore _sem { };
public:
void wait_for_io()
{
_sem.down();
}
void wait_for_io() { _sem.down(); }
void wakeup()
{
_sem.up();
}
void wakeup() { _sem.up(); }
};
struct Noux::Vfs_handle_context : Vfs::Vfs_handle::Context
{
Vfs_io_waiter vfs_io_waiter;
Vfs_io_waiter vfs_io_waiter { };
};
struct Noux::Vfs_io_channel : Io_channel
@ -60,24 +54,24 @@ struct Noux::Vfs_io_channel : Io_channel
Io_channel::invoke_all_notifiers();
}
Vfs::Vfs_handle *_fh;
Vfs::Vfs_handle &_fh;
Vfs_io_waiter_registry &_vfs_io_waiter_registry;
Absolute_path _path;
Absolute_path _leaf_path;
bool const _dir = _fh->ds().directory(_leaf_path.base());
bool const _dir = _fh.ds().directory(_leaf_path.base());
void _sync()
{
Registered_no_delete<Vfs_io_waiter>
vfs_io_waiter(_vfs_io_waiter_registry);
while (!_fh->fs().queue_sync(_fh))
while (!_fh.fs().queue_sync(&_fh))
vfs_io_waiter.wait_for_io();
while (_fh->fs().complete_sync(_fh) == Vfs::File_io_service::SYNC_QUEUED)
while (_fh.fs().complete_sync(&_fh) == Vfs::File_io_service::SYNC_QUEUED)
vfs_io_waiter.wait_for_io();
/* wake up threads blocking for 'queue_*()' or 'write()' */
@ -87,22 +81,22 @@ struct Noux::Vfs_io_channel : Io_channel
}
Vfs_io_channel(char const *path, char const *leaf_path,
Vfs::File_system *root_dir, Vfs::Vfs_handle *vfs_handle,
Vfs::Vfs_handle *vfs_handle,
Vfs_io_waiter_registry &vfs_io_waiter_registry,
Entrypoint &ep)
:
_read_avail_handler(ep, *this, &Vfs_io_channel::_handle_read_avail),
_fh(vfs_handle), _vfs_io_waiter_registry(vfs_io_waiter_registry),
_fh(*vfs_handle), _vfs_io_waiter_registry(vfs_io_waiter_registry),
_path(path), _leaf_path(leaf_path)
{
_fh->fs().register_read_ready_sigh(_fh, _read_avail_handler);
_fh.fs().register_read_ready_sigh(&_fh, _read_avail_handler);
}
~Vfs_io_channel()
{
_sync();
_fh->ds().close(_fh);
_fh.ds().close(&_fh);
}
bool write(Sysio &sysio) override
@ -120,8 +114,8 @@ struct Noux::Vfs_io_channel : Io_channel
for (;;) {
try {
sysio.error.write = _fh->fs().write(_fh, sysio.write_in.chunk,
count, out_count);
sysio.error.write = _fh.fs().write(&_fh, sysio.write_in.chunk,
count, out_count);
break;
} catch (Vfs::File_io_service::Insufficient_buffer) {
vfs_io_waiter.wait_for_io();
@ -136,7 +130,7 @@ struct Noux::Vfs_io_channel : Io_channel
if (sysio.error.write != Vfs::File_io_service::WRITE_OK)
return false;
_fh->advance_seek(out_count);
_fh.advance_seek(out_count);
sysio.write_out.count = out_count;
@ -157,12 +151,12 @@ struct Noux::Vfs_io_channel : Io_channel
Registered_no_delete<Vfs_io_waiter>
vfs_io_waiter(_vfs_io_waiter_registry);
while (!_fh->fs().queue_read(_fh, count))
while (!_fh.fs().queue_read(&_fh, count))
vfs_io_waiter.wait_for_io();
for (;;) {
sysio.error.read = _fh->fs().complete_read(_fh, sysio.read_out.chunk, count, out_count);
sysio.error.read = _fh.fs().complete_read(&_fh, sysio.read_out.chunk, count, out_count);
if (sysio.error.read != Vfs::File_io_service::READ_QUEUED)
break;
@ -180,7 +174,7 @@ struct Noux::Vfs_io_channel : Io_channel
sysio.read_out.count = out_count;
_fh->advance_seek(out_count);
_fh.advance_seek(out_count);
return true;
}
@ -190,12 +184,12 @@ struct Noux::Vfs_io_channel : Io_channel
_sync();
/*
* 'sysio.stat_in' is not used in '_fh->ds().stat()',
* 'sysio.stat_in' is not used in '_fh.ds().stat()',
* so no 'sysio' member translation is needed here
*/
Vfs::Directory_service::Stat stat;
sysio.error.stat = _fh->ds().stat(_leaf_path.base(), stat);
sysio.error.stat = _fh.ds().stat(_leaf_path.base(), stat);
sysio.fstat_out.st = stat;
return (sysio.error.stat == Vfs::Directory_service::STAT_OK);
@ -205,7 +199,7 @@ struct Noux::Vfs_io_channel : Io_channel
{
_sync();
sysio.error.ftruncate = _fh->fs().ftruncate(_fh, sysio.ftruncate_in.length);
sysio.error.ftruncate = _fh.fs().ftruncate(&_fh, sysio.ftruncate_in.length);
return (sysio.error.ftruncate == Vfs::File_io_service::FTRUNCATE_OK);
}
@ -216,11 +210,11 @@ struct Noux::Vfs_io_channel : Io_channel
case Sysio::FCNTL_CMD_GET_FILE_STATUS_FLAGS:
sysio.fcntl_out.result = _fh->status_flags();
sysio.fcntl_out.result = _fh.status_flags();
return true;
case Sysio::FCNTL_CMD_SET_FILE_STATUS_FLAGS:
_fh->status_flags(sysio.fcntl_in.long_arg);
_fh.status_flags(sysio.fcntl_in.long_arg);
return true;
default:
@ -242,7 +236,7 @@ struct Noux::Vfs_io_channel : Io_channel
/*
* Return artificial dir entries for "." and ".."
*/
unsigned const index = _fh->seek() / sizeof(Sysio::Dirent);
unsigned const index = _fh.seek() / sizeof(Sysio::Dirent);
if (index < 2) {
sysio.dirent_out.entry.type = Vfs::Directory_service::DIRENT_TYPE_DIRECTORY;
strncpy(sysio.dirent_out.entry.name,
@ -250,7 +244,7 @@ struct Noux::Vfs_io_channel : Io_channel
sizeof(sysio.dirent_out.entry.name));
sysio.dirent_out.entry.fileno = 1;
_fh->advance_seek(sizeof(Sysio::Dirent));
_fh.advance_seek(sizeof(Sysio::Dirent));
return true;
}
@ -261,15 +255,15 @@ struct Noux::Vfs_io_channel : Io_channel
Vfs::Directory_service::Dirent dirent;
Vfs::file_size noux_dirent_seek = _fh->seek();
_fh->seek((index - 2) * sizeof(dirent));
Vfs::file_size noux_dirent_seek = _fh.seek();
_fh.seek((index - 2) * sizeof(dirent));
Vfs::file_size const count = sizeof(dirent);
Registered_no_delete<Vfs_io_waiter>
vfs_io_waiter(_vfs_io_waiter_registry);
while (!_fh->fs().queue_read(_fh, count))
while (!_fh.fs().queue_read(&_fh, count))
vfs_io_waiter.wait_for_io();
Vfs::File_io_service::Read_result read_result;
@ -277,8 +271,8 @@ struct Noux::Vfs_io_channel : Io_channel
for (;;) {
read_result = _fh->fs().complete_read(_fh, (char*)&dirent,
count, out_count);
read_result = _fh.fs().complete_read(&_fh, (char*)&dirent,
count, out_count);
if (read_result != Vfs::File_io_service::READ_QUEUED)
break;
@ -296,11 +290,11 @@ struct Noux::Vfs_io_channel : Io_channel
dirent = Vfs::Directory_service::Dirent();
}
_fh->seek(noux_dirent_seek);
_fh.seek(noux_dirent_seek);
sysio.dirent_out.entry = dirent;
_fh->advance_seek(sizeof(Sysio::Dirent));
_fh.advance_seek(sizeof(Sysio::Dirent));
return true;
}
@ -323,7 +317,7 @@ struct Noux::Vfs_io_channel : Io_channel
{
Vfs::File_system::Ioctl_arg arg = (Vfs::File_system::Ioctl_arg)sysio.ioctl_in.argp;
sysio.error.ioctl = _fh->fs().ioctl(_fh, sysio.ioctl_in.request, arg, sysio.ioctl_out);
sysio.error.ioctl = _fh.fs().ioctl(&_fh, sysio.ioctl_in.request, arg, sysio.ioctl_out);
return (sysio.error.ioctl == Vfs::File_io_service::IOCTL_OK);
}
@ -331,21 +325,21 @@ struct Noux::Vfs_io_channel : Io_channel
bool lseek(Sysio &sysio) override
{
switch (sysio.lseek_in.whence) {
case Sysio::LSEEK_SET: _fh->seek(sysio.lseek_in.offset); break;
case Sysio::LSEEK_CUR: _fh->advance_seek(sysio.lseek_in.offset); break;
case Sysio::LSEEK_SET: _fh.seek(sysio.lseek_in.offset); break;
case Sysio::LSEEK_CUR: _fh.advance_seek(sysio.lseek_in.offset); break;
case Sysio::LSEEK_END:
off_t offset = sysio.lseek_in.offset;
sysio.fstat_in.fd = sysio.lseek_in.fd;
_fh->seek(size(sysio) + offset);
_fh.seek(size(sysio) + offset);
break;
}
sysio.lseek_out.offset = _fh->seek();
sysio.lseek_out.offset = _fh.seek();
return true;
}
bool check_unblock(bool rd, bool wr, bool ex) const override
{
return _fh->fs().check_unblock(_fh, rd, wr, ex);
return _fh.fs().check_unblock(&_fh, rd, wr, ex);
}
bool path(char *path, size_t len) override