You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[WasmFS] Allow backends to have short reads and writes (#16895)
We previously tried to prevent reads and writes beyond the ends of files by
calling `getSize` on files in the backend-independent implementations of `read`
and `write` and adjusting the length we passed to the backend accordingly. This
works fine when files have meaningful lengths, reads and writes are guaranteed
not to be shortened by the underlying APIs, and files cannot change size
concurrently with the syscall execution, but those requirements are not always
met.
Instead, change the backend API to match the `pread` and `pwrite` syscall APIs,
which allow accesses to be shorter than requested. Specifically, change the
return types to be `ssize_t` so that the accessed lengths can be returned. Error
codes are now returned as negative values, just like in the syscalls themselves.
This change will also have performance benefits, especially for the OPFS
backend, in which getting the size of a file is an asynchronous operation that
is much slower than a small read or write.
0 commit comments