vfs_import: truncate files before writing

genodelabs/genode#5107
This commit is contained in:
Johannes Schlatow 2024-01-30 18:37:38 +01:00 committed by Christian Helmuth
parent 6a94b8d153
commit d23e1a87dd
2 changed files with 19 additions and 1 deletions

View File

@ -65,6 +65,22 @@ install_config {
<binary name="sequence"/>
<resource name="RAM" quantum="1G"/>
<config>
<start name="/bin/true" caps="500">
<config>
<libc stdin="/dev/null" stdout="/dev/log" stderr="/dev/log"/>
<vfs>
<dir name="fs"> <fs/> </dir>
<dir name="dev"> <log/> <null/> </dir>
<ram/>
<import overwrite="yes">
<dir name="fs">
<symlink name="link" target="test"/>
<inline name="test">Hello, this is Genode!</inline>
</dir>
</import>
</vfs>
</config>
</start>
<start name="/bin/true" caps="500">
<config>
<libc stdin="/dev/null" stdout="/dev/log" stderr="/dev/log"/>
@ -108,4 +124,4 @@ build_boot_image [build_artifacts]
append qemu_args " -nographic "
run_genode_until {Hello world!} 30
run_genode_until {Hello world!.{0,7}\n} 30

View File

@ -139,6 +139,8 @@ class Vfs_import::File_system : public Vfs::File_system
return;
}
dst_handle->fs().ftruncate(dst_handle, 0);
char buf[4096];
Vfs_handle::Guard guard { dst_handle };
Flush_guard flush { env.io(), *dst_handle };