I solved the invalid write, but I am still stuck on the syncing.
Apparently I needed to use the fs tied to the `handle` like so:
```cpp handle->fs().write(handle, bufrange, out); ```
So now I focused on the actual syncing, so I added the following:
```cpp handle->fs().queue_sync(handle);
auto res = handle->fs().complete_sync(handle); while (res == Vfs::File_io_service::SYNC_QUEUED) { root_dir.commit_and_wait(); } ```
With `root_dir` being the following:
```cpp Genode::Root_directory root_dir = rom.node().with_sub_node( "vfs", [&](const Genode::Node &config) -> Genode::Root_directory { return {env, heap, config}; }, [&]() -> Genode::Root_directory { Genode::error( "VFS was not configured properly: missing <vfs> under <config>"); return {env, heap, Genode::Node()}; }); ```
The first file gets written to disk, however, after that the program blocks again and no more writes are started. Am I handling the sync correctly?
Best, Rumen
________________________________________ From: Rumen Mitov via users users@lists.genode.org Sent: Tuesday, June 23, 2026 7:28 PM To: Ryan Davidovics via users Cc: Rumen Mitov Subject: How to Explicitly Sync When Appending to a File
CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hello,
I would like to sync the file-system after every invocation to `Genode::Append_file::append()`. However, the `_sync()` interface is private as are the Genode::Append_file's `_io` and `_handle`.
What is the recommended way to sync?
I tried using handles as well:
```cpp Vfs::File_system &fs{root_dir.root_dir()}; Vfs::Vfs_handle *handle {};
fs.open("foo", Vfs::Directory_service::Open_mode::OPEN_MODE_RDWR | Vfs::Directory_service::Open_mode::OPEN_MODE_CREATE, &handle, heap);
// file opens properly
for (long long unsigned i = 0; i < 10; i++) { auto _str = Genode::String<512>(Genode::Hex(i), "\n"); Genode::Const_byte_range_ptr const bufrange { _str.string(), _str.length() }; Genode::size_t out = 0;
auto res = fs.write(handle, bufrange, out); handle->advance_seek(out);
Genode::warning("WROTE: ", out, "B, RES: ", (Genode::uint32_t)res); }
fs.close(handle); ```
However, before I could add syncing to the above example, I noticed that `fs.write()` returns WRITE_ERR_INVALID. I am stuck on what could be wrong, as I based this example off of the internal implementation of `Genode::Writeable_file`.
As always, any help is greatly appreciated :)
Best, Rumen
P.S. This was tested on rump-ext2fs. _______________________________________________ users mailing list -- users@lists.genode.org To unsubscribe send an email to users-leave@lists.genode.org Archived at https://lists.genode.org/mailman3/hyperkitty/list/users@lists.genode.org/mes...