VFS: add an error to to the Sync_result enum

Sync errors can be used to indicate failed writes across the File_system
session.

Ref #2920
This commit is contained in:
Ehmry - 2018-07-23 19:53:09 +02:00 committed by Christian Helmuth
parent 7fabc45313
commit 08b774e318
5 changed files with 13 additions and 6 deletions

View File

@ -175,7 +175,7 @@ struct Vfs::File_io_service : Interface
** Sync **
**********/
enum Sync_result { SYNC_QUEUED, SYNC_OK };
enum Sync_result { SYNC_QUEUED, SYNC_ERR_INVALID, SYNC_OK };
/**
* Queue sync operation

View File

@ -187,6 +187,7 @@ static inline void print(Genode::Output &output, Vfs::File_io_service::Sync_resu
switch (r) {
CASE_PRINT(SYNC_OK);
CASE_PRINT(SYNC_QUEUED);
CASE_PRINT(SYNC_ERR_INVALID);
}
#undef CASE_PRINT

View File

@ -211,12 +211,15 @@ class Vfs::Fs_file_system : public File_system
::File_system::Session::Tx::Source &source = *_fs.tx();
Sync_result result = packet.succeeded()
? SYNC_OK : SYNC_ERR_INVALID;
queued_sync_state = Handle_state::Queued_state::IDLE;
queued_sync_packet = ::File_system::Packet_descriptor();
source.release_packet(packet);
return SYNC_OK;
return result;
}
};

View File

@ -227,8 +227,7 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object,
*/
try {
_apply(packet.handle(), [&] (Io_node &node) {
node.sync();
succeeded = true;
succeeded = node.sync();
});
} catch (Operation_incomplete) {
throw Not_ready();

View File

@ -270,7 +270,7 @@ class Vfs_server::Io_node : public Vfs_server::Node,
bool notify_read_ready() const { return _notify_read_ready; }
void sync()
bool sync()
{
typedef Vfs::File_io_service::Sync_result Result;
Result out_result = Result::SYNC_OK;
@ -288,7 +288,10 @@ class Vfs_server::Io_node : public Vfs_server::Node,
switch (out_result) {
case Result::SYNC_OK:
op_state = Op_state::IDLE;
return;
return true;
case Result::SYNC_ERR_INVALID:
return false;
case Result::SYNC_QUEUED:
op_state = Op_state::SYNC_QUEUED;
@ -299,6 +302,7 @@ class Vfs_server::Io_node : public Vfs_server::Node,
case Op_state::READ_QUEUED:
throw Operation_incomplete();
}
return false;
}
};