genode/repos/os/include/file_system_session/client.h
Christian Prochaska b0935ef9b2 VFS: nonblocking interface
The VFS library can be used in single-threaded or multi-threaded
environments and depending on that, signals are handled by the same thread
which uses the VFS library or possibly by a different thread. If a VFS
plugin needs to block to wait for a signal, there is currently no way
which works reliably in both environments.

For this reason, this commit makes the interface of the VFS library
nonblocking, similar to the File_system session interface.

The most important changes are:

- Directories are created and opened with the 'opendir()' function and the
  directory entries are read with the recently introduced 'queue_read()'
  and 'complete_read()' functions.

- Symbolic links are created and opened with the 'openlink()' function and
  the link target is read with the 'queue_read()' and 'complete_read()'
  functions and written with the 'write()' function.

- The 'write()' function does not wait for signals anymore. This can have
  the effect that data written by a VFS library user has not been
  processed by a file system server yet when the library user asks for the
  size of the file or closes it (both done with RPC functions at the file
  system server). For this reason, a user of the VFS library should
  request synchronization before calling 'stat()' or 'close()'. To make
  sure that a file system server has processed all write request packets
  which a client submitted before the synchronization request,
  synchronization is now requested at the file system server with a
  synchronization packet instead of an RPC function. Because of this
  change, the synchronization interface of the VFS library is now split
  into 'queue_sync()' and 'complete_sync()' functions.

Fixes #2399
2017-08-28 16:49:38 +02:00

117 lines
2.6 KiB
C++

/*
* \brief Client-side file-system session interface
* \author Norman Feske
* \date 2012-04-05
*/
/*
* Copyright (C) 2012-2017 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__FILE_SYSTEM_SESSION__CLIENT_H_
#define _INCLUDE__FILE_SYSTEM_SESSION__CLIENT_H_
#include <base/rpc_client.h>
#include <file_system_session/capability.h>
#include <packet_stream_tx/client.h>
namespace File_system { class Session_client; }
class File_system::Session_client : public Genode::Rpc_client<Session>
{
private:
Packet_stream_tx::Client<Tx> _tx;
public:
/**
* Constructor
*
* \param session session capability
* \param tx_buffer_alloc allocator used for managing the
* transmission buffer
*/
Session_client(Session_capability session,
Genode::Range_allocator &tx_buffer_alloc,
Genode::Region_map &rm)
:
Rpc_client<Session>(session),
_tx(call<Rpc_tx_cap>(), rm, tx_buffer_alloc)
{ }
/***********************************
** File-system session interface **
***********************************/
Tx::Source *tx() { return _tx.source(); }
void sigh_ready_to_submit(Genode::Signal_context_capability sigh)
{
_tx.sigh_ready_to_submit(sigh);
}
void sigh_ack_avail(Genode::Signal_context_capability sigh)
{
_tx.sigh_ack_avail(sigh);
}
File_handle file(Dir_handle dir, Name const &name, Mode mode, bool create) override
{
return call<Rpc_file>(dir, name, mode, create);
}
Symlink_handle symlink(Dir_handle dir, Name const &name, bool create) override
{
return call<Rpc_symlink>(dir, name, create);
}
Dir_handle dir(Path const &path, bool create) override
{
return call<Rpc_dir>(path, create);
}
Node_handle node(Path const &path) override
{
return call<Rpc_node>(path);
}
void close(Node_handle node) override
{
call<Rpc_close>(node);
}
Status status(Node_handle node) override
{
return call<Rpc_status>(node);
}
void control(Node_handle node, Control control) override
{
call<Rpc_control>(node, control);
}
void unlink(Dir_handle dir, Name const &name) override
{
call<Rpc_unlink>(dir, name);
}
void truncate(File_handle file, file_size_t size) override
{
call<Rpc_truncate>(file, size);
}
void move(Dir_handle from_dir, Name const &from_name,
Dir_handle to_dir, Name const &to_name) override
{
call<Rpc_move>(from_dir, from_name, to_dir, to_name);
}
};
#endif /* _INCLUDE__FILE_SYSTEM_SESSION__CLIENT_H_ */