Stream: git-wasmtime

Topic: wasmtime / Issue #2076 wasi-common: pwrite semantics mism...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 29 2020 at 08:24):

ueno labeled Issue #2076:

The documentation of wasi_common::virtfs::FileContents::pwrite says:

    /// Write contents from `buf` to this file starting at `offset`. `offset` plus the length of
    /// `buf` is guaranteed to not exceed `max_size`. Implementations must not indicate more bytes
    /// have been written than the size of `buf`.
    fn pwrite(&mut self, buf: &[u8], offset: types::Filesize) -> Result<usize>;

while POSIX says the offset is a file offset rather than the offset in buffer. Although FileContents::pwrite is currently only used by InMemoryFile implementation, it would be consistent to treat the offset as a file offset.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 29 2020 at 08:24):

ueno opened Issue #2076:

The documentation of wasi_common::virtfs::FileContents::pwrite says:

    /// Write contents from `buf` to this file starting at `offset`. `offset` plus the length of
    /// `buf` is guaranteed to not exceed `max_size`. Implementations must not indicate more bytes
    /// have been written than the size of `buf`.
    fn pwrite(&mut self, buf: &[u8], offset: types::Filesize) -> Result<usize>;

while POSIX says the offset is a file offset rather than the offset in buffer. Although FileContents::pwrite is currently only used by InMemoryFile implementation, it would be consistent to treat the offset as a file offset.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 29 2020 at 11:23):

ueno edited Issue #2076:

The documentation of wasi_common::virtfs::FileContents::pwrite says:

    /// Write contents from `buf` to this file starting at `offset`. `offset` plus the length of
    /// `buf` is guaranteed to not exceed `max_size`. Implementations must not indicate more bytes
    /// have been written than the size of `buf`.
    fn pwrite(&mut self, buf: &[u8], offset: types::Filesize) -> Result<usize>;

while in POSIX (and WASI fd_pwrite) the offset is a file offset rather than the offset in buffer. Although FileContents::pwrite is currently only used by InMemoryFile implementation, it would be consistent to treat the offset as a file offset.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2020 at 06:43):

ueno commented on Issue #2076:

Sorry, this was my misunderstanding and the function actually writes at the file offset.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2020 at 06:43):

ueno closed Issue #2076:

The documentation of wasi_common::virtfs::FileContents::pwrite says:

    /// Write contents from `buf` to this file starting at `offset`. `offset` plus the length of
    /// `buf` is guaranteed to not exceed `max_size`. Implementations must not indicate more bytes
    /// have been written than the size of `buf`.
    fn pwrite(&mut self, buf: &[u8], offset: types::Filesize) -> Result<usize>;

while in POSIX (and WASI fd_pwrite) the offset is a file offset rather than the offset in buffer. Although FileContents::pwrite is currently only used by InMemoryFile implementation, it would be consistent to treat the offset as a file offset.


Last updated: Oct 23 2024 at 20:03 UTC