rawfile

package
v0.0.0-...-9fcf0b5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0, MIT Imports: 3 Imported by: 3

Documentation

Overview

Package rawfile contains utilities for using raw host files on Linux hosts.

Index

Constants

View Source
const MaxIovs = 1024

MaxIovs is UIO_MAXIOV, the maximum number of iovecs that may be passed to a host system call in a single array.

View Source
const SizeofIovec = unsafe.Sizeof(unix.Iovec{})

SizeofIovec is the size of a unix.Iovec in bytes.

View Source
const SizeofMMsgHdr = unsafe.Sizeof(MMsgHdr{})

SizeofMMsgHdr is the size of a MMsgHdr in bytes.

Variables

This section is empty.

Functions

func AppendIovecFromBytes

func AppendIovecFromBytes(iovs []unix.Iovec, bs []byte, max int) []unix.Iovec

AppendIovecFromBytes returns append(iovs, IovecFromBytes(bs)). If len(bs) == 0, AppendIovecFromBytes returns iovs without modification. If len(iovs) >= max, AppendIovecFromBytes replaces the final iovec in iovs with one that also includes the contents of bs. Note that this implies that AppendIovecFromBytes is only usable when the returned iovec slice is used as the source of a write.

func BlockingPoll

func BlockingPoll(fds *PollEvent, nfds int, timeout *unix.Timespec) (int, unix.Errno)

BlockingPoll on amd64/arm64 makes the ppoll() syscall while calling the version of entersyscall that relinquishes the P so that other Gs can run. This is meant to be called in cases when the syscall is expected to block. On non amd64/arm64 platforms it just forwards to the ppoll() system call.

func BlockingPollUntilStopped

func BlockingPollUntilStopped(efd int, fd int, events int16) (bool, unix.Errno)

BlockingPollUntilStopped polls for events on fd or until a stop is signalled on the event fd efd. Returns true if stopped, i.e., efd has event POLLIN.

func BlockingRead

func BlockingRead(fd int, b []byte) (int, unix.Errno)

BlockingRead reads from a file descriptor that is set up as non-blocking. If no data is available, it will block in a poll() syscall until the file descriptor becomes readable.

func BlockingReadvUntilStopped

func BlockingReadvUntilStopped(efd int, fd int, iovecs []unix.Iovec) (int, unix.Errno)

BlockingReadvUntilStopped reads from a file descriptor that is set up as non-blocking and stores the data in a list of iovecs buffers. If no data is available, it will block in a poll() syscall until the file descriptor becomes readable or stop is signalled (efd becomes readable). Returns -1 in the latter case.

func BlockingRecvMMsgUntilStopped

func BlockingRecvMMsgUntilStopped(efd int, fd int, msgHdrs []MMsgHdr) (int, unix.Errno)

BlockingRecvMMsgUntilStopped reads from a file descriptor that is set up as non-blocking and stores the received messages in a slice of MMsgHdr structures. If no data is available, it will block in a poll() syscall until the file descriptor becomes readable or stop is signalled (efd becomes readable). Returns -1 in the latter case.

func GetMTU

func GetMTU(name string) (uint32, error)

GetMTU determines the MTU of a network interface device.

func IovecFromBytes

func IovecFromBytes(bs []byte) unix.Iovec

IovecFromBytes returns a unix.Iovec representing bs.

Preconditions: len(bs) > 0.

func NonBlockingSendMMsg

func NonBlockingSendMMsg(fd int, msgHdrs []MMsgHdr) (int, unix.Errno)

NonBlockingSendMMsg sends multiple messages on a socket.

func NonBlockingWrite

func NonBlockingWrite(fd int, buf []byte) unix.Errno

NonBlockingWrite writes the given buffer to a file descriptor. It fails if partial data is written.

func NonBlockingWriteIovec

func NonBlockingWriteIovec(fd int, iovec []unix.Iovec) unix.Errno

NonBlockingWriteIovec writes iovec to a file descriptor in a single unix. It fails if partial data is written.

Types

type MMsgHdr

type MMsgHdr struct {
	Msg unix.Msghdr
	Len uint32
	// contains filtered or unexported fields
}

MMsgHdr represents the mmsg_hdr structure required by recvmmsg() on linux.

type PollEvent

type PollEvent struct {
	FD      int32
	Events  int16
	Revents int16
}

PollEvent represents the pollfd structure passed to a poll() system call.

Jump to

Keyboard shortcuts

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