Documentation ¶
Overview ¶
Package hostfd provides efficient I/O with host file descriptors.
Index ¶
Constants ¶
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.
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 ¶
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.
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.