hostfd

package
v0.0.0-...-989fa2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hostfd provides efficient I/O with host file descriptors.

Index

Constants

View Source
const MaxReadWriteIov = 1024 // UIO_MAXIOV

MaxReadWriteIov is the maximum permitted size of a struct iovec array in a readv, writev, preadv, or pwritev host syscall.

View Source
const MaxSendRecvMsgIov = 1024 // UIO_MAXIOV

MaxSendRecvMsgIov is the maximum permitted size of a struct iovec array in a sendmsg or recvmsg host syscall.

Variables

This section is empty.

Functions

func Preadv2

func Preadv2(fd int32, dsts safemem.BlockSeq, offset int64, flags uint32) (uint64, error)

Preadv2 reads up to dsts.NumBytes() bytes from host file descriptor fd into dsts. offset and flags are interpreted as for preadv2(2).

Preconditions: !dsts.IsEmpty().

func PutReadWriterAt

func PutReadWriterAt(rw *ReadWriterAt)

PutReadWriterAt releases a ReadWriterAt returned by a previous call to GetReadWriterAt that is no longer in use.

func Pwritev2

func Pwritev2(fd int32, srcs safemem.BlockSeq, offset int64, flags uint32) (uint64, error)

Pwritev2 writes up to srcs.NumBytes() from srcs into host file descriptor fd. offset and flags are interpreted as for pwritev2(2).

Preconditions: !srcs.IsEmpty().

Types

type ReadWriterAt

type ReadWriterAt struct {
	// contains filtered or unexported fields
}

ReadWriterAt implements safemem.Reader and safemem.Writer by reading from and writing to a host file descriptor respectively. ReadWriterAts should be obtained by calling GetReadWriterAt.

Clients should usually prefer to use Preadv2 and Pwritev2 directly.

func GetReadWriterAt

func GetReadWriterAt(fd int32, offset int64, flags uint32) *ReadWriterAt

GetReadWriterAt returns a ReadWriterAt that reads from / writes to the given host file descriptor, starting at the given offset and using the given preadv2(2)/pwritev2(2) flags. If offset is -1, the host file descriptor's offset is used instead. Users are responsible for ensuring that fd remains valid for the lifetime of the returned ReadWriterAt, and must call PutReadWriterAt when it is no longer needed.

func (*ReadWriterAt) ReadToBlocks

func (rw *ReadWriterAt) ReadToBlocks(dsts safemem.BlockSeq) (uint64, error)

ReadToBlocks implements safemem.Reader.ReadToBlocks.

func (*ReadWriterAt) WriteFromBlocks

func (rw *ReadWriterAt) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error)

WriteFromBlocks implements safemem.Writer.WriteFromBlocks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL