vfs: implement 'complete_sync()' in 'Single_file_system'

Fixes #3047
This commit is contained in:
Christian Prochaska 2018-11-13 13:59:21 +01:00 committed by Christian Helmuth
parent cde542c37c
commit fd7ab79fe0
2 changed files with 19 additions and 8 deletions

View File

@ -48,6 +48,11 @@ class Vfs::Single_file_system : public File_system
virtual Write_result write(char const *src, file_size count,
file_size &out_count) = 0;
virtual Sync_result sync()
{
return SYNC_OK;
}
virtual bool read_ready() = 0;
};
@ -275,6 +280,17 @@ class Vfs::Single_file_system : public File_system
{
return FTRUNCATE_ERR_NO_PERM;
}
Sync_result complete_sync(Vfs_handle *vfs_handle)
{
Single_vfs_handle *handle =
static_cast<Single_vfs_handle*>(vfs_handle);
if (handle)
return handle->sync();
return SYNC_ERR_INVALID;
}
};
#endif /* _INCLUDE__VFS__SINGLE_FILE_SYSTEM_H_ */

View File

@ -122,16 +122,17 @@ class Vfs::Log_file_system : public Single_file_system
count -= curr_count;
src += curr_count;
}
return WRITE_OK;
}
bool read_ready() override { return false; }
void sync()
Sync_result sync() override
{
if (_line_pos > 0)
_flush();
return SYNC_OK;
}
};
@ -167,12 +168,6 @@ class Vfs::Log_file_system : public Single_file_system
catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; }
catch (Genode::Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; }
}
Sync_result complete_sync(Vfs_handle *vfs_handle)
{
static_cast<Log_vfs_handle *>(vfs_handle)->sync();
return SYNC_OK;
}
};
#endif /* _INCLUDE__VFS__LOG_FILE_SYSTEM_H_ */