vfs: add Append_file class

This reverts commit cf904e0a5d and
introduces the Append_file class instead.

genodelabs/genode#4352
This commit is contained in:
Johannes Schlatow
2022-08-29 11:38:36 +02:00
committed by Norman Feske
parent 06f24a73d2
commit bc57e9e647
7 changed files with 112 additions and 57 deletions

View File

@@ -23,12 +23,12 @@ void Writer::start_iteration(Directory &root,
_file_path = Directory::join(path, info.thread_name());
try {
_dst_file.construct(root, _file_path, true);
_dst_file.construct(root, _file_path);
/* initialise packet header */
_packet_buffer.init_header(info);
}
catch (New_file::Create_failed) {
catch (Append_file::Create_failed) {
error("Could not create file."); }
}

View File

@@ -27,7 +27,7 @@ namespace Ctf {
using namespace Trace_recorder;
using Genode::Directory;
using Genode::New_file;
using Genode::Append_file;
using Buffer = Write_buffer<32*1024>;
@@ -39,9 +39,9 @@ namespace Ctf {
class Ctf::Writer : public Trace_recorder::Writer_base
{
private:
Buffer &_packet_buffer;
Constructible<New_file> _dst_file { };
Directory::Path _file_path { };
Buffer &_packet_buffer;
Constructible<Append_file> _dst_file { };
Directory::Path _file_path { };
public:
Writer(Genode::Registry<Writer_base> &registry, Buffer &packet_buffer)

View File

@@ -64,12 +64,12 @@ class Ctf::Write_buffer
});
}
void write_to_file(Genode::New_file &dst, Genode::Directory::Path const &path)
void write_to_file(Genode::Append_file &dst, Genode::Directory::Path const &path)
{
if (_header().empty())
return;
if (dst.append(_buffer, _header().total_length_bytes()) != New_file::Append_result::OK)
if (dst.append(_buffer, _header().total_length_bytes()) != Append_file::Append_result::OK)
error("Write error for ", path);
_header().reset();

View File

@@ -35,14 +35,14 @@ void Writer::start_iteration(Directory &root,
/* append to file */
try {
_dst_file.construct(root, _file_path, true);
_dst_file.construct(root, _file_path);
_interface_registry.clear();
_buffer.clear();
_buffer.append<Section_header_block>();
_empty_section = true;
}
catch (New_file::Create_failed) {
catch (Append_file::Create_failed) {
error("Could not create file."); }
}

View File

@@ -27,7 +27,7 @@ namespace Pcapng {
using namespace Trace_recorder;
using Genode::Directory;
using Genode::New_file;
using Genode::Append_file;
using Buffer = Write_buffer<32*1024>;
@@ -42,7 +42,7 @@ class Pcapng::Writer : public Trace_recorder::Writer_base
Interface_registry &_interface_registry;
Buffer &_buffer;
Timestamp_calibrator const &_ts_calibrator;
Constructible<New_file> _dst_file { };
Constructible<Append_file> _dst_file { };
Directory::Path _file_path { };
bool _empty_section { false };

View File

@@ -62,12 +62,12 @@ class Pcapng::Write_buffer
return Append_ok();
}
void write_to_file(Genode::New_file &dst, Directory::Path const &path)
void write_to_file(Genode::Append_file &dst, Directory::Path const &path)
{
if (_total_length == 0)
return;
if (dst.append(_buffer, _total_length) != New_file::Append_result::OK)
if (dst.append(_buffer, _total_length) != Append_file::Append_result::OK)
error("Write error for ", path);
clear();