Skip to content

x/sys/unix: Add wrapper for readv/writev #36201

@Merovius

Description

@Merovius

I'd like to propose exposing readv/writev (and maybe preadv/pwritev and maybeer preadv2/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 []bytes, or b) use unix.Syscall. The latter is fine, but a wrapper would allow to avoid unsafe.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions