-
Notifications
You must be signed in to change notification settings - Fork 18k
x/sys/unix: Add wrapper for readv/writev #36201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
(See also #21676 which discusses, among other things, exposing an interface to |
In general we permit adding any existing system call to x/net/unix. Using |
I assume you meant It's fine to add the non-portable |
@tklauser yes I do, thanks, corrected my initial post as well :) I'll send a CL later today. |
Change https://golang.org/cl/212157 mentions this issue: |
I only have Linux machines, so AIUI I can't generate the constants and everything for other platforms. |
iovec read/writes (readv, writev, preadv, pwritev) are present on illumos, but they weren't added to the package. This commit added those missing features. Updates golang/go#36201
Change https://golang.org/cl/224238 mentions this issue: |
iovec read/writes (readv, writev, preadv, pwritev) are present on illumos, but they weren't added to the package. This commit adds those missing features. Updates golang/go#36201 Change-Id: Iecf2bab7ef846f5ca5d693e833491d819618c15d GitHub-Last-Rev: 81a479f GitHub-Pull-Request: #64 Reviewed-on: https://go-review.googlesource.com/c/sys/+/224238 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
I'd like to propose exposing
readv
/writev
(and maybepreadv
/pwritev
and maybeerpreadv2
/pwritev2
) in x/sys/unix, as{Read,Write}v(fd int, iov [][]byte) (int, error)
.My usecase is writing to a file in
O_APPEND
mode, which offers atomicity-guarantees per write. Issuing multiple writes loses those guarantees, so I have to resort to a) allocating a temporary buffer and concatenating the individual[]byte
s, or b) useunix.Syscall
. The latter is fine, but a wrapper would allow to avoidunsafe
.I don't personally care about the
p…
and…v2
variants, but they could be added at the same time. I'm not sure how portable they are, though, beyond Linux.I can send a CL if this is accepted.
The text was updated successfully, but these errors were encountered: