Writing to a mem mapped area of a file that was open with `O_APPEND`,
will always write at the end of the file. We can test this with running
virtiofsd with --cache=auto|always:
```python
    import mmap
    import struct
    l = 1024
    f = open("./test.db", "a+b")
    f.truncate(l)
    m = mmap.mmap(f.fileno(), 1024, access=mmap.ACCESS_WRITE)
    m[0:4] = b"0000"
    m.flush()
    print(m.size())
    m[0:4] = b"0000"
    m.flush()
    print(m.size())
```
After each write the size of the file is increased.
This is because, even though the guest kernel sends the correct
offsets, the mem mapped writes in the guest translate into `write()`
operations in the host so that if the file was opened/created with
`O_APPEND` the offset is ignored.

For more details see:
https://gitlab.com/virtio-fs/virtiofsd/-/issues/67
https://github.com/kata-containers/kata-containers/issues/5634

closes #67
---
https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/143

_______________________________________________
Virtio-fs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/virtio-fs

Reply via email to