2014-04-07 14:15:40 +00:00
|
|
|
/*
|
|
|
|
* \brief Interface for operations provided by file I/O service
|
|
|
|
* \author Norman Feske
|
2017-01-31 15:38:23 +00:00
|
|
|
* \author Emery Hemingway
|
|
|
|
* \author Christian Helmuth
|
2014-04-07 14:15:40 +00:00
|
|
|
* \date 2011-02-17
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-01-31 15:38:23 +00:00
|
|
|
* Copyright (C) 2011-2017 Genode Labs GmbH
|
2014-04-07 14:15:40 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2014-04-07 14:15:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__VFS__FILE_IO_SERVICE_H_
|
|
|
|
#define _INCLUDE__VFS__FILE_IO_SERVICE_H_
|
|
|
|
|
2017-02-01 20:07:14 +00:00
|
|
|
#include <vfs/vfs_handle.h>
|
|
|
|
|
2019-03-25 14:41:43 +00:00
|
|
|
namespace Vfs { struct File_io_service; }
|
2014-04-07 14:15:40 +00:00
|
|
|
|
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
struct Vfs::File_io_service : Interface
|
2014-04-07 14:15:40 +00:00
|
|
|
{
|
|
|
|
/***********
|
|
|
|
** Write **
|
|
|
|
***********/
|
|
|
|
|
2022-12-06 16:04:26 +00:00
|
|
|
enum Write_result { WRITE_ERR_WOULD_BLOCK, WRITE_ERR_INVALID,
|
|
|
|
WRITE_ERR_IO, WRITE_OK };
|
2014-04-07 14:15:40 +00:00
|
|
|
|
2023-02-09 14:07:24 +00:00
|
|
|
virtual Write_result write(Vfs_handle *vfs_handle, Const_byte_range_ptr const &,
|
|
|
|
size_t &out_count) = 0;
|
2014-04-07 14:15:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********
|
|
|
|
** Read **
|
|
|
|
**********/
|
|
|
|
|
2022-12-20 11:11:27 +00:00
|
|
|
enum Read_result { READ_ERR_WOULD_BLOCK, READ_ERR_INVALID,
|
2022-12-20 11:15:14 +00:00
|
|
|
READ_ERR_IO, READ_QUEUED,
|
|
|
|
READ_OK };
|
2014-04-07 14:15:40 +00:00
|
|
|
|
2017-01-31 15:38:23 +00:00
|
|
|
/**
|
2017-08-15 18:51:53 +00:00
|
|
|
* Queue read operation
|
2017-01-31 15:38:23 +00:00
|
|
|
*
|
|
|
|
* \return false if queue is full
|
2018-07-04 12:09:01 +00:00
|
|
|
*
|
|
|
|
* If the queue is full, the caller can try again after a previous VFS
|
|
|
|
* request is completed.
|
2017-01-31 15:38:23 +00:00
|
|
|
*/
|
2023-02-09 14:07:24 +00:00
|
|
|
virtual bool queue_read(Vfs_handle *, size_t)
|
2017-01-31 15:38:23 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-02-09 14:07:24 +00:00
|
|
|
virtual Read_result complete_read(Vfs_handle *, Byte_range_ptr const &dst,
|
|
|
|
size_t &out_count) = 0;
|
2017-01-31 15:38:23 +00:00
|
|
|
|
2017-02-01 10:28:15 +00:00
|
|
|
/**
|
|
|
|
* Return true if the handle has readable data
|
|
|
|
*/
|
2022-12-07 16:12:21 +00:00
|
|
|
virtual bool read_ready(Vfs_handle const &) const = 0;
|
2017-02-01 10:28:15 +00:00
|
|
|
|
2022-12-06 18:11:44 +00:00
|
|
|
/**
|
|
|
|
* Return true if the handle might accept a write operation
|
|
|
|
*/
|
|
|
|
virtual bool write_ready(Vfs_handle const &) const = 0;
|
|
|
|
|
2017-02-01 20:07:14 +00:00
|
|
|
/**
|
|
|
|
* Explicitly indicate interest in read-ready for a handle
|
|
|
|
*
|
|
|
|
* For example, the file-system-session plugin can then send READ_READY
|
|
|
|
* packets to the server.
|
|
|
|
*
|
|
|
|
* \return false if notification setup failed
|
|
|
|
*/
|
|
|
|
virtual bool notify_read_ready(Vfs_handle *) { return true; }
|
|
|
|
|
2014-04-07 14:15:40 +00:00
|
|
|
|
|
|
|
/***************
|
|
|
|
** Ftruncate **
|
|
|
|
***************/
|
|
|
|
|
2022-12-20 11:05:01 +00:00
|
|
|
enum Ftruncate_result { FTRUNCATE_ERR_NO_PERM, FTRUNCATE_ERR_INTERRUPT,
|
|
|
|
FTRUNCATE_ERR_NO_SPACE, FTRUNCATE_OK };
|
2014-04-07 14:15:40 +00:00
|
|
|
|
2014-09-09 12:32:31 +00:00
|
|
|
virtual Ftruncate_result ftruncate(Vfs_handle *vfs_handle, file_size len) = 0;
|
2014-04-07 14:15:40 +00:00
|
|
|
|
|
|
|
|
2017-08-15 18:51:53 +00:00
|
|
|
/**********
|
|
|
|
** Sync **
|
|
|
|
**********/
|
|
|
|
|
2018-07-23 17:53:09 +00:00
|
|
|
enum Sync_result { SYNC_QUEUED, SYNC_ERR_INVALID, SYNC_OK };
|
2017-08-15 18:51:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Queue sync operation
|
|
|
|
*
|
|
|
|
* \return false if queue is full
|
2018-07-04 12:09:01 +00:00
|
|
|
*
|
|
|
|
* If the queue is full, the caller can try again after a previous VFS
|
|
|
|
* request is completed.
|
2017-08-15 18:51:53 +00:00
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
virtual bool queue_sync(Vfs_handle *) { return true; }
|
2017-08-15 18:51:53 +00:00
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
virtual Sync_result complete_sync(Vfs_handle *) { return SYNC_OK; }
|
2019-03-20 14:01:34 +00:00
|
|
|
|
|
|
|
/***********************
|
|
|
|
** Modification time **
|
|
|
|
***********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the modification time of a file
|
|
|
|
*
|
|
|
|
* \return true if update attempt was successful
|
|
|
|
*/
|
|
|
|
virtual bool update_modification_timestamp(Vfs_handle *, Vfs::Timestamp)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-04-07 14:15:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__VFS__FILE_IO_SERVICE_H_ */
|