package unix

import "github.com/cilium/ebpf/internal/unix"

Package unix re-exports Linux specific parts of golang.org/x/sys/unix.

It avoids breaking compilation on other OS by providing stubs as follows:

Index

Constants

const (
	BPF_F_NO_PREALLOC = iota
	BPF_F_NUMA_NODE
	BPF_F_RDONLY
	BPF_F_WRONLY
	BPF_F_RDONLY_PROG
	BPF_F_WRONLY_PROG
	BPF_F_SLEEPABLE
	BPF_F_MMAPABLE
	BPF_F_INNER_MAP
	BPF_F_KPROBE_MULTI_RETURN
	BPF_F_UPROBE_MULTI_RETURN
	BPF_F_XDP_HAS_FRAGS
	BPF_OBJ_NAME_LEN
	BPF_TAG_SIZE
	BPF_RINGBUF_BUSY_BIT
	BPF_RINGBUF_DISCARD_BIT
	BPF_RINGBUF_HDR_SZ
	SYS_BPF
	F_DUPFD_CLOEXEC
	EPOLLIN
	EPOLL_CTL_ADD
	EPOLL_CLOEXEC
	O_CLOEXEC
	O_NONBLOCK
	PROT_NONE
	PROT_READ
	PROT_WRITE
	MAP_ANON
	MAP_SHARED
	MAP_PRIVATE
	PERF_ATTR_SIZE_VER1
	PERF_TYPE_SOFTWARE
	PERF_TYPE_TRACEPOINT
	PERF_COUNT_SW_BPF_OUTPUT
	PERF_EVENT_IOC_DISABLE
	PERF_EVENT_IOC_ENABLE
	PERF_EVENT_IOC_SET_BPF
	PerfBitWatermark
	PerfBitWriteBackward
	PERF_SAMPLE_RAW
	PERF_FLAG_FD_CLOEXEC
	RLIM_INFINITY
	RLIMIT_MEMLOCK
	BPF_STATS_RUN_TIME
	PERF_RECORD_LOST
	PERF_RECORD_SAMPLE
	AT_FDCWD
	RENAME_NOREPLACE
	SO_ATTACH_BPF
	SO_DETACH_BPF
	SOL_SOCKET
	SIGPROF
	SIGUSR1
	SIG_BLOCK
	SIG_UNBLOCK
	BPF_FS_MAGIC
	TRACEFS_MAGIC
	DEBUGFS_MAGIC
	BPF_RB_NO_WAKEUP
	BPF_RB_FORCE_WAKEUP
	BPF_F_LOCK
	AF_UNSPEC
	IFF_UP
)

Constants are distinct to avoid breaking switch statements.

Functions

func Auxv

func Auxv() ([][2]uintptr, error)

func BytePtrFromString

func BytePtrFromString(s string) (*byte, error)

func ByteSliceFromString

func ByteSliceFromString(s string) ([]byte, error)

func ByteSliceToString

func ByteSliceToString(s []byte) string

func Close

func Close(fd int) (err error)

func EpollCreate1

func EpollCreate1(flag int) (fd int, err error)

func EpollCtl

func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)

func EpollWait

func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)

func Eventfd

func Eventfd(initval uint, flags int) (fd int, err error)

func FcntlInt

func FcntlInt(fd uintptr, cmd, arg int) (int, error)

func Fstat

func Fstat(fd int, stat *Stat_t) error

func Getpid

func Getpid() int

func Gettid

func Gettid() int

func IoctlSetInt

func IoctlSetInt(fd int, req uint, value int) error

func Mmap

func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)

func Munmap

func Munmap(b []byte) (err error)

func Open

func Open(path string, mode int, perm uint32) (int, error)

func PerfEventOpen

func PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error)

func Prlimit

func Prlimit(pid, resource int, new, old *Rlimit) error

func PthreadSigmask

func PthreadSigmask(how int, set, oldset *Sigset_t) error

func Renameat2

func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) error

func SchedGetaffinity

func SchedGetaffinity(pid int, set *CPUSet) error

func SchedSetaffinity

func SchedSetaffinity(pid int, set *CPUSet) error

func SetNonblock

func SetNonblock(fd int, nonblocking bool) (err error)

func SetsockoptInt

func SetsockoptInt(fd, level, opt, value int) error

func Statfs

func Statfs(path string, buf *Statfs_t) error

func Tgkill

func Tgkill(tgid int, tid int, sig syscall.Signal) (err error)

func Uname

func Uname(buf *Utsname) (err error)

func Write

func Write(fd int, p []byte) (n int, err error)

Types

type CPUSet

type CPUSet struct{}

func (*CPUSet) Set

func (*CPUSet) Set(int)

type EpollEvent

type EpollEvent struct {
	Events uint32
	Fd     int32
	Pad    int32
}

type Errno

type Errno = syscall.Errno
const (
	E2BIG Errno = iota + 1
	EACCES
	EAGAIN
	EBADF
	EEXIST
	EFAULT
	EILSEQ
	EINTR
	EINVAL
	ENODEV
	ENOENT
	ENOSPC
	ENOTSUP
	ENOTSUPP
	EOPNOTSUPP
	EPERM
	ESRCH
	ESTALE
)

Errnos are distinct and non-zero.

func Syscall

func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)

type PerfEventAttr

type PerfEventAttr struct {
	Type               uint32
	Size               uint32
	Config             uint64
	Sample             uint64
	Sample_type        uint64
	Read_format        uint64
	Bits               uint64
	Wakeup             uint32
	Bp_type            uint32
	Ext1               uint64
	Ext2               uint64
	Branch_sample_type uint64
	Sample_regs_user   uint64
	Sample_stack_user  uint32
	Clockid            int32
	Sample_regs_intr   uint64
	Aux_watermark      uint32
	Sample_max_stack   uint16
}

type PerfEventMmapPage

type PerfEventMmapPage struct {
	Version        uint32
	Compat_version uint32
	Lock           uint32
	Index          uint32
	Offset         int64
	Time_enabled   uint64
	Time_running   uint64
	Capabilities   uint64
	Pmc_width      uint16
	Time_shift     uint16
	Time_mult      uint32
	Time_offset    uint64
	Time_zero      uint64
	Size           uint32

	Data_head   uint64
	Data_tail   uint64
	Data_offset uint64
	Data_size   uint64
	Aux_head    uint64
	Aux_tail    uint64
	Aux_offset  uint64
	Aux_size    uint64
}

type Rlimit

type Rlimit struct {
	Cur uint64
	Max uint64
}

type Signal

type Signal int

type Sigset_t

type Sigset_t struct {
	Val [4]uint64
}

type Stat_t

type Stat_t struct {
	Dev   uint64
	Ino   uint64
	Nlink uint64
	Mode  uint32
	Uid   uint32
	Gid   uint32

	Rdev    uint64
	Size    int64
	Blksize int64
	Blocks  int64
	// contains filtered or unexported fields
}

type Statfs_t

type Statfs_t struct {
	Type    int64
	Bsize   int64
	Blocks  uint64
	Bfree   uint64
	Bavail  uint64
	Files   uint64
	Ffree   uint64
	Fsid    [2]int32
	Namelen int64
	Frsize  int64
	Flags   int64
	Spare   [4]int64
}

type Utsname

type Utsname struct {
	Release [65]byte
	Version [65]byte
}

Source Files

doc.go errno_other.go error.go strings_other.go types_other.go

Version
v0.18.0 (latest)
Published
Apr 2, 2025
Platform
darwin/amd64
Imports
5 packages
Last checked
4 hours ago

Tools for package owners.