├── LICENSE ├── Makefile ├── README ├── TODO ├── go.mod ├── go.sum ├── src ├── bpf │ ├── Makefile │ ├── reaper-hist.bpf.c │ └── reaper-log.bpf.c └── go │ ├── Makefile │ └── reaper.go └── vendor ├── github.com └── cilium │ └── ebpf │ ├── .clang-format │ ├── .gitignore │ ├── .golangci.yaml │ ├── ARCHITECTURE.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── asm │ ├── alu.go │ ├── alu_string.go │ ├── doc.go │ ├── func.go │ ├── func_string.go │ ├── instruction.go │ ├── jump.go │ ├── jump_string.go │ ├── load_store.go │ ├── load_store_string.go │ ├── opcode.go │ ├── opcode_string.go │ └── register.go │ ├── attachtype_string.go │ ├── collection.go │ ├── doc.go │ ├── elf_reader.go │ ├── features │ ├── doc.go │ ├── map.go │ ├── prog.go │ └── version.go │ ├── info.go │ ├── internal │ ├── align.go │ ├── btf │ │ ├── btf.go │ │ ├── btf_types.go │ │ ├── btf_types_string.go │ │ ├── core.go │ │ ├── doc.go │ │ ├── ext_info.go │ │ ├── format.go │ │ ├── info.go │ │ ├── strings.go │ │ └── types.go │ ├── cpu.go │ ├── elf.go │ ├── endian.go │ ├── epoll │ │ └── poller.go │ ├── errors.go │ ├── feature.go │ ├── io.go │ ├── output.go │ ├── pinning.go │ ├── sys │ │ ├── doc.go │ │ ├── fd.go │ │ ├── ptr.go │ │ ├── ptr_32_be.go │ │ ├── ptr_32_le.go │ │ ├── ptr_64.go │ │ ├── syscall.go │ │ └── types.go │ ├── unix │ │ ├── types_linux.go │ │ └── types_other.go │ ├── vdso.go │ └── version.go │ ├── link │ ├── cgroup.go │ ├── doc.go │ ├── iter.go │ ├── kprobe.go │ ├── link.go │ ├── netns.go │ ├── perf_event.go │ ├── platform.go │ ├── program.go │ ├── raw_tracepoint.go │ ├── socket_filter.go │ ├── syscalls.go │ ├── tracepoint.go │ ├── tracing.go │ ├── uprobe.go │ └── xdp.go │ ├── linker.go │ ├── map.go │ ├── marshalers.go │ ├── perf │ ├── doc.go │ ├── reader.go │ └── ring.go │ ├── prog.go │ ├── run-tests.sh │ ├── syscalls.go │ ├── types.go │ └── types_string.go ├── golang.org └── x │ └── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── internal │ └── unsafeheader │ │ └── unsafeheader.go │ └── unix │ ├── .gitignore │ ├── README.md │ ├── affinity_linux.go │ ├── aliases.go │ ├── asm_aix_ppc64.s │ ├── asm_bsd_386.s │ ├── asm_bsd_amd64.s │ ├── asm_bsd_arm.s │ ├── asm_bsd_arm64.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_riscv64.s │ ├── asm_linux_s390x.s │ ├── asm_openbsd_mips64.s │ ├── asm_solaris_amd64.s │ ├── asm_zos_s390x.s │ ├── bluetooth_linux.go │ ├── cap_freebsd.go │ ├── constants.go │ ├── dev_aix_ppc.go │ ├── dev_aix_ppc64.go │ ├── dev_darwin.go │ ├── dev_dragonfly.go │ ├── dev_freebsd.go │ ├── dev_linux.go │ ├── dev_netbsd.go │ ├── dev_openbsd.go │ ├── dev_zos.go │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── epoll_zos.go │ ├── errors_freebsd_386.go │ ├── errors_freebsd_amd64.go │ ├── errors_freebsd_arm.go │ ├── errors_freebsd_arm64.go │ ├── fcntl.go │ ├── fcntl_darwin.go │ ├── fcntl_linux_32bit.go │ ├── fdset.go │ ├── fstatfs_zos.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── ifreq_linux.go │ ├── ioctl.go │ ├── ioctl_linux.go │ ├── ioctl_zos.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── pagesize_unix.go │ ├── pledge_openbsd.go │ ├── ptrace_darwin.go │ ├── ptrace_ios.go │ ├── race.go │ ├── race0.go │ ├── readdirent_getdents.go │ ├── readdirent_getdirentries.go │ ├── sockcmsg_dragonfly.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── sockcmsg_unix_other.go │ ├── str.go │ ├── syscall.go │ ├── syscall_aix.go │ ├── syscall_aix_ppc.go │ ├── syscall_aix_ppc64.go │ ├── syscall_bsd.go │ ├── syscall_darwin.1_12.go │ ├── syscall_darwin.1_13.go │ ├── syscall_darwin.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm64.go │ ├── syscall_darwin_libSystem.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_freebsd_arm64.go │ ├── syscall_illumos.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_alarm.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_gc.go │ ├── syscall_linux_gc_386.go │ ├── syscall_linux_gc_arm.go │ ├── syscall_linux_gccgo_386.go │ ├── syscall_linux_gccgo_arm.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_riscv64.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_netbsd_arm64.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_openbsd_arm.go │ ├── syscall_openbsd_arm64.go │ ├── syscall_openbsd_mips64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── syscall_unix_gc_ppc64x.go │ ├── syscall_zos_s390x.go │ ├── sysvshm_linux.go │ ├── sysvshm_unix.go │ ├── sysvshm_unix_other.go │ ├── timestruct.go │ ├── unveil_openbsd.go │ ├── xattr_bsd.go │ ├── zerrors_aix_ppc.go │ ├── zerrors_aix_ppc64.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_freebsd_arm64.go │ ├── zerrors_linux.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_riscv64.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_netbsd_arm64.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_openbsd_arm.go │ ├── zerrors_openbsd_arm64.go │ ├── zerrors_openbsd_mips64.go │ ├── zerrors_solaris_amd64.go │ ├── zerrors_zos_s390x.go │ ├── zptrace_armnn_linux.go │ ├── zptrace_linux_arm64.go │ ├── zptrace_mipsnn_linux.go │ ├── zptrace_mipsnnle_linux.go │ ├── zptrace_x86_linux.go │ ├── zsyscall_aix_ppc.go │ ├── zsyscall_aix_ppc64.go │ ├── zsyscall_aix_ppc64_gc.go │ ├── zsyscall_aix_ppc64_gccgo.go │ ├── zsyscall_darwin_amd64.1_13.go │ ├── zsyscall_darwin_amd64.1_13.s │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_amd64.s │ ├── zsyscall_darwin_arm64.1_13.go │ ├── zsyscall_darwin_arm64.1_13.s │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_darwin_arm64.s │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_freebsd_arm64.go │ ├── zsyscall_illumos_amd64.go │ ├── zsyscall_linux.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_riscv64.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_netbsd_arm64.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_openbsd_arm.go │ ├── zsyscall_openbsd_arm64.go │ ├── zsyscall_openbsd_mips64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsyscall_zos_s390x.go │ ├── zsysctl_openbsd_386.go │ ├── zsysctl_openbsd_amd64.go │ ├── zsysctl_openbsd_arm.go │ ├── zsysctl_openbsd_arm64.go │ ├── zsysctl_openbsd_mips64.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_freebsd_arm64.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_riscv64.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_netbsd_arm64.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_openbsd_arm.go │ ├── zsysnum_openbsd_arm64.go │ ├── zsysnum_openbsd_mips64.go │ ├── zsysnum_zos_s390x.go │ ├── ztypes_aix_ppc.go │ ├── ztypes_aix_ppc64.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_freebsd_arm64.go │ ├── ztypes_illumos_amd64.go │ ├── ztypes_linux.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_riscv64.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_netbsd_arm64.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ ├── ztypes_openbsd_arm.go │ ├── ztypes_openbsd_arm64.go │ ├── ztypes_openbsd_mips64.go │ ├── ztypes_solaris_amd64.go │ └── ztypes_zos_s390x.go └── modules.txt /Makefile: -------------------------------------------------------------------------------- 1 | all: build-bpf build-go 2 | 3 | build-bpf: 4 | make -C src/bpf 5 | build-go: 6 | go build -o build/reaperfish src/go/reaper.go 7 | 8 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Install instructions 2 | --------------------- 3 | 4 | o Minimum required/tested versions: 5 | 6 | Linux kernel: 5.13 7 | clang: 13 8 | 9 | 10 | o Ubuntu impish (21.10): 11 | 12 | sudo apt install clang llvm libbpf-dev libbpf0 dwarves golang-go make 13 | sudo apt install linux-tools-common (for bpftool, also needs the kernel specific linux-tools- package) 14 | 15 | mkdir build 16 | make 17 | 18 | o Usage (no install yet) 19 | 20 | cd build 21 | sudo ./reaperfish -device /dev/nvme0n1p1 22 | 23 | Make sure to pick the correct device, e.g. if you want to monitor IO on /home you need to pick whatever mount 24 | or lsblk lists for that device. 25 | 26 | o Optional Docker build instructions: 27 | 28 | sudo apt install docker.io 29 | sudo adduser myuser docker 30 | 31 | TODO: add Dockerfile with upstream libbpf git 32 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module reaper 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/cilium/ebpf v0.8.1 7 | golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 8 | ) 9 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/cilium/ebpf v0.8.1 h1:bLSSEbBLqGPXxls55pGr5qWZaTqcmfDJHhou7t254ao= 2 | github.com/cilium/ebpf v0.8.1/go.mod h1:f5zLIM0FSNuAkSyLAN7X+Hy6yznlF1mNiWUMfxMtrgk= 3 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 4 | github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss= 5 | github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= 6 | github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= 7 | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 8 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 9 | github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= 10 | github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= 11 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 12 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 13 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 14 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 15 | github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= 16 | github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= 17 | golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 18 | golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 h1:QyVthZKMsyaQwBTJE04jdNN0Pp5Fn9Qga0mrgxyERQM= 19 | golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 20 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 21 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 22 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 23 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 24 | -------------------------------------------------------------------------------- /src/bpf/Makefile: -------------------------------------------------------------------------------- 1 | all: vmlinux build 2 | 3 | BUILDDIR = ../../build 4 | OBJS = reaper-log.bpf.o reaper-hist.bpf.o 5 | build: $(OBJS) 6 | 7 | CLANG ?= clang 8 | LLC ?= llc 9 | OPT ?= opt 10 | LLVM_DIS ?= llvm-dis 11 | LLC_FLAGS += -mattr=dwarfris 12 | BPFTOOL ?= bpftool 13 | LINUX_KERNEL_VERSION := $(shell uname -r) 14 | 15 | $(OBJS): %.o:%.c 16 | $(CLANG) -D__KERNEL__ -D__ASM_SYSREG_H -D__BPF_TRACING__ \ 17 | -Wno-unknown-attributes \ 18 | -fno-stack-protector -fno-jump-tables -fno-unwind-tables -fno-asynchronous-unwind-tables \ 19 | -xc \ 20 | -I $(BUILDDIR) \ 21 | -g -O2 \ 22 | -target bpf -emit-llvm -Xclang -disable-llvm-passes \ 23 | -c $< -o - | \ 24 | $(OPT) -O2 -mtriple=bpf-pc-linux | $(LLVM_DIS) | \ 25 | $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $(BUILDDIR)/$@ 26 | llvm-strip -g $(BUILDDIR)/$@ 27 | 28 | # TODO: genereate stripped down version of vmlinux.h to reduce kernel change flux 29 | vmlinux: 30 | $(BPFTOOL) btf dump file /sys/kernel/btf/vmlinux format c > $(BUILDDIR)/vmlinux.h 31 | 32 | clean: 33 | @rm $(OBJS) 34 | -------------------------------------------------------------------------------- /src/go/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | SHELL=/bin/bash 4 | 5 | UID := $(shell id -u) 6 | GID := $(shell id -g) 7 | 8 | SOURCE="src/git-trees/reaperfish/src/go" 9 | SCRIPT="src/git-trees/reaperfish/script" 10 | 11 | build: 12 | docker run --rm --user $(UID):$(GID) --network=host -v $(HOME)/$(SOURCE):/rf -v $(HOME)/$(SCRIPT):/script golang:latest bash /script/build.sh 13 | 14 | shell: 15 | docker run --rm -it --user $(UID):$(GID) --network=host -v $(HOME)/$(SOURCE):/rf -v $(HOME)/$(SCRIPT):/script golang:latest /bin/bash 16 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: LLVM 4 | AlignAfterOpenBracket: DontAlign 5 | AlignConsecutiveAssignments: true 6 | AlignEscapedNewlines: DontAlign 7 | AlwaysBreakBeforeMultilineStrings: true 8 | AlwaysBreakTemplateDeclarations: false 9 | AllowAllParametersOfDeclarationOnNextLine: false 10 | AllowShortFunctionsOnASingleLine: false 11 | BreakBeforeBraces: Attach 12 | IndentWidth: 4 13 | KeepEmptyLinesAtTheStartOfBlocks: false 14 | TabWidth: 4 15 | UseTab: ForContinuationAndIndentation 16 | ColumnLimit: 1000 17 | ... 18 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | *.o 8 | !*_bpf*.o 9 | 10 | # Test binary, build with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/.golangci.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | issues: 3 | exclude-rules: 4 | # syscall param structs will have unused fields in Go code. 5 | - path: syscall.*.go 6 | linters: 7 | - structcheck 8 | 9 | linters: 10 | disable-all: true 11 | enable: 12 | - deadcode 13 | - errcheck 14 | - goimports 15 | - gosimple 16 | - govet 17 | - ineffassign 18 | - misspell 19 | - staticcheck 20 | - structcheck 21 | - typecheck 22 | - unused 23 | - varcheck 24 | 25 | # Could be enabled later: 26 | # - gocyclo 27 | # - maligned 28 | # - gosec 29 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at nathanjsweet at gmail dot com or i at lmb dot io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Development is on [GitHub](https://github.com/cilium/ebpf) and contributions in 4 | the form of pull requests and issues reporting bugs or suggesting new features 5 | are welcome. Please take a look at [the architecture](ARCHITECTURE.md) to get 6 | a better understanding for the high-level goals. 7 | 8 | New features must be accompanied by tests. Before starting work on any large 9 | feature, please [join](https://ebpf.io/slack) the 10 | [#ebpf-go](https://cilium.slack.com/messages/ebpf-go) channel on Slack to 11 | discuss the design first. 12 | 13 | When submitting pull requests, consider writing details about what problem you 14 | are solving and why the proposed approach solves that problem in commit messages 15 | and/or pull request description to help future library users and maintainers to 16 | reason about the proposed changes. 17 | 18 | ## Running the tests 19 | 20 | Many of the tests require privileges to set resource limits and load eBPF code. 21 | The easiest way to obtain these is to run the tests with `sudo`. 22 | 23 | To test the current package with your local kernel you can simply run: 24 | ``` 25 | go test -exec sudo ./... 26 | ``` 27 | 28 | To test the current package with a different kernel version you can use the [run-tests.sh](run-tests.sh) script. 29 | It requires [virtme](https://github.com/amluto/virtme) and qemu to be installed. 30 | 31 | Examples: 32 | 33 | ```bash 34 | # Run all tests on a 5.4 kernel 35 | ./run-tests.sh 5.4 36 | 37 | # Run a subset of tests: 38 | ./run-tests.sh 5.4 go test ./link 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Nathan Sweet 4 | Copyright (c) 2018, 2019 Cloudflare 5 | Copyright (c) 2019 Authors of Cilium 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/Makefile: -------------------------------------------------------------------------------- 1 | # The development version of clang is distributed as the 'clang' binary, 2 | # while stable/released versions have a version number attached. 3 | # Pin the default clang to a stable version. 4 | CLANG ?= clang-13 5 | STRIP ?= llvm-strip-13 6 | CFLAGS := -O2 -g -Wall -Werror $(CFLAGS) 7 | 8 | # Obtain an absolute path to the directory of the Makefile. 9 | # Assume the Makefile is in the root of the repository. 10 | REPODIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) 11 | UIDGID := $(shell stat -c '%u:%g' ${REPODIR}) 12 | 13 | # Prefer podman if installed, otherwise use docker. 14 | # Note: Setting the var at runtime will always override. 15 | CONTAINER_ENGINE ?= $(if $(shell command -v podman), podman, docker) 16 | CONTAINER_RUN_ARGS ?= $(if $(filter ${CONTAINER_ENGINE}, podman),, --user "${UIDGID}") 17 | 18 | IMAGE := $(shell cat ${REPODIR}/testdata/docker/IMAGE) 19 | VERSION := $(shell cat ${REPODIR}/testdata/docker/VERSION) 20 | 21 | # clang <8 doesn't tag relocs properly (STT_NOTYPE) 22 | # clang 9 is the first version emitting BTF 23 | TARGETS := \ 24 | testdata/loader-clang-7 \ 25 | testdata/loader-clang-9 \ 26 | testdata/loader-$(CLANG) \ 27 | testdata/btf_map_init \ 28 | testdata/invalid_map \ 29 | testdata/raw_tracepoint \ 30 | testdata/invalid_map_static \ 31 | testdata/invalid_btf_map_init \ 32 | testdata/strings \ 33 | testdata/freplace \ 34 | testdata/iproute2_map_compat \ 35 | testdata/map_spin_lock \ 36 | testdata/subprog_reloc \ 37 | testdata/fwd_decl \ 38 | internal/btf/testdata/relocs 39 | 40 | .PHONY: all clean container-all container-shell generate 41 | 42 | .DEFAULT_TARGET = container-all 43 | 44 | # Build all ELF binaries using a containerized LLVM toolchain. 45 | container-all: 46 | ${CONTAINER_ENGINE} run --rm ${CONTAINER_RUN_ARGS} \ 47 | -v "${REPODIR}":/ebpf -w /ebpf --env MAKEFLAGS \ 48 | --env CFLAGS="-fdebug-prefix-map=/ebpf=." \ 49 | --env HOME="/tmp" \ 50 | "${IMAGE}:${VERSION}" \ 51 | $(MAKE) all 52 | 53 | # (debug) Drop the user into a shell inside the container as root. 54 | container-shell: 55 | ${CONTAINER_ENGINE} run --rm -ti \ 56 | -v "${REPODIR}":/ebpf -w /ebpf \ 57 | "${IMAGE}:${VERSION}" 58 | 59 | clean: 60 | -$(RM) testdata/*.elf 61 | -$(RM) internal/btf/testdata/*.elf 62 | 63 | all: $(addsuffix -el.elf,$(TARGETS)) $(addsuffix -eb.elf,$(TARGETS)) generate 64 | ln -srf testdata/loader-$(CLANG)-el.elf testdata/loader-el.elf 65 | ln -srf testdata/loader-$(CLANG)-eb.elf testdata/loader-eb.elf 66 | 67 | # $BPF_CLANG is used in go:generate invocations. 68 | generate: export BPF_CLANG := $(CLANG) 69 | generate: export BPF_CFLAGS := $(CFLAGS) 70 | generate: 71 | go generate ./cmd/bpf2go/test 72 | cd examples/ && go generate ./... 73 | 74 | testdata/loader-%-el.elf: testdata/loader.c 75 | $* $(CFLAGS) -target bpfel -c $< -o $@ 76 | $(STRIP) -g $@ 77 | 78 | testdata/loader-%-eb.elf: testdata/loader.c 79 | $* $(CFLAGS) -target bpfeb -c $< -o $@ 80 | $(STRIP) -g $@ 81 | 82 | %-el.elf: %.c 83 | $(CLANG) $(CFLAGS) -target bpfel -c $< -o $@ 84 | $(STRIP) -g $@ 85 | 86 | %-eb.elf : %.c 87 | $(CLANG) $(CFLAGS) -target bpfeb -c $< -o $@ 88 | $(STRIP) -g $@ 89 | 90 | # Usage: make VMLINUX=/path/to/vmlinux vmlinux-btf 91 | .PHONY: vmlinux-btf 92 | vmlinux-btf: internal/btf/testdata/vmlinux-btf.gz 93 | internal/btf/testdata/vmlinux-btf.gz: $(VMLINUX) 94 | objcopy --dump-section .BTF=/dev/stdout "$<" /dev/null | gzip > "$@" 95 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/README.md: -------------------------------------------------------------------------------- 1 | # eBPF 2 | 3 | [![PkgGoDev](https://pkg.go.dev/badge/github.com/cilium/ebpf)](https://pkg.go.dev/github.com/cilium/ebpf) 4 | 5 | ![HoneyGopher](.github/images/cilium-ebpf.png) 6 | 7 | eBPF is a pure Go library that provides utilities for loading, compiling, and 8 | debugging eBPF programs. It has minimal external dependencies and is intended to 9 | be used in long running processes. 10 | 11 | The library is maintained by [Cloudflare](https://www.cloudflare.com) and 12 | [Cilium](https://www.cilium.io). 13 | 14 | See [ebpf.io](https://ebpf.io) for other projects from the eBPF ecosystem. 15 | 16 | ## Getting Started 17 | 18 | A small collection of Go and eBPF programs that serve as examples for building 19 | your own tools can be found under [examples/](examples/). 20 | 21 | Contributions are highly encouraged, as they highlight certain use cases of 22 | eBPF and the library, and help shape the future of the project. 23 | 24 | ## Getting Help 25 | 26 | Please 27 | [join](https://ebpf.io/slack) the 28 | [#ebpf-go](https://cilium.slack.com/messages/ebpf-go) channel on Slack if you 29 | have questions regarding the library. 30 | 31 | ## Packages 32 | 33 | This library includes the following packages: 34 | 35 | * [asm](https://pkg.go.dev/github.com/cilium/ebpf/asm) contains a basic 36 | assembler, allowing you to write eBPF assembly instructions directly 37 | within your Go code. (You don't need to use this if you prefer to write your eBPF program in C.) 38 | * [cmd/bpf2go](https://pkg.go.dev/github.com/cilium/ebpf/cmd/bpf2go) allows 39 | compiling and embedding eBPF programs written in C within Go code. As well as 40 | compiling the C code, it auto-generates Go code for loading and manipulating 41 | the eBPF program and map objects. 42 | * [link](https://pkg.go.dev/github.com/cilium/ebpf/link) allows attaching eBPF 43 | to various hooks 44 | * [perf](https://pkg.go.dev/github.com/cilium/ebpf/perf) allows reading from a 45 | `PERF_EVENT_ARRAY` 46 | * [ringbuf](https://pkg.go.dev/github.com/cilium/ebpf/ringbuf) allows reading from a 47 | `BPF_MAP_TYPE_RINGBUF` map 48 | * [features](https://pkg.go.dev/github.com/cilium/ebpf/features) implements the equivalent 49 | of `bpftool feature probe` for discovering BPF-related kernel features using native Go. 50 | * [rlimit](https://pkg.go.dev/github.com/cilium/ebpf/rlimit) provides a convenient API to lift 51 | the `RLIMIT_MEMLOCK` constraint on kernels before 5.11. 52 | 53 | ## Requirements 54 | 55 | * A version of Go that is [supported by 56 | upstream](https://golang.org/doc/devel/release.html#policy) 57 | * Linux >= 4.4. CI is run against LTS releases. 58 | 59 | ## Regenerating Testdata 60 | 61 | Run `make` in the root of this repository to rebuild testdata in all 62 | subpackages. This requires Docker, as it relies on a standardized build 63 | environment to keep the build output stable. 64 | 65 | It is possible to regenerate data using Podman by overriding the `CONTAINER_*` 66 | variables: `CONTAINER_ENGINE=podman CONTAINER_RUN_ARGS= make`. 67 | 68 | The toolchain image build files are kept in [testdata/docker/](testdata/docker/). 69 | 70 | ## License 71 | 72 | MIT 73 | 74 | ### eBPF Gopher 75 | 76 | The eBPF honeygopher is based on the Go gopher designed by Renee French. 77 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/asm/alu_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -output alu_string.go -type=Source,Endianness,ALUOp"; DO NOT EDIT. 2 | 3 | package asm 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[InvalidSource-255] 12 | _ = x[ImmSource-0] 13 | _ = x[RegSource-8] 14 | } 15 | 16 | const ( 17 | _Source_name_0 = "ImmSource" 18 | _Source_name_1 = "RegSource" 19 | _Source_name_2 = "InvalidSource" 20 | ) 21 | 22 | func (i Source) String() string { 23 | switch { 24 | case i == 0: 25 | return _Source_name_0 26 | case i == 8: 27 | return _Source_name_1 28 | case i == 255: 29 | return _Source_name_2 30 | default: 31 | return "Source(" + strconv.FormatInt(int64(i), 10) + ")" 32 | } 33 | } 34 | func _() { 35 | // An "invalid array index" compiler error signifies that the constant values have changed. 36 | // Re-run the stringer command to generate them again. 37 | var x [1]struct{} 38 | _ = x[InvalidEndian-255] 39 | _ = x[LE-0] 40 | _ = x[BE-8] 41 | } 42 | 43 | const ( 44 | _Endianness_name_0 = "LE" 45 | _Endianness_name_1 = "BE" 46 | _Endianness_name_2 = "InvalidEndian" 47 | ) 48 | 49 | func (i Endianness) String() string { 50 | switch { 51 | case i == 0: 52 | return _Endianness_name_0 53 | case i == 8: 54 | return _Endianness_name_1 55 | case i == 255: 56 | return _Endianness_name_2 57 | default: 58 | return "Endianness(" + strconv.FormatInt(int64(i), 10) + ")" 59 | } 60 | } 61 | func _() { 62 | // An "invalid array index" compiler error signifies that the constant values have changed. 63 | // Re-run the stringer command to generate them again. 64 | var x [1]struct{} 65 | _ = x[InvalidALUOp-255] 66 | _ = x[Add-0] 67 | _ = x[Sub-16] 68 | _ = x[Mul-32] 69 | _ = x[Div-48] 70 | _ = x[Or-64] 71 | _ = x[And-80] 72 | _ = x[LSh-96] 73 | _ = x[RSh-112] 74 | _ = x[Neg-128] 75 | _ = x[Mod-144] 76 | _ = x[Xor-160] 77 | _ = x[Mov-176] 78 | _ = x[ArSh-192] 79 | _ = x[Swap-208] 80 | } 81 | 82 | const _ALUOp_name = "AddSubMulDivOrAndLShRShNegModXorMovArShSwapInvalidALUOp" 83 | 84 | var _ALUOp_map = map[ALUOp]string{ 85 | 0: _ALUOp_name[0:3], 86 | 16: _ALUOp_name[3:6], 87 | 32: _ALUOp_name[6:9], 88 | 48: _ALUOp_name[9:12], 89 | 64: _ALUOp_name[12:14], 90 | 80: _ALUOp_name[14:17], 91 | 96: _ALUOp_name[17:20], 92 | 112: _ALUOp_name[20:23], 93 | 128: _ALUOp_name[23:26], 94 | 144: _ALUOp_name[26:29], 95 | 160: _ALUOp_name[29:32], 96 | 176: _ALUOp_name[32:35], 97 | 192: _ALUOp_name[35:39], 98 | 208: _ALUOp_name[39:43], 99 | 255: _ALUOp_name[43:55], 100 | } 101 | 102 | func (i ALUOp) String() string { 103 | if str, ok := _ALUOp_map[i]; ok { 104 | return str 105 | } 106 | return "ALUOp(" + strconv.FormatInt(int64(i), 10) + ")" 107 | } 108 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/asm/doc.go: -------------------------------------------------------------------------------- 1 | // Package asm is an assembler for eBPF bytecode. 2 | package asm 3 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/asm/jump_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -output jump_string.go -type=JumpOp"; DO NOT EDIT. 2 | 3 | package asm 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[InvalidJumpOp-255] 12 | _ = x[Ja-0] 13 | _ = x[JEq-16] 14 | _ = x[JGT-32] 15 | _ = x[JGE-48] 16 | _ = x[JSet-64] 17 | _ = x[JNE-80] 18 | _ = x[JSGT-96] 19 | _ = x[JSGE-112] 20 | _ = x[Call-128] 21 | _ = x[Exit-144] 22 | _ = x[JLT-160] 23 | _ = x[JLE-176] 24 | _ = x[JSLT-192] 25 | _ = x[JSLE-208] 26 | } 27 | 28 | const _JumpOp_name = "JaJEqJGTJGEJSetJNEJSGTJSGECallExitJLTJLEJSLTJSLEInvalidJumpOp" 29 | 30 | var _JumpOp_map = map[JumpOp]string{ 31 | 0: _JumpOp_name[0:2], 32 | 16: _JumpOp_name[2:5], 33 | 32: _JumpOp_name[5:8], 34 | 48: _JumpOp_name[8:11], 35 | 64: _JumpOp_name[11:15], 36 | 80: _JumpOp_name[15:18], 37 | 96: _JumpOp_name[18:22], 38 | 112: _JumpOp_name[22:26], 39 | 128: _JumpOp_name[26:30], 40 | 144: _JumpOp_name[30:34], 41 | 160: _JumpOp_name[34:37], 42 | 176: _JumpOp_name[37:40], 43 | 192: _JumpOp_name[40:44], 44 | 208: _JumpOp_name[44:48], 45 | 255: _JumpOp_name[48:61], 46 | } 47 | 48 | func (i JumpOp) String() string { 49 | if str, ok := _JumpOp_map[i]; ok { 50 | return str 51 | } 52 | return "JumpOp(" + strconv.FormatInt(int64(i), 10) + ")" 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/asm/load_store_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -output load_store_string.go -type=Mode,Size"; DO NOT EDIT. 2 | 3 | package asm 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[InvalidMode-255] 12 | _ = x[ImmMode-0] 13 | _ = x[AbsMode-32] 14 | _ = x[IndMode-64] 15 | _ = x[MemMode-96] 16 | _ = x[XAddMode-192] 17 | } 18 | 19 | const ( 20 | _Mode_name_0 = "ImmMode" 21 | _Mode_name_1 = "AbsMode" 22 | _Mode_name_2 = "IndMode" 23 | _Mode_name_3 = "MemMode" 24 | _Mode_name_4 = "XAddMode" 25 | _Mode_name_5 = "InvalidMode" 26 | ) 27 | 28 | func (i Mode) String() string { 29 | switch { 30 | case i == 0: 31 | return _Mode_name_0 32 | case i == 32: 33 | return _Mode_name_1 34 | case i == 64: 35 | return _Mode_name_2 36 | case i == 96: 37 | return _Mode_name_3 38 | case i == 192: 39 | return _Mode_name_4 40 | case i == 255: 41 | return _Mode_name_5 42 | default: 43 | return "Mode(" + strconv.FormatInt(int64(i), 10) + ")" 44 | } 45 | } 46 | func _() { 47 | // An "invalid array index" compiler error signifies that the constant values have changed. 48 | // Re-run the stringer command to generate them again. 49 | var x [1]struct{} 50 | _ = x[InvalidSize-255] 51 | _ = x[DWord-24] 52 | _ = x[Word-0] 53 | _ = x[Half-8] 54 | _ = x[Byte-16] 55 | } 56 | 57 | const ( 58 | _Size_name_0 = "Word" 59 | _Size_name_1 = "Half" 60 | _Size_name_2 = "Byte" 61 | _Size_name_3 = "DWord" 62 | _Size_name_4 = "InvalidSize" 63 | ) 64 | 65 | func (i Size) String() string { 66 | switch { 67 | case i == 0: 68 | return _Size_name_0 69 | case i == 8: 70 | return _Size_name_1 71 | case i == 16: 72 | return _Size_name_2 73 | case i == 24: 74 | return _Size_name_3 75 | case i == 255: 76 | return _Size_name_4 77 | default: 78 | return "Size(" + strconv.FormatInt(int64(i), 10) + ")" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/asm/opcode_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -output opcode_string.go -type=Class"; DO NOT EDIT. 2 | 3 | package asm 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[LdClass-0] 12 | _ = x[LdXClass-1] 13 | _ = x[StClass-2] 14 | _ = x[StXClass-3] 15 | _ = x[ALUClass-4] 16 | _ = x[JumpClass-5] 17 | _ = x[Jump32Class-6] 18 | _ = x[ALU64Class-7] 19 | } 20 | 21 | const _Class_name = "LdClassLdXClassStClassStXClassALUClassJumpClassJump32ClassALU64Class" 22 | 23 | var _Class_index = [...]uint8{0, 7, 15, 22, 30, 38, 47, 58, 68} 24 | 25 | func (i Class) String() string { 26 | if i >= Class(len(_Class_index)-1) { 27 | return "Class(" + strconv.FormatInt(int64(i), 10) + ")" 28 | } 29 | return _Class_name[_Class_index[i]:_Class_index[i+1]] 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/asm/register.go: -------------------------------------------------------------------------------- 1 | package asm 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Register is the source or destination of most operations. 8 | type Register uint8 9 | 10 | // R0 contains return values. 11 | const R0 Register = 0 12 | 13 | // Registers for function arguments. 14 | const ( 15 | R1 Register = R0 + 1 + iota 16 | R2 17 | R3 18 | R4 19 | R5 20 | ) 21 | 22 | // Callee saved registers preserved by function calls. 23 | const ( 24 | R6 Register = R5 + 1 + iota 25 | R7 26 | R8 27 | R9 28 | ) 29 | 30 | // Read-only frame pointer to access stack. 31 | const ( 32 | R10 Register = R9 + 1 33 | RFP = R10 34 | ) 35 | 36 | // Pseudo registers used by 64bit loads and jumps 37 | const ( 38 | PseudoMapFD = R1 // BPF_PSEUDO_MAP_FD 39 | PseudoMapValue = R2 // BPF_PSEUDO_MAP_VALUE 40 | PseudoCall = R1 // BPF_PSEUDO_CALL 41 | PseudoFunc = R4 // BPF_PSEUDO_FUNC 42 | ) 43 | 44 | func (r Register) String() string { 45 | v := uint8(r) 46 | if v == 10 { 47 | return "rfp" 48 | } 49 | return fmt.Sprintf("r%d", v) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/attachtype_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type AttachType -trimprefix Attach"; DO NOT EDIT. 2 | 3 | package ebpf 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[AttachNone-0] 12 | _ = x[AttachCGroupInetIngress-0] 13 | _ = x[AttachCGroupInetEgress-1] 14 | _ = x[AttachCGroupInetSockCreate-2] 15 | _ = x[AttachCGroupSockOps-3] 16 | _ = x[AttachSkSKBStreamParser-4] 17 | _ = x[AttachSkSKBStreamVerdict-5] 18 | _ = x[AttachCGroupDevice-6] 19 | _ = x[AttachSkMsgVerdict-7] 20 | _ = x[AttachCGroupInet4Bind-8] 21 | _ = x[AttachCGroupInet6Bind-9] 22 | _ = x[AttachCGroupInet4Connect-10] 23 | _ = x[AttachCGroupInet6Connect-11] 24 | _ = x[AttachCGroupInet4PostBind-12] 25 | _ = x[AttachCGroupInet6PostBind-13] 26 | _ = x[AttachCGroupUDP4Sendmsg-14] 27 | _ = x[AttachCGroupUDP6Sendmsg-15] 28 | _ = x[AttachLircMode2-16] 29 | _ = x[AttachFlowDissector-17] 30 | _ = x[AttachCGroupSysctl-18] 31 | _ = x[AttachCGroupUDP4Recvmsg-19] 32 | _ = x[AttachCGroupUDP6Recvmsg-20] 33 | _ = x[AttachCGroupGetsockopt-21] 34 | _ = x[AttachCGroupSetsockopt-22] 35 | _ = x[AttachTraceRawTp-23] 36 | _ = x[AttachTraceFEntry-24] 37 | _ = x[AttachTraceFExit-25] 38 | _ = x[AttachModifyReturn-26] 39 | _ = x[AttachLSMMac-27] 40 | _ = x[AttachTraceIter-28] 41 | _ = x[AttachCgroupInet4GetPeername-29] 42 | _ = x[AttachCgroupInet6GetPeername-30] 43 | _ = x[AttachCgroupInet4GetSockname-31] 44 | _ = x[AttachCgroupInet6GetSockname-32] 45 | _ = x[AttachXDPDevMap-33] 46 | _ = x[AttachCgroupInetSockRelease-34] 47 | _ = x[AttachXDPCPUMap-35] 48 | _ = x[AttachSkLookup-36] 49 | _ = x[AttachXDP-37] 50 | _ = x[AttachSkSKBVerdict-38] 51 | _ = x[AttachSkReuseportSelect-39] 52 | _ = x[AttachSkReuseportSelectOrMigrate-40] 53 | _ = x[AttachPerfEvent-41] 54 | } 55 | 56 | const _AttachType_name = "NoneCGroupInetEgressCGroupInetSockCreateCGroupSockOpsSkSKBStreamParserSkSKBStreamVerdictCGroupDeviceSkMsgVerdictCGroupInet4BindCGroupInet6BindCGroupInet4ConnectCGroupInet6ConnectCGroupInet4PostBindCGroupInet6PostBindCGroupUDP4SendmsgCGroupUDP6SendmsgLircMode2FlowDissectorCGroupSysctlCGroupUDP4RecvmsgCGroupUDP6RecvmsgCGroupGetsockoptCGroupSetsockoptTraceRawTpTraceFEntryTraceFExitModifyReturnLSMMacTraceIterCgroupInet4GetPeernameCgroupInet6GetPeernameCgroupInet4GetSocknameCgroupInet6GetSocknameXDPDevMapCgroupInetSockReleaseXDPCPUMapSkLookupXDPSkSKBVerdictSkReuseportSelectSkReuseportSelectOrMigratePerfEvent" 57 | 58 | var _AttachType_index = [...]uint16{0, 4, 20, 40, 53, 70, 88, 100, 112, 127, 142, 160, 178, 197, 216, 233, 250, 259, 272, 284, 301, 318, 334, 350, 360, 371, 381, 393, 399, 408, 430, 452, 474, 496, 505, 526, 535, 543, 546, 558, 575, 601, 610} 59 | 60 | func (i AttachType) String() string { 61 | if i >= AttachType(len(_AttachType_index)-1) { 62 | return "AttachType(" + strconv.FormatInt(int64(i), 10) + ")" 63 | } 64 | return _AttachType_name[_AttachType_index[i]:_AttachType_index[i+1]] 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/doc.go: -------------------------------------------------------------------------------- 1 | // Package ebpf is a toolkit for working with eBPF programs. 2 | // 3 | // eBPF programs are small snippets of code which are executed directly 4 | // in a VM in the Linux kernel, which makes them very fast and flexible. 5 | // Many Linux subsystems now accept eBPF programs. This makes it possible 6 | // to implement highly application specific logic inside the kernel, 7 | // without having to modify the actual kernel itself. 8 | // 9 | // This package is designed for long-running processes which 10 | // want to use eBPF to implement part of their application logic. It has no 11 | // run-time dependencies outside of the library and the Linux kernel itself. 12 | // eBPF code should be compiled ahead of time using clang, and shipped with 13 | // your application as any other resource. 14 | // 15 | // Use the link subpackage to attach a loaded program to a hook in the kernel. 16 | package ebpf 17 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/features/doc.go: -------------------------------------------------------------------------------- 1 | // Package features allows probing for BPF features available to the calling process. 2 | package features 3 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/features/version.go: -------------------------------------------------------------------------------- 1 | package features 2 | 3 | import "github.com/cilium/ebpf/internal" 4 | 5 | // LinuxVersionCode returns the version of the currently running kernel 6 | // as defined in the LINUX_VERSION_CODE compile-time macro. It is represented 7 | // in the format described by the KERNEL_VERSION macro from linux/version.h. 8 | // 9 | // Do not use the version to make assumptions about the presence of certain 10 | // kernel features, always prefer feature probes in this package. Some 11 | // distributions backport or disable eBPF features. 12 | func LinuxVersionCode() (uint32, error) { 13 | v, err := internal.KernelVersion() 14 | if err != nil { 15 | return 0, err 16 | } 17 | return v.Kernel(), nil 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/align.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | // Align returns 'n' updated to 'alignment' boundary. 4 | func Align(n, alignment int) int { 5 | return (int(n) + alignment - 1) / alignment * alignment 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/btf/btf_types_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -linecomment -output=btf_types_string.go -type=FuncLinkage,VarLinkage"; DO NOT EDIT. 2 | 3 | package btf 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[StaticFunc-0] 12 | _ = x[GlobalFunc-1] 13 | _ = x[ExternFunc-2] 14 | } 15 | 16 | const _FuncLinkage_name = "staticglobalextern" 17 | 18 | var _FuncLinkage_index = [...]uint8{0, 6, 12, 18} 19 | 20 | func (i FuncLinkage) String() string { 21 | if i < 0 || i >= FuncLinkage(len(_FuncLinkage_index)-1) { 22 | return "FuncLinkage(" + strconv.FormatInt(int64(i), 10) + ")" 23 | } 24 | return _FuncLinkage_name[_FuncLinkage_index[i]:_FuncLinkage_index[i+1]] 25 | } 26 | func _() { 27 | // An "invalid array index" compiler error signifies that the constant values have changed. 28 | // Re-run the stringer command to generate them again. 29 | var x [1]struct{} 30 | _ = x[StaticVar-0] 31 | _ = x[GlobalVar-1] 32 | _ = x[ExternVar-2] 33 | } 34 | 35 | const _VarLinkage_name = "staticglobalextern" 36 | 37 | var _VarLinkage_index = [...]uint8{0, 6, 12, 18} 38 | 39 | func (i VarLinkage) String() string { 40 | if i < 0 || i >= VarLinkage(len(_VarLinkage_index)-1) { 41 | return "VarLinkage(" + strconv.FormatInt(int64(i), 10) + ")" 42 | } 43 | return _VarLinkage_name[_VarLinkage_index[i]:_VarLinkage_index[i+1]] 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/btf/doc.go: -------------------------------------------------------------------------------- 1 | // Package btf handles data encoded according to the BPF Type Format. 2 | // 3 | // The canonical documentation lives in the Linux kernel repository and is 4 | // available at https://www.kernel.org/doc/html/latest/bpf/btf.html 5 | // 6 | // The API is very much unstable. You should only use this via the main 7 | // ebpf library. 8 | package btf 9 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/btf/info.go: -------------------------------------------------------------------------------- 1 | package btf 2 | 3 | import ( 4 | "bytes" 5 | 6 | "github.com/cilium/ebpf/internal" 7 | "github.com/cilium/ebpf/internal/sys" 8 | "github.com/cilium/ebpf/internal/unix" 9 | ) 10 | 11 | // info describes a BTF object. 12 | type info struct { 13 | BTF *Spec 14 | ID ID 15 | // Name is an identifying name for the BTF, currently only used by the 16 | // kernel. 17 | Name string 18 | // KernelBTF is true if the BTf originated with the kernel and not 19 | // userspace. 20 | KernelBTF bool 21 | } 22 | 23 | func newInfoFromFd(fd *sys.FD) (*info, error) { 24 | // We invoke the syscall once with a empty BTF and name buffers to get size 25 | // information to allocate buffers. Then we invoke it a second time with 26 | // buffers to receive the data. 27 | var btfInfo sys.BtfInfo 28 | if err := sys.ObjInfo(fd, &btfInfo); err != nil { 29 | return nil, err 30 | } 31 | 32 | btfBuffer := make([]byte, btfInfo.BtfSize) 33 | nameBuffer := make([]byte, btfInfo.NameLen) 34 | btfInfo.Btf, btfInfo.BtfSize = sys.NewSlicePointerLen(btfBuffer) 35 | btfInfo.Name, btfInfo.NameLen = sys.NewSlicePointerLen(nameBuffer) 36 | if err := sys.ObjInfo(fd, &btfInfo); err != nil { 37 | return nil, err 38 | } 39 | 40 | spec, err := loadRawSpec(bytes.NewReader(btfBuffer), internal.NativeEndian, nil, nil) 41 | if err != nil { 42 | return nil, err 43 | } 44 | 45 | return &info{ 46 | BTF: spec, 47 | ID: ID(btfInfo.Id), 48 | Name: unix.ByteSliceToString(nameBuffer), 49 | KernelBTF: btfInfo.KernelBtf != 0, 50 | }, nil 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/btf/strings.go: -------------------------------------------------------------------------------- 1 | package btf 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "fmt" 7 | "io" 8 | ) 9 | 10 | type stringTable []byte 11 | 12 | func readStringTable(r io.Reader) (stringTable, error) { 13 | contents, err := io.ReadAll(r) 14 | if err != nil { 15 | return nil, fmt.Errorf("can't read string table: %v", err) 16 | } 17 | 18 | if len(contents) < 1 { 19 | return nil, errors.New("string table is empty") 20 | } 21 | 22 | if contents[0] != '\x00' { 23 | return nil, errors.New("first item in string table is non-empty") 24 | } 25 | 26 | if contents[len(contents)-1] != '\x00' { 27 | return nil, errors.New("string table isn't null terminated") 28 | } 29 | 30 | return stringTable(contents), nil 31 | } 32 | 33 | func (st stringTable) Lookup(offset uint32) (string, error) { 34 | if int64(offset) > int64(^uint(0)>>1) { 35 | return "", fmt.Errorf("offset %d overflows int", offset) 36 | } 37 | 38 | pos := int(offset) 39 | if pos >= len(st) { 40 | return "", fmt.Errorf("offset %d is out of bounds", offset) 41 | } 42 | 43 | if pos > 0 && st[pos-1] != '\x00' { 44 | return "", fmt.Errorf("offset %d isn't start of a string", offset) 45 | } 46 | 47 | str := st[pos:] 48 | end := bytes.IndexByte(str, '\x00') 49 | if end == -1 { 50 | return "", fmt.Errorf("offset %d isn't null terminated", offset) 51 | } 52 | 53 | return string(str[:end]), nil 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/cpu.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strings" 7 | "sync" 8 | ) 9 | 10 | var sysCPU struct { 11 | once sync.Once 12 | err error 13 | num int 14 | } 15 | 16 | // PossibleCPUs returns the max number of CPUs a system may possibly have 17 | // Logical CPU numbers must be of the form 0-n 18 | func PossibleCPUs() (int, error) { 19 | sysCPU.once.Do(func() { 20 | sysCPU.num, sysCPU.err = parseCPUsFromFile("/sys/devices/system/cpu/possible") 21 | }) 22 | 23 | return sysCPU.num, sysCPU.err 24 | } 25 | 26 | func parseCPUsFromFile(path string) (int, error) { 27 | spec, err := os.ReadFile(path) 28 | if err != nil { 29 | return 0, err 30 | } 31 | 32 | n, err := parseCPUs(string(spec)) 33 | if err != nil { 34 | return 0, fmt.Errorf("can't parse %s: %v", path, err) 35 | } 36 | 37 | return n, nil 38 | } 39 | 40 | // parseCPUs parses the number of cpus from a string produced 41 | // by bitmap_list_string() in the Linux kernel. 42 | // Multiple ranges are rejected, since they can't be unified 43 | // into a single number. 44 | // This is the format of /sys/devices/system/cpu/possible, it 45 | // is not suitable for /sys/devices/system/cpu/online, etc. 46 | func parseCPUs(spec string) (int, error) { 47 | if strings.Trim(spec, "\n") == "0" { 48 | return 1, nil 49 | } 50 | 51 | var low, high int 52 | n, err := fmt.Sscanf(spec, "%d-%d\n", &low, &high) 53 | if n != 2 || err != nil { 54 | return 0, fmt.Errorf("invalid format: %s", spec) 55 | } 56 | if low != 0 { 57 | return 0, fmt.Errorf("CPU spec doesn't start at zero: %s", spec) 58 | } 59 | 60 | // cpus is 0 indexed 61 | return high + 1, nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/elf.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "debug/elf" 5 | "fmt" 6 | "io" 7 | ) 8 | 9 | type SafeELFFile struct { 10 | *elf.File 11 | } 12 | 13 | // NewSafeELFFile reads an ELF safely. 14 | // 15 | // Any panic during parsing is turned into an error. This is necessary since 16 | // there are a bunch of unfixed bugs in debug/elf. 17 | // 18 | // https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+debug%2Felf+in%3Atitle 19 | func NewSafeELFFile(r io.ReaderAt) (safe *SafeELFFile, err error) { 20 | defer func() { 21 | r := recover() 22 | if r == nil { 23 | return 24 | } 25 | 26 | safe = nil 27 | err = fmt.Errorf("reading ELF file panicked: %s", r) 28 | }() 29 | 30 | file, err := elf.NewFile(r) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &SafeELFFile{file}, nil 36 | } 37 | 38 | // Symbols is the safe version of elf.File.Symbols. 39 | func (se *SafeELFFile) Symbols() (syms []elf.Symbol, err error) { 40 | defer func() { 41 | r := recover() 42 | if r == nil { 43 | return 44 | } 45 | 46 | syms = nil 47 | err = fmt.Errorf("reading ELF symbols panicked: %s", r) 48 | }() 49 | 50 | syms, err = se.File.Symbols() 51 | return 52 | } 53 | 54 | // DynamicSymbols is the safe version of elf.File.DynamicSymbols. 55 | func (se *SafeELFFile) DynamicSymbols() (syms []elf.Symbol, err error) { 56 | defer func() { 57 | r := recover() 58 | if r == nil { 59 | return 60 | } 61 | 62 | syms = nil 63 | err = fmt.Errorf("reading ELF dynamic symbols panicked: %s", r) 64 | }() 65 | 66 | syms, err = se.File.DynamicSymbols() 67 | return 68 | } 69 | 70 | // SectionsByType returns all sections in the file with the specified section type. 71 | func (se *SafeELFFile) SectionsByType(typ elf.SectionType) []*elf.Section { 72 | sections := make([]*elf.Section, 0, 1) 73 | for _, section := range se.Sections { 74 | if section.Type == typ { 75 | sections = append(sections, section) 76 | } 77 | } 78 | return sections 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/endian.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "encoding/binary" 5 | "unsafe" 6 | ) 7 | 8 | // NativeEndian is set to either binary.BigEndian or binary.LittleEndian, 9 | // depending on the host's endianness. 10 | var NativeEndian binary.ByteOrder 11 | 12 | // Clang is set to either "el" or "eb" depending on the host's endianness. 13 | var ClangEndian string 14 | 15 | func init() { 16 | if isBigEndian() { 17 | NativeEndian = binary.BigEndian 18 | ClangEndian = "eb" 19 | } else { 20 | NativeEndian = binary.LittleEndian 21 | ClangEndian = "el" 22 | } 23 | } 24 | 25 | func isBigEndian() (ret bool) { 26 | i := int(0x1) 27 | bs := (*[int(unsafe.Sizeof(i))]byte)(unsafe.Pointer(&i)) 28 | return bs[0] == 0 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/errors.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strings" 7 | 8 | "github.com/cilium/ebpf/internal/unix" 9 | ) 10 | 11 | // ErrorWithLog returns an error that includes logs from the 12 | // kernel verifier. 13 | // 14 | // logErr should be the error returned by the syscall that generated 15 | // the log. It is used to check for truncation of the output. 16 | func ErrorWithLog(err error, log []byte, logErr error) error { 17 | logStr := strings.Trim(unix.ByteSliceToString(log), "\t\r\n ") 18 | if errors.Is(logErr, unix.ENOSPC) { 19 | logStr += " (truncated...)" 20 | } 21 | 22 | return &VerifierError{err, logStr} 23 | } 24 | 25 | // VerifierError includes information from the eBPF verifier. 26 | type VerifierError struct { 27 | cause error 28 | log string 29 | } 30 | 31 | func (le *VerifierError) Unwrap() error { 32 | return le.cause 33 | } 34 | 35 | func (le *VerifierError) Error() string { 36 | if le.log == "" { 37 | return le.cause.Error() 38 | } 39 | 40 | return fmt.Sprintf("%s: %s", le.cause, le.log) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/feature.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "sync" 7 | ) 8 | 9 | // ErrNotSupported indicates that a feature is not supported by the current kernel. 10 | var ErrNotSupported = errors.New("not supported") 11 | 12 | // UnsupportedFeatureError is returned by FeatureTest() functions. 13 | type UnsupportedFeatureError struct { 14 | // The minimum Linux mainline version required for this feature. 15 | // Used for the error string, and for sanity checking during testing. 16 | MinimumVersion Version 17 | 18 | // The name of the feature that isn't supported. 19 | Name string 20 | } 21 | 22 | func (ufe *UnsupportedFeatureError) Error() string { 23 | if ufe.MinimumVersion.Unspecified() { 24 | return fmt.Sprintf("%s not supported", ufe.Name) 25 | } 26 | return fmt.Sprintf("%s not supported (requires >= %s)", ufe.Name, ufe.MinimumVersion) 27 | } 28 | 29 | // Is indicates that UnsupportedFeatureError is ErrNotSupported. 30 | func (ufe *UnsupportedFeatureError) Is(target error) bool { 31 | return target == ErrNotSupported 32 | } 33 | 34 | type featureTest struct { 35 | sync.RWMutex 36 | successful bool 37 | result error 38 | } 39 | 40 | // FeatureTestFn is used to determine whether the kernel supports 41 | // a certain feature. 42 | // 43 | // The return values have the following semantics: 44 | // 45 | // err == ErrNotSupported: the feature is not available 46 | // err == nil: the feature is available 47 | // err != nil: the test couldn't be executed 48 | type FeatureTestFn func() error 49 | 50 | // FeatureTest wraps a function so that it is run at most once. 51 | // 52 | // name should identify the tested feature, while version must be in the 53 | // form Major.Minor[.Patch]. 54 | // 55 | // Returns an error wrapping ErrNotSupported if the feature is not supported. 56 | func FeatureTest(name, version string, fn FeatureTestFn) func() error { 57 | v, err := NewVersion(version) 58 | if err != nil { 59 | return func() error { return err } 60 | } 61 | 62 | ft := new(featureTest) 63 | return func() error { 64 | ft.RLock() 65 | if ft.successful { 66 | defer ft.RUnlock() 67 | return ft.result 68 | } 69 | ft.RUnlock() 70 | ft.Lock() 71 | defer ft.Unlock() 72 | // check one more time on the off 73 | // chance that two go routines 74 | // were able to call into the write 75 | // lock 76 | if ft.successful { 77 | return ft.result 78 | } 79 | err := fn() 80 | switch { 81 | case errors.Is(err, ErrNotSupported): 82 | ft.result = &UnsupportedFeatureError{ 83 | MinimumVersion: v, 84 | Name: name, 85 | } 86 | fallthrough 87 | 88 | case err == nil: 89 | ft.successful = true 90 | 91 | default: 92 | // We couldn't execute the feature test to a point 93 | // where it could make a determination. 94 | // Don't cache the result, just return it. 95 | return fmt.Errorf("detect support for %s: %w", name, err) 96 | } 97 | 98 | return ft.result 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/io.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "bufio" 5 | "compress/gzip" 6 | "errors" 7 | "io" 8 | "os" 9 | ) 10 | 11 | // NewBufferedSectionReader wraps an io.ReaderAt in an appropriately-sized 12 | // buffered reader. It is a convenience function for reading subsections of 13 | // ELF sections while minimizing the amount of read() syscalls made. 14 | // 15 | // Syscall overhead is non-negligible in continuous integration context 16 | // where ELFs might be accessed over virtual filesystems with poor random 17 | // access performance. Buffering reads makes sense because (sub)sections 18 | // end up being read completely anyway. 19 | // 20 | // Use instead of the r.Seek() + io.LimitReader() pattern. 21 | func NewBufferedSectionReader(ra io.ReaderAt, off, n int64) io.Reader { 22 | // Clamp the size of the buffer to one page to avoid slurping large parts 23 | // of a file into memory. bufio.NewReader uses a hardcoded default buffer 24 | // of 4096. Allow arches with larger pages to allocate more, but don't 25 | // allocate a fixed 4k buffer if we only need to read a small segment. 26 | buf := n 27 | if ps := int64(os.Getpagesize()); n > ps { 28 | buf = ps 29 | } 30 | 31 | return bufio.NewReaderSize(io.NewSectionReader(ra, off, n), int(buf)) 32 | } 33 | 34 | // DiscardZeroes makes sure that all written bytes are zero 35 | // before discarding them. 36 | type DiscardZeroes struct{} 37 | 38 | func (DiscardZeroes) Write(p []byte) (int, error) { 39 | for _, b := range p { 40 | if b != 0 { 41 | return 0, errors.New("encountered non-zero byte") 42 | } 43 | } 44 | return len(p), nil 45 | } 46 | 47 | // ReadAllCompressed decompresses a gzipped file into memory. 48 | func ReadAllCompressed(file string) ([]byte, error) { 49 | fh, err := os.Open(file) 50 | if err != nil { 51 | return nil, err 52 | } 53 | defer fh.Close() 54 | 55 | gz, err := gzip.NewReader(fh) 56 | if err != nil { 57 | return nil, err 58 | } 59 | defer gz.Close() 60 | 61 | return io.ReadAll(gz) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/output.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "go/format" 7 | "go/scanner" 8 | "io" 9 | "strings" 10 | "unicode" 11 | ) 12 | 13 | // Identifier turns a C style type or field name into an exportable Go equivalent. 14 | func Identifier(str string) string { 15 | prev := rune(-1) 16 | return strings.Map(func(r rune) rune { 17 | // See https://golang.org/ref/spec#Identifiers 18 | switch { 19 | case unicode.IsLetter(r): 20 | if prev == -1 { 21 | r = unicode.ToUpper(r) 22 | } 23 | 24 | case r == '_': 25 | switch { 26 | // The previous rune was deleted, or we are at the 27 | // beginning of the string. 28 | case prev == -1: 29 | fallthrough 30 | 31 | // The previous rune is a lower case letter or a digit. 32 | case unicode.IsDigit(prev) || (unicode.IsLetter(prev) && unicode.IsLower(prev)): 33 | // delete the current rune, and force the 34 | // next character to be uppercased. 35 | r = -1 36 | } 37 | 38 | case unicode.IsDigit(r): 39 | 40 | default: 41 | // Delete the current rune. prev is unchanged. 42 | return -1 43 | } 44 | 45 | prev = r 46 | return r 47 | }, str) 48 | } 49 | 50 | // WriteFormatted outputs a formatted src into out. 51 | // 52 | // If formatting fails it returns an informative error message. 53 | func WriteFormatted(src []byte, out io.Writer) error { 54 | formatted, err := format.Source(src) 55 | if err == nil { 56 | _, err = out.Write(formatted) 57 | return err 58 | } 59 | 60 | var el scanner.ErrorList 61 | if !errors.As(err, &el) { 62 | return err 63 | } 64 | 65 | var nel scanner.ErrorList 66 | for _, err := range el { 67 | if !err.Pos.IsValid() { 68 | nel = append(nel, err) 69 | continue 70 | } 71 | 72 | buf := src[err.Pos.Offset:] 73 | nl := bytes.IndexRune(buf, '\n') 74 | if nl == -1 { 75 | nel = append(nel, err) 76 | continue 77 | } 78 | 79 | err.Msg += ": " + string(buf[:nl]) 80 | nel = append(nel, err) 81 | } 82 | 83 | return nel 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/pinning.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | "runtime" 9 | 10 | "github.com/cilium/ebpf/internal/sys" 11 | "github.com/cilium/ebpf/internal/unix" 12 | ) 13 | 14 | func Pin(currentPath, newPath string, fd *sys.FD) error { 15 | const bpfFSType = 0xcafe4a11 16 | 17 | if newPath == "" { 18 | return errors.New("given pinning path cannot be empty") 19 | } 20 | if currentPath == newPath { 21 | return nil 22 | } 23 | 24 | var statfs unix.Statfs_t 25 | if err := unix.Statfs(filepath.Dir(newPath), &statfs); err != nil { 26 | return err 27 | } else if uint64(statfs.Type) != bpfFSType { 28 | return fmt.Errorf("%s is not on a bpf filesystem", newPath) 29 | } 30 | 31 | defer runtime.KeepAlive(fd) 32 | 33 | if currentPath == "" { 34 | return sys.ObjPin(&sys.ObjPinAttr{ 35 | Pathname: sys.NewStringPointer(newPath), 36 | BpfFd: fd.Uint(), 37 | }) 38 | } 39 | 40 | // Renameat2 is used instead of os.Rename to disallow the new path replacing 41 | // an existing path. 42 | err := unix.Renameat2(unix.AT_FDCWD, currentPath, unix.AT_FDCWD, newPath, unix.RENAME_NOREPLACE) 43 | if err == nil { 44 | // Object is now moved to the new pinning path. 45 | return nil 46 | } 47 | if !os.IsNotExist(err) { 48 | return fmt.Errorf("unable to move pinned object to new path %v: %w", newPath, err) 49 | } 50 | // Internal state not in sync with the file system so let's fix it. 51 | return sys.ObjPin(&sys.ObjPinAttr{ 52 | Pathname: sys.NewStringPointer(newPath), 53 | BpfFd: fd.Uint(), 54 | }) 55 | } 56 | 57 | func Unpin(pinnedPath string) error { 58 | if pinnedPath == "" { 59 | return nil 60 | } 61 | err := os.Remove(pinnedPath) 62 | if err == nil || os.IsNotExist(err) { 63 | return nil 64 | } 65 | return err 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/doc.go: -------------------------------------------------------------------------------- 1 | // Package sys contains bindings for the BPF syscall. 2 | package sys 3 | 4 | //go:generate go run github.com/cilium/ebpf/internal/cmd/gentypes ../btf/testdata/vmlinux-btf.gz 5 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/fd.go: -------------------------------------------------------------------------------- 1 | package sys 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | "os" 7 | "runtime" 8 | "strconv" 9 | 10 | "github.com/cilium/ebpf/internal/unix" 11 | ) 12 | 13 | var ErrClosedFd = unix.EBADF 14 | 15 | type FD struct { 16 | raw int 17 | } 18 | 19 | func newFD(value int) *FD { 20 | fd := &FD{value} 21 | runtime.SetFinalizer(fd, (*FD).Close) 22 | return fd 23 | } 24 | 25 | // NewFD wraps a raw fd with a finalizer. 26 | // 27 | // You must not use the raw fd after calling this function, since the underlying 28 | // file descriptor number may change. This is because the BPF UAPI assumes that 29 | // zero is not a valid fd value. 30 | func NewFD(value int) (*FD, error) { 31 | if value < 0 { 32 | return nil, fmt.Errorf("invalid fd %d", value) 33 | } 34 | 35 | fd := newFD(value) 36 | if value != 0 { 37 | return fd, nil 38 | } 39 | 40 | dup, err := fd.Dup() 41 | _ = fd.Close() 42 | return dup, err 43 | } 44 | 45 | func (fd *FD) String() string { 46 | return strconv.FormatInt(int64(fd.raw), 10) 47 | } 48 | 49 | func (fd *FD) Int() int { 50 | return fd.raw 51 | } 52 | 53 | func (fd *FD) Uint() uint32 { 54 | if fd.raw < 0 || int64(fd.raw) > math.MaxUint32 { 55 | // Best effort: this is the number most likely to be an invalid file 56 | // descriptor. It is equal to -1 (on two's complement arches). 57 | return math.MaxUint32 58 | } 59 | return uint32(fd.raw) 60 | } 61 | 62 | func (fd *FD) Close() error { 63 | if fd.raw < 0 { 64 | return nil 65 | } 66 | 67 | value := int(fd.raw) 68 | fd.raw = -1 69 | 70 | fd.Forget() 71 | return unix.Close(value) 72 | } 73 | 74 | func (fd *FD) Forget() { 75 | runtime.SetFinalizer(fd, nil) 76 | } 77 | 78 | func (fd *FD) Dup() (*FD, error) { 79 | if fd.raw < 0 { 80 | return nil, ErrClosedFd 81 | } 82 | 83 | // Always require the fd to be larger than zero: the BPF API treats the value 84 | // as "no argument provided". 85 | dup, err := unix.FcntlInt(uintptr(fd.raw), unix.F_DUPFD_CLOEXEC, 1) 86 | if err != nil { 87 | return nil, fmt.Errorf("can't dup fd: %v", err) 88 | } 89 | 90 | return newFD(dup), nil 91 | } 92 | 93 | func (fd *FD) File(name string) *os.File { 94 | fd.Forget() 95 | return os.NewFile(uintptr(fd.raw), name) 96 | } 97 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/ptr.go: -------------------------------------------------------------------------------- 1 | package sys 2 | 3 | import ( 4 | "unsafe" 5 | 6 | "github.com/cilium/ebpf/internal/unix" 7 | ) 8 | 9 | // NewPointer creates a 64-bit pointer from an unsafe Pointer. 10 | func NewPointer(ptr unsafe.Pointer) Pointer { 11 | return Pointer{ptr: ptr} 12 | } 13 | 14 | // NewSlicePointer creates a 64-bit pointer from a byte slice. 15 | func NewSlicePointer(buf []byte) Pointer { 16 | if len(buf) == 0 { 17 | return Pointer{} 18 | } 19 | 20 | return Pointer{ptr: unsafe.Pointer(&buf[0])} 21 | } 22 | 23 | // NewSlicePointer creates a 64-bit pointer from a byte slice. 24 | // 25 | // Useful to assign both the pointer and the length in one go. 26 | func NewSlicePointerLen(buf []byte) (Pointer, uint32) { 27 | return NewSlicePointer(buf), uint32(len(buf)) 28 | } 29 | 30 | // NewStringPointer creates a 64-bit pointer from a string. 31 | func NewStringPointer(str string) Pointer { 32 | p, err := unix.BytePtrFromString(str) 33 | if err != nil { 34 | return Pointer{} 35 | } 36 | 37 | return Pointer{ptr: unsafe.Pointer(p)} 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/ptr_32_be.go: -------------------------------------------------------------------------------- 1 | //go:build armbe || mips || mips64p32 2 | // +build armbe mips mips64p32 3 | 4 | package sys 5 | 6 | import ( 7 | "unsafe" 8 | ) 9 | 10 | // Pointer wraps an unsafe.Pointer to be 64bit to 11 | // conform to the syscall specification. 12 | type Pointer struct { 13 | pad uint32 14 | ptr unsafe.Pointer 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/ptr_32_le.go: -------------------------------------------------------------------------------- 1 | //go:build 386 || amd64p32 || arm || mipsle || mips64p32le 2 | // +build 386 amd64p32 arm mipsle mips64p32le 3 | 4 | package sys 5 | 6 | import ( 7 | "unsafe" 8 | ) 9 | 10 | // Pointer wraps an unsafe.Pointer to be 64bit to 11 | // conform to the syscall specification. 12 | type Pointer struct { 13 | ptr unsafe.Pointer 14 | pad uint32 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/ptr_64.go: -------------------------------------------------------------------------------- 1 | //go:build !386 && !amd64p32 && !arm && !mipsle && !mips64p32le && !armbe && !mips && !mips64p32 2 | // +build !386,!amd64p32,!arm,!mipsle,!mips64p32le,!armbe,!mips,!mips64p32 3 | 4 | package sys 5 | 6 | import ( 7 | "unsafe" 8 | ) 9 | 10 | // Pointer wraps an unsafe.Pointer to be 64bit to 11 | // conform to the syscall specification. 12 | type Pointer struct { 13 | ptr unsafe.Pointer 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/internal/sys/syscall.go: -------------------------------------------------------------------------------- 1 | package sys 2 | 3 | import ( 4 | "runtime" 5 | "syscall" 6 | "unsafe" 7 | 8 | "github.com/cilium/ebpf/internal/unix" 9 | ) 10 | 11 | // BPF wraps SYS_BPF. 12 | // 13 | // Any pointers contained in attr must use the Pointer type from this package. 14 | func BPF(cmd Cmd, attr unsafe.Pointer, size uintptr) (uintptr, error) { 15 | for { 16 | r1, _, errNo := unix.Syscall(unix.SYS_BPF, uintptr(cmd), uintptr(attr), size) 17 | runtime.KeepAlive(attr) 18 | 19 | // As of ~4.20 the verifier can be interrupted by a signal, 20 | // and returns EAGAIN in that case. 21 | if errNo == unix.EAGAIN && cmd == BPF_PROG_LOAD { 22 | continue 23 | } 24 | 25 | var err error 26 | if errNo != 0 { 27 | err = wrappedErrno{errNo} 28 | } 29 | 30 | return r1, err 31 | } 32 | } 33 | 34 | // Info is implemented by all structs that can be passed to the ObjInfo syscall. 35 | // 36 | // MapInfo 37 | // ProgInfo 38 | // LinkInfo 39 | // BtfInfo 40 | type Info interface { 41 | info() (unsafe.Pointer, uint32) 42 | } 43 | 44 | var _ Info = (*MapInfo)(nil) 45 | 46 | func (i *MapInfo) info() (unsafe.Pointer, uint32) { 47 | return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i)) 48 | } 49 | 50 | var _ Info = (*ProgInfo)(nil) 51 | 52 | func (i *ProgInfo) info() (unsafe.Pointer, uint32) { 53 | return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i)) 54 | } 55 | 56 | var _ Info = (*LinkInfo)(nil) 57 | 58 | func (i *LinkInfo) info() (unsafe.Pointer, uint32) { 59 | return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i)) 60 | } 61 | 62 | var _ Info = (*BtfInfo)(nil) 63 | 64 | func (i *BtfInfo) info() (unsafe.Pointer, uint32) { 65 | return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i)) 66 | } 67 | 68 | // ObjInfo retrieves information about a BPF Fd. 69 | // 70 | // info may be one of MapInfo, ProgInfo, LinkInfo and BtfInfo. 71 | func ObjInfo(fd *FD, info Info) error { 72 | ptr, len := info.info() 73 | err := ObjGetInfoByFd(&ObjGetInfoByFdAttr{ 74 | BpfFd: fd.Uint(), 75 | InfoLen: len, 76 | Info: NewPointer(ptr), 77 | }) 78 | runtime.KeepAlive(fd) 79 | return err 80 | } 81 | 82 | // BPFObjName is a null-terminated string made up of 83 | // 'A-Za-z0-9_' characters. 84 | type ObjName [unix.BPF_OBJ_NAME_LEN]byte 85 | 86 | // NewObjName truncates the result if it is too long. 87 | func NewObjName(name string) ObjName { 88 | var result ObjName 89 | copy(result[:unix.BPF_OBJ_NAME_LEN-1], name) 90 | return result 91 | } 92 | 93 | // LinkID uniquely identifies a bpf_link. 94 | type LinkID uint32 95 | 96 | // wrappedErrno wraps syscall.Errno to prevent direct comparisons with 97 | // syscall.E* or unix.E* constants. 98 | // 99 | // You should never export an error of this type. 100 | type wrappedErrno struct { 101 | syscall.Errno 102 | } 103 | 104 | func (we wrappedErrno) Unwrap() error { 105 | return we.Errno 106 | } 107 | 108 | type syscallError struct { 109 | error 110 | errno syscall.Errno 111 | } 112 | 113 | func Error(err error, errno syscall.Errno) error { 114 | return &syscallError{err, errno} 115 | } 116 | 117 | func (se *syscallError) Is(target error) bool { 118 | return target == se.error 119 | } 120 | 121 | func (se *syscallError) Unwrap() error { 122 | return se.errno 123 | } 124 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/doc.go: -------------------------------------------------------------------------------- 1 | // Package link allows attaching eBPF programs to various kernel hooks. 2 | package link 3 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/iter.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "unsafe" 7 | 8 | "github.com/cilium/ebpf" 9 | "github.com/cilium/ebpf/internal/sys" 10 | ) 11 | 12 | type IterOptions struct { 13 | // Program must be of type Tracing with attach type 14 | // AttachTraceIter. The kind of iterator to attach to is 15 | // determined at load time via the AttachTo field. 16 | // 17 | // AttachTo requires the kernel to include BTF of itself, 18 | // and it to be compiled with a recent pahole (>= 1.16). 19 | Program *ebpf.Program 20 | 21 | // Map specifies the target map for bpf_map_elem and sockmap iterators. 22 | // It may be nil. 23 | Map *ebpf.Map 24 | } 25 | 26 | // AttachIter attaches a BPF seq_file iterator. 27 | func AttachIter(opts IterOptions) (*Iter, error) { 28 | if err := haveBPFLink(); err != nil { 29 | return nil, err 30 | } 31 | 32 | progFd := opts.Program.FD() 33 | if progFd < 0 { 34 | return nil, fmt.Errorf("invalid program: %s", sys.ErrClosedFd) 35 | } 36 | 37 | var info bpfIterLinkInfoMap 38 | if opts.Map != nil { 39 | mapFd := opts.Map.FD() 40 | if mapFd < 0 { 41 | return nil, fmt.Errorf("invalid map: %w", sys.ErrClosedFd) 42 | } 43 | info.map_fd = uint32(mapFd) 44 | } 45 | 46 | attr := sys.LinkCreateIterAttr{ 47 | ProgFd: uint32(progFd), 48 | AttachType: sys.AttachType(ebpf.AttachTraceIter), 49 | IterInfo: sys.NewPointer(unsafe.Pointer(&info)), 50 | IterInfoLen: uint32(unsafe.Sizeof(info)), 51 | } 52 | 53 | fd, err := sys.LinkCreateIter(&attr) 54 | if err != nil { 55 | return nil, fmt.Errorf("can't link iterator: %w", err) 56 | } 57 | 58 | return &Iter{RawLink{fd, ""}}, err 59 | } 60 | 61 | // LoadPinnedIter loads a pinned iterator from a bpffs. 62 | // 63 | // Deprecated: use LoadPinnedLink instead. 64 | func LoadPinnedIter(fileName string, opts *ebpf.LoadPinOptions) (*Iter, error) { 65 | link, err := LoadPinnedRawLink(fileName, IterType, opts) 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | return &Iter{*link}, err 71 | } 72 | 73 | // Iter represents an attached bpf_iter. 74 | type Iter struct { 75 | RawLink 76 | } 77 | 78 | // Open creates a new instance of the iterator. 79 | // 80 | // Reading from the returned reader triggers the BPF program. 81 | func (it *Iter) Open() (io.ReadCloser, error) { 82 | attr := &sys.IterCreateAttr{ 83 | LinkFd: it.fd.Uint(), 84 | } 85 | 86 | fd, err := sys.IterCreate(attr) 87 | if err != nil { 88 | return nil, fmt.Errorf("can't create iterator: %w", err) 89 | } 90 | 91 | return fd.File("bpf_iter"), nil 92 | } 93 | 94 | // union bpf_iter_link_info.map 95 | type bpfIterLinkInfoMap struct { 96 | map_fd uint32 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/netns.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/cilium/ebpf" 7 | ) 8 | 9 | // NetNsLink is a program attached to a network namespace. 10 | type NetNsLink struct { 11 | RawLink 12 | } 13 | 14 | // AttachNetNs attaches a program to a network namespace. 15 | func AttachNetNs(ns int, prog *ebpf.Program) (*NetNsLink, error) { 16 | var attach ebpf.AttachType 17 | switch t := prog.Type(); t { 18 | case ebpf.FlowDissector: 19 | attach = ebpf.AttachFlowDissector 20 | case ebpf.SkLookup: 21 | attach = ebpf.AttachSkLookup 22 | default: 23 | return nil, fmt.Errorf("can't attach %v to network namespace", t) 24 | } 25 | 26 | link, err := AttachRawLink(RawLinkOptions{ 27 | Target: ns, 28 | Program: prog, 29 | Attach: attach, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &NetNsLink{*link}, nil 36 | } 37 | 38 | // LoadPinnedNetNs loads a network namespace link from bpffs. 39 | // 40 | // Deprecated: use LoadPinnedLink instead. 41 | func LoadPinnedNetNs(fileName string, opts *ebpf.LoadPinOptions) (*NetNsLink, error) { 42 | link, err := LoadPinnedRawLink(fileName, NetNsType, opts) 43 | if err != nil { 44 | return nil, err 45 | } 46 | 47 | return &NetNsLink{*link}, nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/platform.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | ) 7 | 8 | func platformPrefix(symbol string) string { 9 | 10 | prefix := runtime.GOARCH 11 | 12 | // per https://github.com/golang/go/blob/master/src/go/build/syslist.go 13 | switch prefix { 14 | case "386": 15 | prefix = "ia32" 16 | case "amd64", "amd64p32": 17 | prefix = "x64" 18 | case "arm64", "arm64be": 19 | prefix = "arm64" 20 | default: 21 | return symbol 22 | } 23 | 24 | return fmt.Sprintf("__%s_%s", prefix, symbol) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/program.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/cilium/ebpf" 7 | "github.com/cilium/ebpf/internal/sys" 8 | ) 9 | 10 | type RawAttachProgramOptions struct { 11 | // File descriptor to attach to. This differs for each attach type. 12 | Target int 13 | // Program to attach. 14 | Program *ebpf.Program 15 | // Program to replace (cgroups). 16 | Replace *ebpf.Program 17 | // Attach must match the attach type of Program (and Replace). 18 | Attach ebpf.AttachType 19 | // Flags control the attach behaviour. This differs for each attach type. 20 | Flags uint32 21 | } 22 | 23 | // RawAttachProgram is a low level wrapper around BPF_PROG_ATTACH. 24 | // 25 | // You should use one of the higher level abstractions available in this 26 | // package if possible. 27 | func RawAttachProgram(opts RawAttachProgramOptions) error { 28 | if err := haveProgAttach(); err != nil { 29 | return err 30 | } 31 | 32 | var replaceFd uint32 33 | if opts.Replace != nil { 34 | replaceFd = uint32(opts.Replace.FD()) 35 | } 36 | 37 | attr := sys.ProgAttachAttr{ 38 | TargetFd: uint32(opts.Target), 39 | AttachBpfFd: uint32(opts.Program.FD()), 40 | ReplaceBpfFd: replaceFd, 41 | AttachType: uint32(opts.Attach), 42 | AttachFlags: uint32(opts.Flags), 43 | } 44 | 45 | if err := sys.ProgAttach(&attr); err != nil { 46 | return fmt.Errorf("can't attach program: %w", err) 47 | } 48 | return nil 49 | } 50 | 51 | type RawDetachProgramOptions struct { 52 | Target int 53 | Program *ebpf.Program 54 | Attach ebpf.AttachType 55 | } 56 | 57 | // RawDetachProgram is a low level wrapper around BPF_PROG_DETACH. 58 | // 59 | // You should use one of the higher level abstractions available in this 60 | // package if possible. 61 | func RawDetachProgram(opts RawDetachProgramOptions) error { 62 | if err := haveProgAttach(); err != nil { 63 | return err 64 | } 65 | 66 | attr := sys.ProgDetachAttr{ 67 | TargetFd: uint32(opts.Target), 68 | AttachBpfFd: uint32(opts.Program.FD()), 69 | AttachType: uint32(opts.Attach), 70 | } 71 | if err := sys.ProgDetach(&attr); err != nil { 72 | return fmt.Errorf("can't detach program: %w", err) 73 | } 74 | 75 | return nil 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/raw_tracepoint.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "github.com/cilium/ebpf" 8 | "github.com/cilium/ebpf/internal/sys" 9 | ) 10 | 11 | type RawTracepointOptions struct { 12 | // Tracepoint name. 13 | Name string 14 | // Program must be of type RawTracepoint* 15 | Program *ebpf.Program 16 | } 17 | 18 | // AttachRawTracepoint links a BPF program to a raw_tracepoint. 19 | // 20 | // Requires at least Linux 4.17. 21 | func AttachRawTracepoint(opts RawTracepointOptions) (Link, error) { 22 | if t := opts.Program.Type(); t != ebpf.RawTracepoint && t != ebpf.RawTracepointWritable { 23 | return nil, fmt.Errorf("invalid program type %s, expected RawTracepoint(Writable)", t) 24 | } 25 | if opts.Program.FD() < 0 { 26 | return nil, fmt.Errorf("invalid program: %w", sys.ErrClosedFd) 27 | } 28 | 29 | fd, err := sys.RawTracepointOpen(&sys.RawTracepointOpenAttr{ 30 | Name: sys.NewStringPointer(opts.Name), 31 | ProgFd: uint32(opts.Program.FD()), 32 | }) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | err = haveBPFLink() 38 | if errors.Is(err, ErrNotSupported) { 39 | // Prior to commit 70ed506c3bbc ("bpf: Introduce pinnable bpf_link abstraction") 40 | // raw_tracepoints are just a plain fd. 41 | return &simpleRawTracepoint{fd}, nil 42 | } 43 | 44 | if err != nil { 45 | return nil, err 46 | } 47 | 48 | return &rawTracepoint{RawLink{fd: fd}}, nil 49 | } 50 | 51 | type simpleRawTracepoint struct { 52 | fd *sys.FD 53 | } 54 | 55 | var _ Link = (*simpleRawTracepoint)(nil) 56 | 57 | func (frt *simpleRawTracepoint) isLink() {} 58 | 59 | func (frt *simpleRawTracepoint) Close() error { 60 | return frt.fd.Close() 61 | } 62 | 63 | func (frt *simpleRawTracepoint) Update(_ *ebpf.Program) error { 64 | return fmt.Errorf("update raw_tracepoint: %w", ErrNotSupported) 65 | } 66 | 67 | func (frt *simpleRawTracepoint) Pin(string) error { 68 | return fmt.Errorf("pin raw_tracepoint: %w", ErrNotSupported) 69 | } 70 | 71 | func (frt *simpleRawTracepoint) Unpin() error { 72 | return fmt.Errorf("unpin raw_tracepoint: %w", ErrNotSupported) 73 | } 74 | 75 | func (frt *simpleRawTracepoint) Info() (*Info, error) { 76 | return nil, fmt.Errorf("can't get raw_tracepoint info: %w", ErrNotSupported) 77 | } 78 | 79 | type rawTracepoint struct { 80 | RawLink 81 | } 82 | 83 | var _ Link = (*rawTracepoint)(nil) 84 | 85 | func (rt *rawTracepoint) Update(_ *ebpf.Program) error { 86 | return fmt.Errorf("update raw_tracepoint: %w", ErrNotSupported) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/socket_filter.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "syscall" 5 | 6 | "github.com/cilium/ebpf" 7 | "github.com/cilium/ebpf/internal/unix" 8 | ) 9 | 10 | // AttachSocketFilter attaches a SocketFilter BPF program to a socket. 11 | func AttachSocketFilter(conn syscall.Conn, program *ebpf.Program) error { 12 | rawConn, err := conn.SyscallConn() 13 | if err != nil { 14 | return err 15 | } 16 | var ssoErr error 17 | err = rawConn.Control(func(fd uintptr) { 18 | ssoErr = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_ATTACH_BPF, program.FD()) 19 | }) 20 | if ssoErr != nil { 21 | return ssoErr 22 | } 23 | return err 24 | } 25 | 26 | // DetachSocketFilter detaches a SocketFilter BPF program from a socket. 27 | func DetachSocketFilter(conn syscall.Conn) error { 28 | rawConn, err := conn.SyscallConn() 29 | if err != nil { 30 | return err 31 | } 32 | var ssoErr error 33 | err = rawConn.Control(func(fd uintptr) { 34 | ssoErr = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_DETACH_BPF, 0) 35 | }) 36 | if ssoErr != nil { 37 | return ssoErr 38 | } 39 | return err 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/syscalls.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/cilium/ebpf" 7 | "github.com/cilium/ebpf/asm" 8 | "github.com/cilium/ebpf/internal" 9 | "github.com/cilium/ebpf/internal/sys" 10 | "github.com/cilium/ebpf/internal/unix" 11 | ) 12 | 13 | // Type is the kind of link. 14 | type Type = sys.LinkType 15 | 16 | // Valid link types. 17 | const ( 18 | UnspecifiedType = sys.BPF_LINK_TYPE_UNSPEC 19 | RawTracepointType = sys.BPF_LINK_TYPE_RAW_TRACEPOINT 20 | TracingType = sys.BPF_LINK_TYPE_TRACING 21 | CgroupType = sys.BPF_LINK_TYPE_CGROUP 22 | IterType = sys.BPF_LINK_TYPE_ITER 23 | NetNsType = sys.BPF_LINK_TYPE_NETNS 24 | XDPType = sys.BPF_LINK_TYPE_XDP 25 | ) 26 | 27 | var haveProgAttach = internal.FeatureTest("BPF_PROG_ATTACH", "4.10", func() error { 28 | prog, err := ebpf.NewProgram(&ebpf.ProgramSpec{ 29 | Type: ebpf.CGroupSKB, 30 | AttachType: ebpf.AttachCGroupInetIngress, 31 | License: "MIT", 32 | Instructions: asm.Instructions{ 33 | asm.Mov.Imm(asm.R0, 0), 34 | asm.Return(), 35 | }, 36 | }) 37 | if err != nil { 38 | return internal.ErrNotSupported 39 | } 40 | 41 | // BPF_PROG_ATTACH was introduced at the same time as CGgroupSKB, 42 | // so being able to load the program is enough to infer that we 43 | // have the syscall. 44 | prog.Close() 45 | return nil 46 | }) 47 | 48 | var haveProgAttachReplace = internal.FeatureTest("BPF_PROG_ATTACH atomic replacement", "5.5", func() error { 49 | if err := haveProgAttach(); err != nil { 50 | return err 51 | } 52 | 53 | prog, err := ebpf.NewProgram(&ebpf.ProgramSpec{ 54 | Type: ebpf.CGroupSKB, 55 | AttachType: ebpf.AttachCGroupInetIngress, 56 | License: "MIT", 57 | Instructions: asm.Instructions{ 58 | asm.Mov.Imm(asm.R0, 0), 59 | asm.Return(), 60 | }, 61 | }) 62 | if err != nil { 63 | return internal.ErrNotSupported 64 | } 65 | defer prog.Close() 66 | 67 | // We know that we have BPF_PROG_ATTACH since we can load CGroupSKB programs. 68 | // If passing BPF_F_REPLACE gives us EINVAL we know that the feature isn't 69 | // present. 70 | attr := sys.ProgAttachAttr{ 71 | // We rely on this being checked after attachFlags. 72 | TargetFd: ^uint32(0), 73 | AttachBpfFd: uint32(prog.FD()), 74 | AttachType: uint32(ebpf.AttachCGroupInetIngress), 75 | AttachFlags: uint32(flagReplace), 76 | } 77 | 78 | err = sys.ProgAttach(&attr) 79 | if errors.Is(err, unix.EINVAL) { 80 | return internal.ErrNotSupported 81 | } 82 | if errors.Is(err, unix.EBADF) { 83 | return nil 84 | } 85 | return err 86 | }) 87 | 88 | var haveBPFLink = internal.FeatureTest("bpf_link", "5.7", func() error { 89 | attr := sys.LinkCreateAttr{ 90 | // This is a hopefully invalid file descriptor, which triggers EBADF. 91 | TargetFd: ^uint32(0), 92 | ProgFd: ^uint32(0), 93 | AttachType: sys.AttachType(ebpf.AttachCGroupInetIngress), 94 | } 95 | _, err := sys.LinkCreate(&attr) 96 | if errors.Is(err, unix.EINVAL) { 97 | return internal.ErrNotSupported 98 | } 99 | if errors.Is(err, unix.EBADF) { 100 | return nil 101 | } 102 | return err 103 | }) 104 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/tracepoint.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/cilium/ebpf" 7 | ) 8 | 9 | // Tracepoint attaches the given eBPF program to the tracepoint with the given 10 | // group and name. See /sys/kernel/debug/tracing/events to find available 11 | // tracepoints. The top-level directory is the group, the event's subdirectory 12 | // is the name. Example: 13 | // 14 | // tp, err := Tracepoint("syscalls", "sys_enter_fork", prog) 15 | // 16 | // Losing the reference to the resulting Link (tp) will close the Tracepoint 17 | // and prevent further execution of prog. The Link must be Closed during 18 | // program shutdown to avoid leaking system resources. 19 | // 20 | // Note that attaching eBPF programs to syscalls (sys_enter_*/sys_exit_*) is 21 | // only possible as of kernel 4.14 (commit cf5f5ce). 22 | func Tracepoint(group, name string, prog *ebpf.Program) (Link, error) { 23 | if group == "" || name == "" { 24 | return nil, fmt.Errorf("group and name cannot be empty: %w", errInvalidInput) 25 | } 26 | if prog == nil { 27 | return nil, fmt.Errorf("prog cannot be nil: %w", errInvalidInput) 28 | } 29 | if !rgxTraceEvent.MatchString(group) || !rgxTraceEvent.MatchString(name) { 30 | return nil, fmt.Errorf("group and name '%s/%s' must be alphanumeric or underscore: %w", group, name, errInvalidInput) 31 | } 32 | if prog.Type() != ebpf.TracePoint { 33 | return nil, fmt.Errorf("eBPF program type %s is not a Tracepoint: %w", prog.Type(), errInvalidInput) 34 | } 35 | 36 | tid, err := getTraceEventID(group, name) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | fd, err := openTracepointPerfEvent(tid, perfAllThreads) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | pe := &perfEvent{ 47 | fd: fd, 48 | tracefsID: tid, 49 | group: group, 50 | name: name, 51 | typ: tracepointEvent, 52 | } 53 | 54 | if err := pe.attach(prog); err != nil { 55 | pe.Close() 56 | return nil, err 57 | } 58 | 59 | return pe, nil 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/link/xdp.go: -------------------------------------------------------------------------------- 1 | package link 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/cilium/ebpf" 7 | ) 8 | 9 | // XDPAttachFlags represents how XDP program will be attached to interface. 10 | type XDPAttachFlags uint32 11 | 12 | const ( 13 | // XDPGenericMode (SKB) links XDP BPF program for drivers which do 14 | // not yet support native XDP. 15 | XDPGenericMode XDPAttachFlags = 1 << (iota + 1) 16 | // XDPDriverMode links XDP BPF program into the driver’s receive path. 17 | XDPDriverMode 18 | // XDPOffloadMode offloads the entire XDP BPF program into hardware. 19 | XDPOffloadMode 20 | ) 21 | 22 | type XDPOptions struct { 23 | // Program must be an XDP BPF program. 24 | Program *ebpf.Program 25 | 26 | // Interface is the interface index to attach program to. 27 | Interface int 28 | 29 | // Flags is one of XDPAttachFlags (optional). 30 | // 31 | // Only one XDP mode should be set, without flag defaults 32 | // to driver/generic mode (best effort). 33 | Flags XDPAttachFlags 34 | } 35 | 36 | // AttachXDP links an XDP BPF program to an XDP hook. 37 | func AttachXDP(opts XDPOptions) (Link, error) { 38 | if t := opts.Program.Type(); t != ebpf.XDP { 39 | return nil, fmt.Errorf("invalid program type %s, expected XDP", t) 40 | } 41 | 42 | if opts.Interface < 1 { 43 | return nil, fmt.Errorf("invalid interface index: %d", opts.Interface) 44 | } 45 | 46 | rawLink, err := AttachRawLink(RawLinkOptions{ 47 | Program: opts.Program, 48 | Attach: ebpf.AttachXDP, 49 | Target: opts.Interface, 50 | Flags: uint32(opts.Flags), 51 | }) 52 | 53 | return rawLink, err 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/ebpf/perf/doc.go: -------------------------------------------------------------------------------- 1 | // Package perf allows interacting with Linux perf_events. 2 | // 3 | // BPF allows submitting custom perf_events to a ring-buffer set up 4 | // by userspace. This is very useful to push things like packet samples 5 | // from BPF to a daemon running in user space. 6 | package perf 7 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package unsafeheader contains header declarations for the Go runtime's 6 | // slice and string implementations. 7 | // 8 | // This package allows x/sys to use types equivalent to 9 | // reflect.SliceHeader and reflect.StringHeader without introducing 10 | // a dependency on the (relatively heavy) "reflect" package. 11 | package unsafeheader 12 | 13 | import ( 14 | "unsafe" 15 | ) 16 | 17 | // Slice is the runtime representation of a slice. 18 | // It cannot be used safely or portably and its representation may change in a later release. 19 | type Slice struct { 20 | Data unsafe.Pointer 21 | Len int 22 | Cap int 23 | } 24 | 25 | // String is the runtime representation of a string. 26 | // It cannot be used safely or portably and its representation may change in a later release. 27 | type String struct { 28 | Data unsafe.Pointer 29 | Len int 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "math/bits" 11 | "unsafe" 12 | ) 13 | 14 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 15 | 16 | // CPUSet represents a CPU affinity mask. 17 | type CPUSet [cpuSetSize]cpuMask 18 | 19 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 20 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) 21 | if e != 0 { 22 | return errnoErr(e) 23 | } 24 | return nil 25 | } 26 | 27 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 28 | // If pid is 0 the calling thread is used. 29 | func SchedGetaffinity(pid int, set *CPUSet) error { 30 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 31 | } 32 | 33 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 34 | // If pid is 0 the calling thread is used. 35 | func SchedSetaffinity(pid int, set *CPUSet) error { 36 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 37 | } 38 | 39 | // Zero clears the set s, so that it contains no CPUs. 40 | func (s *CPUSet) Zero() { 41 | for i := range s { 42 | s[i] = 0 43 | } 44 | } 45 | 46 | func cpuBitsIndex(cpu int) int { 47 | return cpu / _NCPUBITS 48 | } 49 | 50 | func cpuBitsMask(cpu int) cpuMask { 51 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 52 | } 53 | 54 | // Set adds cpu to the set s. 55 | func (s *CPUSet) Set(cpu int) { 56 | i := cpuBitsIndex(cpu) 57 | if i < len(s) { 58 | s[i] |= cpuBitsMask(cpu) 59 | } 60 | } 61 | 62 | // Clear removes cpu from the set s. 63 | func (s *CPUSet) Clear(cpu int) { 64 | i := cpuBitsIndex(cpu) 65 | if i < len(s) { 66 | s[i] &^= cpuBitsMask(cpu) 67 | } 68 | } 69 | 70 | // IsSet reports whether cpu is in the set s. 71 | func (s *CPUSet) IsSet(cpu int) bool { 72 | i := cpuBitsIndex(cpu) 73 | if i < len(s) { 74 | return s[i]&cpuBitsMask(cpu) != 0 75 | } 76 | return false 77 | } 78 | 79 | // Count returns the number of CPUs in the set s. 80 | func (s *CPUSet) Count() int { 81 | c := 0 82 | for _, b := range s { 83 | c += bits.OnesCount64(uint64(b)) 84 | } 85 | return c 86 | } 87 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | // +build go1.9 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | type Signal = syscall.Signal 14 | type Errno = syscall.Errno 15 | type SysProcAttr = syscall.SysProcAttr 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 12 | // 13 | 14 | TEXT ·syscall6(SB),NOSPLIT,$0-88 15 | JMP syscall·syscall6(SB) 16 | 17 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSyscall6(SB) 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (freebsd || netbsd || openbsd) && gc 6 | // +build freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for 386 BSD 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc 6 | // +build darwin dragonfly freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for AMD64 BSD 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (freebsd || netbsd || openbsd) && gc 6 | // +build freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for ARM BSD 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for ARM64 BSD 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for 386, Linux 12 | // 13 | 14 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 15 | // instead of the glibc-specific "CALL 0x10(GS)". 16 | #define INVOKE_SYSCALL INT $0x80 17 | 18 | // Just jump to package syscall's implementation for all these functions. 19 | // The runtime may know about them. 20 | 21 | TEXT ·Syscall(SB),NOSPLIT,$0-28 22 | JMP syscall·Syscall(SB) 23 | 24 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 25 | JMP syscall·Syscall6(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | CALL runtime·entersyscall(SB) 29 | MOVL trap+0(FP), AX // syscall entry 30 | MOVL a1+4(FP), BX 31 | MOVL a2+8(FP), CX 32 | MOVL a3+12(FP), DX 33 | MOVL $0, SI 34 | MOVL $0, DI 35 | INVOKE_SYSCALL 36 | MOVL AX, r1+16(FP) 37 | MOVL DX, r2+20(FP) 38 | CALL runtime·exitsyscall(SB) 39 | RET 40 | 41 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 42 | JMP syscall·RawSyscall(SB) 43 | 44 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 45 | JMP syscall·RawSyscall6(SB) 46 | 47 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 48 | MOVL trap+0(FP), AX // syscall entry 49 | MOVL a1+4(FP), BX 50 | MOVL a2+8(FP), CX 51 | MOVL a3+12(FP), DX 52 | MOVL $0, SI 53 | MOVL $0, DI 54 | INVOKE_SYSCALL 55 | MOVL AX, r1+16(FP) 56 | MOVL DX, r2+20(FP) 57 | RET 58 | 59 | TEXT ·socketcall(SB),NOSPLIT,$0-36 60 | JMP syscall·socketcall(SB) 61 | 62 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 63 | JMP syscall·rawsocketcall(SB) 64 | 65 | TEXT ·seek(SB),NOSPLIT,$0-28 66 | JMP syscall·seek(SB) 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for AMD64, Linux 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 24 | CALL runtime·entersyscall(SB) 25 | MOVQ a1+8(FP), DI 26 | MOVQ a2+16(FP), SI 27 | MOVQ a3+24(FP), DX 28 | MOVQ $0, R10 29 | MOVQ $0, R8 30 | MOVQ $0, R9 31 | MOVQ trap+0(FP), AX // syscall entry 32 | SYSCALL 33 | MOVQ AX, r1+32(FP) 34 | MOVQ DX, r2+40(FP) 35 | CALL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 39 | JMP syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 42 | JMP syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 45 | MOVQ a1+8(FP), DI 46 | MOVQ a2+16(FP), SI 47 | MOVQ a3+24(FP), DX 48 | MOVQ $0, R10 49 | MOVQ $0, R8 50 | MOVQ $0, R9 51 | MOVQ trap+0(FP), AX // syscall entry 52 | SYSCALL 53 | MOVQ AX, r1+32(FP) 54 | MOVQ DX, r2+40(FP) 55 | RET 56 | 57 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 58 | JMP syscall·gettimeofday(SB) 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for arm, Linux 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 24 | BL runtime·entersyscall(SB) 25 | MOVW trap+0(FP), R7 26 | MOVW a1+4(FP), R0 27 | MOVW a2+8(FP), R1 28 | MOVW a3+12(FP), R2 29 | MOVW $0, R3 30 | MOVW $0, R4 31 | MOVW $0, R5 32 | SWI $0 33 | MOVW R0, r1+16(FP) 34 | MOVW $0, R0 35 | MOVW R0, r2+20(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 40 | B syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 43 | B syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 46 | MOVW trap+0(FP), R7 // syscall entry 47 | MOVW a1+4(FP), R0 48 | MOVW a2+8(FP), R1 49 | MOVW a3+12(FP), R2 50 | SWI $0 51 | MOVW R0, r1+16(FP) 52 | MOVW $0, R0 53 | MOVW R0, r2+20(FP) 54 | RET 55 | 56 | TEXT ·seek(SB),NOSPLIT,$0-28 57 | B syscall·seek(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && arm64 && gc 6 | // +build linux 7 | // +build arm64 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // Just jump to package syscall's implementation for all these functions. 13 | // The runtime may know about them. 14 | 15 | TEXT ·Syscall(SB),NOSPLIT,$0-56 16 | B syscall·Syscall(SB) 17 | 18 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 19 | B syscall·Syscall6(SB) 20 | 21 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 22 | BL runtime·entersyscall(SB) 23 | MOVD a1+8(FP), R0 24 | MOVD a2+16(FP), R1 25 | MOVD a3+24(FP), R2 26 | MOVD $0, R3 27 | MOVD $0, R4 28 | MOVD $0, R5 29 | MOVD trap+0(FP), R8 // syscall entry 30 | SVC 31 | MOVD R0, r1+32(FP) // r1 32 | MOVD R1, r2+40(FP) // r2 33 | BL runtime·exitsyscall(SB) 34 | RET 35 | 36 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 37 | B syscall·RawSyscall(SB) 38 | 39 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 40 | B syscall·RawSyscall6(SB) 41 | 42 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 43 | MOVD a1+8(FP), R0 44 | MOVD a2+16(FP), R1 45 | MOVD a3+24(FP), R2 46 | MOVD $0, R3 47 | MOVD $0, R4 48 | MOVD $0, R5 49 | MOVD trap+0(FP), R8 // syscall entry 50 | SVC 51 | MOVD R0, r1+32(FP) 52 | MOVD R1, r2+40(FP) 53 | RET 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (mips64 || mips64le) && gc 6 | // +build linux 7 | // +build mips64 mips64le 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for mips64, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-56 20 | JMP syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 23 | JMP syscall·Syscall6(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 26 | JAL runtime·entersyscall(SB) 27 | MOVV a1+8(FP), R4 28 | MOVV a2+16(FP), R5 29 | MOVV a3+24(FP), R6 30 | MOVV R0, R7 31 | MOVV R0, R8 32 | MOVV R0, R9 33 | MOVV trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVV R2, r1+32(FP) 36 | MOVV R3, r2+40(FP) 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 47 | MOVV a1+8(FP), R4 48 | MOVV a2+16(FP), R5 49 | MOVV a3+24(FP), R6 50 | MOVV R0, R7 51 | MOVV R0, R8 52 | MOVV R0, R9 53 | MOVV trap+0(FP), R2 // syscall entry 54 | SYSCALL 55 | MOVV R2, r1+32(FP) 56 | MOVV R3, r2+40(FP) 57 | RET 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (mips || mipsle) && gc 6 | // +build linux 7 | // +build mips mipsle 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for mips, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-28 20 | JMP syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 23 | JMP syscall·Syscall6(SB) 24 | 25 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 26 | JMP syscall·Syscall9(SB) 27 | 28 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 29 | JAL runtime·entersyscall(SB) 30 | MOVW a1+4(FP), R4 31 | MOVW a2+8(FP), R5 32 | MOVW a3+12(FP), R6 33 | MOVW R0, R7 34 | MOVW trap+0(FP), R2 // syscall entry 35 | SYSCALL 36 | MOVW R2, r1+16(FP) // r1 37 | MOVW R3, r2+20(FP) // r2 38 | JAL runtime·exitsyscall(SB) 39 | RET 40 | 41 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 42 | JMP syscall·RawSyscall(SB) 43 | 44 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 45 | JMP syscall·RawSyscall6(SB) 46 | 47 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 48 | MOVW a1+4(FP), R4 49 | MOVW a2+8(FP), R5 50 | MOVW a3+12(FP), R6 51 | MOVW trap+0(FP), R2 // syscall entry 52 | SYSCALL 53 | MOVW R2, r1+16(FP) 54 | MOVW R3, r2+20(FP) 55 | RET 56 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (ppc64 || ppc64le) && gc 6 | // +build linux 7 | // +build ppc64 ppc64le 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for ppc64, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 20 | BL runtime·entersyscall(SB) 21 | MOVD a1+8(FP), R3 22 | MOVD a2+16(FP), R4 23 | MOVD a3+24(FP), R5 24 | MOVD R0, R6 25 | MOVD R0, R7 26 | MOVD R0, R8 27 | MOVD trap+0(FP), R9 // syscall entry 28 | SYSCALL R9 29 | MOVD R3, r1+32(FP) 30 | MOVD R4, r2+40(FP) 31 | BL runtime·exitsyscall(SB) 32 | RET 33 | 34 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 35 | MOVD a1+8(FP), R3 36 | MOVD a2+16(FP), R4 37 | MOVD a3+24(FP), R5 38 | MOVD R0, R6 39 | MOVD R0, R7 40 | MOVD R0, R8 41 | MOVD trap+0(FP), R9 // syscall entry 42 | SYSCALL R9 43 | MOVD R3, r1+32(FP) 44 | MOVD R4, r2+40(FP) 45 | RET 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_riscv64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build riscv64 && gc 6 | // +build riscv64 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for linux/riscv64. 13 | // 14 | // Where available, just jump to package syscall's implementation of 15 | // these functions. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 24 | CALL runtime·entersyscall(SB) 25 | MOV a1+8(FP), A0 26 | MOV a2+16(FP), A1 27 | MOV a3+24(FP), A2 28 | MOV trap+0(FP), A7 // syscall entry 29 | ECALL 30 | MOV A0, r1+32(FP) // r1 31 | MOV A1, r2+40(FP) // r2 32 | CALL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | JMP syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | JMP syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOV a1+8(FP), A0 43 | MOV a2+16(FP), A1 44 | MOV a3+24(FP), A2 45 | MOV trap+0(FP), A7 // syscall entry 46 | ECALL 47 | MOV A0, r1+32(FP) 48 | MOV A1, r2+40(FP) 49 | RET 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && s390x && gc 6 | // +build linux 7 | // +build s390x 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for s390x, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-56 20 | BR syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 23 | BR syscall·Syscall6(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 26 | BL runtime·entersyscall(SB) 27 | MOVD a1+8(FP), R2 28 | MOVD a2+16(FP), R3 29 | MOVD a3+24(FP), R4 30 | MOVD $0, R5 31 | MOVD $0, R6 32 | MOVD $0, R7 33 | MOVD trap+0(FP), R1 // syscall entry 34 | SYSCALL 35 | MOVD R2, r1+32(FP) 36 | MOVD R3, r2+40(FP) 37 | BL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 41 | BR syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 44 | BR syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 47 | MOVD a1+8(FP), R2 48 | MOVD a2+16(FP), R3 49 | MOVD a3+24(FP), R4 50 | MOVD $0, R5 51 | MOVD $0, R6 52 | MOVD $0, R7 53 | MOVD trap+0(FP), R1 // syscall entry 54 | SYSCALL 55 | MOVD R2, r1+32(FP) 56 | MOVD R3, r2+40(FP) 57 | RET 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for mips64, OpenBSD 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | JMP syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | JMP syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | JMP syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 12 | // 13 | 14 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 15 | JMP syscall·sysvicall6(SB) 16 | 17 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSysvicall6(SB) 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | HCI_CHANNEL_LOGGING = 4 27 | ) 28 | 29 | // Socketoption Level 30 | const ( 31 | SOL_BLUETOOTH = 0x112 32 | SOL_HCI = 0x0 33 | SOL_L2CAP = 0x6 34 | SOL_RFCOMM = 0x12 35 | SOL_SCO = 0x11 36 | ) 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | const ( 11 | R_OK = 0x4 12 | W_OK = 0x2 13 | X_OK = 0x1 14 | ) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc 6 | // +build aix,ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc64 6 | // +build aix,ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build zos && s390x 6 | // +build zos,s390x 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by z/OS. 10 | // 11 | // The information below is extracted and adapted from macros. 12 | 13 | package unix 14 | 15 | // Major returns the major component of a z/OS device number. 16 | func Major(dev uint64) uint32 { 17 | return uint32((dev >> 16) & 0x0000FFFF) 18 | } 19 | 20 | // Minor returns the minor component of a z/OS device number. 21 | func Minor(dev uint64) uint32 { 22 | return uint32(dev & 0x0000FFFF) 23 | } 24 | 25 | // Mkdev returns a z/OS device number generated from the given major and minor 26 | // components. 27 | func Mkdev(major, minor uint32) uint64 { 28 | return (uint64(major) << 16) | uint64(minor) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 6 | // +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 7 | 8 | package unix 9 | 10 | const isBigEndian = true 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh 6 | // +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh 7 | 8 | package unix 9 | 10 | const isBigEndian = false 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Unix environment variables. 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Getenv(key string) (value string, found bool) { 15 | return syscall.Getenv(key) 16 | } 17 | 18 | func Setenv(key, value string) error { 19 | return syscall.Setenv(key, value) 20 | } 21 | 22 | func Clearenv() { 23 | syscall.Clearenv() 24 | } 25 | 26 | func Environ() []string { 27 | return syscall.Environ() 28 | } 29 | 30 | func Unsetenv(key string) error { 31 | return syscall.Unsetenv(key) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Constants that were deprecated or moved to enums in the FreeBSD headers. Keep 6 | // them here for backwards compatibility. 7 | 8 | package unix 9 | 10 | const ( 11 | DLT_HHDLC = 0x79 12 | IPV6_MIN_MEMBERSHIPS = 0x1f 13 | IP_MAX_SOURCE_FILTER = 0x400 14 | IP_MIN_MEMBERSHIPS = 0x1f 15 | RT_CACHING_CONTEXT = 0x1 16 | RT_NORTREF = 0x2 17 | ) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build dragonfly || freebsd || linux || netbsd || openbsd 6 | // +build dragonfly freebsd linux netbsd openbsd 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 13 | // systems by fcntl_linux_32bit.go to be SYS_FCNTL64. 14 | var fcntl64Syscall uintptr = SYS_FCNTL 15 | 16 | func fcntl(fd int, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 26 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 27 | return fcntl(int(fd), cmd, arg) 28 | } 29 | 30 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 31 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 32 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 33 | if errno == 0 { 34 | return nil 35 | } 36 | return errno 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 10 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 11 | return fcntl(int(fd), cmd, arg) 12 | } 13 | 14 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 15 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 16 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) 17 | return err 18 | } 19 | 20 | // FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command. 21 | func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error { 22 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore)))) 23 | return err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc) 6 | // +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc 7 | 8 | package unix 9 | 10 | func init() { 11 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 12 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 13 | fcntl64Syscall = SYS_FCNTL64 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fdset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | // Set adds fd to the set fds. 11 | func (fds *FdSet) Set(fd int) { 12 | fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS)) 13 | } 14 | 15 | // Clear removes fd from the set fds. 16 | func (fds *FdSet) Clear(fd int) { 17 | fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS)) 18 | } 19 | 20 | // IsSet returns whether fd is in the set fds. 21 | func (fds *FdSet) IsSet(fd int) bool { 22 | return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0 23 | } 24 | 25 | // Zero clears the set fds. 26 | func (fds *FdSet) Zero() { 27 | for i := range fds.Bits { 28 | fds.Bits[i] = 0 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo && !aix 6 | // +build gccgo,!aix 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // We can't use the gc-syntax .s files for gccgo. On the plus side 13 | // much of the functionality can be written directly in Go. 14 | 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 18 | 19 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 20 | syscall.Entersyscall() 21 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 22 | syscall.Exitsyscall() 23 | return r, 0 24 | } 25 | 26 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 27 | syscall.Entersyscall() 28 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 29 | syscall.Exitsyscall() 30 | return r, 0, syscall.Errno(errno) 31 | } 32 | 33 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 34 | syscall.Entersyscall() 35 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 36 | syscall.Exitsyscall() 37 | return r, 0, syscall.Errno(errno) 38 | } 39 | 40 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 41 | syscall.Entersyscall() 42 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 43 | syscall.Exitsyscall() 44 | return r, 0, syscall.Errno(errno) 45 | } 46 | 47 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 48 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 49 | return r, 0 50 | } 51 | 52 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 53 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 54 | return r, 0, syscall.Errno(errno) 55 | } 56 | 57 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 58 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 59 | return r, 0, syscall.Errno(errno) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall"); 26 | 27 | struct ret 28 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 29 | { 30 | struct ret r; 31 | 32 | errno = 0; 33 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 34 | r.err = errno; 35 | return r; 36 | } 37 | 38 | uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 39 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError"); 40 | 41 | uintptr_t 42 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 43 | { 44 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo && linux && amd64 6 | // +build gccgo,linux,amd64 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //extern gettimeofday 13 | func realGettimeofday(*Timeval, *byte) int32 14 | 15 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 16 | r := realGettimeofday(tv, nil) 17 | if r < 0 { 18 | return syscall.GetErrno() 19 | } 20 | return 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | // ioctl itself should not be exposed directly, but additional get/set 16 | // functions for specific types are permissible. 17 | 18 | // IoctlSetInt performs an ioctl operation which sets an integer value 19 | // on fd, using the specified request number. 20 | func IoctlSetInt(fd int, req uint, value int) error { 21 | return ioctl(fd, req, uintptr(value)) 22 | } 23 | 24 | // IoctlSetPointerInt performs an ioctl operation which sets an 25 | // integer value on fd, using the specified request number. The ioctl 26 | // argument is called with a pointer to the integer value, rather than 27 | // passing the integer value directly. 28 | func IoctlSetPointerInt(fd int, req uint, value int) error { 29 | v := int32(value) 30 | return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) 31 | } 32 | 33 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 34 | // 35 | // To change fd's window size, the req argument should be TIOCSWINSZ. 36 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 37 | // TODO: if we get the chance, remove the req parameter and 38 | // hardcode TIOCSWINSZ. 39 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 40 | runtime.KeepAlive(value) 41 | return err 42 | } 43 | 44 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 45 | // 46 | // The req value will usually be TCSETA or TIOCSETA. 47 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 48 | // TODO: if we get the chance, remove the req parameter. 49 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 50 | runtime.KeepAlive(value) 51 | return err 52 | } 53 | 54 | // IoctlGetInt performs an ioctl operation which gets an integer value 55 | // from fd, using the specified request number. 56 | // 57 | // A few ioctl requests use the return value as an output parameter; 58 | // for those, IoctlRetInt should be used instead of this function. 59 | func IoctlGetInt(fd int, req uint) (int, error) { 60 | var value int 61 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 62 | return value, err 63 | } 64 | 65 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 66 | var value Winsize 67 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 68 | return &value, err 69 | } 70 | 71 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 72 | var value Termios 73 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 74 | return &value, err 75 | } 76 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build zos && s390x 6 | // +build zos,s390x 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | // ioctl itself should not be exposed directly, but additional get/set 16 | // functions for specific types are permissible. 17 | 18 | // IoctlSetInt performs an ioctl operation which sets an integer value 19 | // on fd, using the specified request number. 20 | func IoctlSetInt(fd int, req uint, value int) error { 21 | return ioctl(fd, req, uintptr(value)) 22 | } 23 | 24 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 25 | // 26 | // To change fd's window size, the req argument should be TIOCSWINSZ. 27 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 28 | // TODO: if we get the chance, remove the req parameter and 29 | // hardcode TIOCSWINSZ. 30 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 31 | runtime.KeepAlive(value) 32 | return err 33 | } 34 | 35 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 36 | // 37 | // The req value is expected to be TCSETS, TCSETSW, or TCSETSF 38 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 39 | if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { 40 | return ENOSYS 41 | } 42 | err := Tcsetattr(fd, int(req), value) 43 | runtime.KeepAlive(value) 44 | return err 45 | } 46 | 47 | // IoctlGetInt performs an ioctl operation which gets an integer value 48 | // from fd, using the specified request number. 49 | // 50 | // A few ioctl requests use the return value as an output parameter; 51 | // for those, IoctlRetInt should be used instead of this function. 52 | func IoctlGetInt(fd int, req uint) (int, error) { 53 | var value int 54 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 55 | return value, err 56 | } 57 | 58 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 59 | var value Winsize 60 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 61 | return &value, err 62 | } 63 | 64 | // IoctlGetTermios performs an ioctl on fd with a *Termios. 65 | // 66 | // The req value is expected to be TCGETS 67 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 68 | var value Termios 69 | if req != TCGETS { 70 | return &value, ENOSYS 71 | } 72 | err := Tcgetattr(fd, &value) 73 | return &value, err 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | // For Unix, get the pagesize from the runtime. 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Getpagesize() int { 15 | return syscall.Getpagesize() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ptrace_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && !ios 6 | // +build darwin,!ios 7 | 8 | package unix 9 | 10 | func ptrace(request int, pid int, addr uintptr, data uintptr) error { 11 | return ptrace1(request, pid, addr, data) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ptrace_ios.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build ios 6 | // +build ios 7 | 8 | package unix 9 | 10 | func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { 11 | return ENOTSUP 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin && race) || (linux && race) || (freebsd && race) 6 | // +build darwin,race linux,race freebsd,race 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | const raceenabled = true 16 | 17 | func raceAcquire(addr unsafe.Pointer) { 18 | runtime.RaceAcquire(addr) 19 | } 20 | 21 | func raceReleaseMerge(addr unsafe.Pointer) { 22 | runtime.RaceReleaseMerge(addr) 23 | } 24 | 25 | func raceReadRange(addr unsafe.Pointer, len int) { 26 | runtime.RaceReadRange(addr, len) 27 | } 28 | 29 | func raceWriteRange(addr unsafe.Pointer, len int) { 30 | runtime.RaceWriteRange(addr, len) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || (darwin && !race) || (linux && !race) || (freebsd && !race) || netbsd || openbsd || solaris || dragonfly || zos 6 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly zos 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = false 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | } 18 | 19 | func raceReleaseMerge(addr unsafe.Pointer) { 20 | } 21 | 22 | func raceReadRange(addr unsafe.Pointer, len int) { 23 | } 24 | 25 | func raceWriteRange(addr unsafe.Pointer, len int) { 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/readdirent_getdents.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || dragonfly || freebsd || linux || netbsd || openbsd 6 | // +build aix dragonfly freebsd linux netbsd openbsd 7 | 8 | package unix 9 | 10 | // ReadDirent reads directory entries from fd and writes them into buf. 11 | func ReadDirent(fd int, buf []byte) (n int, err error) { 12 | return Getdents(fd, buf) 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/readdirent_getdirentries.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin 6 | // +build darwin 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // ReadDirent reads directory entries from fd and writes them into buf. 13 | func ReadDirent(fd int, buf []byte) (n int, err error) { 14 | // Final argument is (basep *uintptr) and the syscall doesn't take nil. 15 | // 64 bits should be enough. (32 bits isn't even on 386). Since the 16 | // actual system call is getdirentries64, 64 is a good guess. 17 | // TODO(rsc): Can we use a single global basep for all calls? 18 | var base = (*uintptr)(unsafe.Pointer(new(uint64))) 19 | return Getdirentries(fd, buf, base) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | // Round the length of a raw sockaddr up to align it properly. 8 | func cmsgAlignOf(salen int) int { 9 | salign := SizeofPtr 10 | if SizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) { 11 | // 64-bit Dragonfly before the September 2019 ABI changes still requires 12 | // 32-bit aligned access to network subsystem. 13 | salign = 4 14 | } 15 | return (salen + salign - 1) & ^(salign - 1) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *(*Ucred)(h.data(0)) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | 38 | // PktInfo4 encodes Inet4Pktinfo into a socket control message of type IP_PKTINFO. 39 | func PktInfo4(info *Inet4Pktinfo) []byte { 40 | b := make([]byte, CmsgSpace(SizeofInet4Pktinfo)) 41 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 42 | h.Level = SOL_IP 43 | h.Type = IP_PKTINFO 44 | h.SetLen(CmsgLen(SizeofInet4Pktinfo)) 45 | *(*Inet4Pktinfo)(h.data(0)) = *info 46 | return b 47 | } 48 | 49 | // PktInfo6 encodes Inet6Pktinfo into a socket control message of type IPV6_PKTINFO. 50 | func PktInfo6(info *Inet6Pktinfo) []byte { 51 | b := make([]byte, CmsgSpace(SizeofInet6Pktinfo)) 52 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 53 | h.Level = SOL_IPV6 54 | h.Type = IPV6_PKTINFO 55 | h.SetLen(CmsgLen(SizeofInet6Pktinfo)) 56 | *(*Inet6Pktinfo)(h.data(0)) = *info 57 | return b 58 | } 59 | 60 | // ParseOrigDstAddr decodes a socket control message containing the original 61 | // destination address. To receive such a message the IP_RECVORIGDSTADDR or 62 | // IPV6_RECVORIGDSTADDR option must be enabled on the socket. 63 | func ParseOrigDstAddr(m *SocketControlMessage) (Sockaddr, error) { 64 | switch { 65 | case m.Header.Level == SOL_IP && m.Header.Type == IP_ORIGDSTADDR: 66 | pp := (*RawSockaddrInet4)(unsafe.Pointer(&m.Data[0])) 67 | sa := new(SockaddrInet4) 68 | p := (*[2]byte)(unsafe.Pointer(&pp.Port)) 69 | sa.Port = int(p[0])<<8 + int(p[1]) 70 | sa.Addr = pp.Addr 71 | return sa, nil 72 | 73 | case m.Header.Level == SOL_IPV6 && m.Header.Type == IPV6_ORIGDSTADDR: 74 | pp := (*RawSockaddrInet6)(unsafe.Pointer(&m.Data[0])) 75 | sa := new(SockaddrInet6) 76 | p := (*[2]byte)(unsafe.Pointer(&pp.Port)) 77 | sa.Port = int(p[0])<<8 + int(p[1]) 78 | sa.ZoneId = pp.Scope_id 79 | sa.Addr = pp.Addr 80 | return sa, nil 81 | 82 | default: 83 | return nil, EINVAL 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Socket control messages 9 | 10 | package unix 11 | 12 | import ( 13 | "unsafe" 14 | ) 15 | 16 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 17 | // structure, taking into account any necessary alignment. 18 | func CmsgLen(datalen int) int { 19 | return cmsgAlignOf(SizeofCmsghdr) + datalen 20 | } 21 | 22 | // CmsgSpace returns the number of bytes an ancillary element with 23 | // payload of the passed data length occupies. 24 | func CmsgSpace(datalen int) int { 25 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 26 | } 27 | 28 | func (h *Cmsghdr) data(offset uintptr) unsafe.Pointer { 29 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)) + offset) 30 | } 31 | 32 | // SocketControlMessage represents a socket control message. 33 | type SocketControlMessage struct { 34 | Header Cmsghdr 35 | Data []byte 36 | } 37 | 38 | // ParseSocketControlMessage parses b as an array of socket control 39 | // messages. 40 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 41 | var msgs []SocketControlMessage 42 | i := 0 43 | for i+CmsgLen(0) <= len(b) { 44 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 45 | if err != nil { 46 | return nil, err 47 | } 48 | m := SocketControlMessage{Header: *h, Data: dbuf} 49 | msgs = append(msgs, m) 50 | i += cmsgAlignOf(int(h.Len)) 51 | } 52 | return msgs, nil 53 | } 54 | 55 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 56 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 57 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 58 | return nil, nil, EINVAL 59 | } 60 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 61 | } 62 | 63 | // UnixRights encodes a set of open file descriptors into a socket 64 | // control message for sending to another process. 65 | func UnixRights(fds ...int) []byte { 66 | datalen := len(fds) * 4 67 | b := make([]byte, CmsgSpace(datalen)) 68 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 69 | h.Level = SOL_SOCKET 70 | h.Type = SCM_RIGHTS 71 | h.SetLen(CmsgLen(datalen)) 72 | for i, fd := range fds { 73 | *(*int32)(h.data(4 * uintptr(i))) = int32(fd) 74 | } 75 | return b 76 | } 77 | 78 | // ParseUnixRights decodes a socket control message that contains an 79 | // integer array of open file descriptors from another process. 80 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 81 | if m.Header.Level != SOL_SOCKET { 82 | return nil, EINVAL 83 | } 84 | if m.Header.Type != SCM_RIGHTS { 85 | return nil, EINVAL 86 | } 87 | fds := make([]int, len(m.Data)>>2) 88 | for i, j := 0, 0; i < len(m.Data); i += 4 { 89 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 90 | j++ 91 | } 92 | return fds, nil 93 | } 94 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | ) 13 | 14 | // Round the length of a raw sockaddr up to align it properly. 15 | func cmsgAlignOf(salen int) int { 16 | salign := SizeofPtr 17 | 18 | // dragonfly needs to check ABI version at runtime, see cmsgAlignOf in 19 | // sockcmsg_dragonfly.go 20 | switch runtime.GOOS { 21 | case "aix": 22 | // There is no alignment on AIX. 23 | salign = 1 24 | case "darwin", "ios", "illumos", "solaris": 25 | // NOTE: It seems like 64-bit Darwin, Illumos and Solaris 26 | // kernels still require 32-bit aligned access to network 27 | // subsystem. 28 | if SizeofPtr == 8 { 29 | salign = 4 30 | } 31 | case "netbsd", "openbsd": 32 | // NetBSD and OpenBSD armv7 require 64-bit alignment. 33 | if runtime.GOARCH == "arm" { 34 | salign = 8 35 | } 36 | // NetBSD aarch64 requires 128-bit alignment. 37 | if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { 38 | salign = 16 39 | } 40 | case "zos": 41 | // z/OS socket macros use [32-bit] sizeof(int) alignment, 42 | // not pointer width. 43 | salign = SizeofInt 44 | } 45 | 46 | return (salen + salign - 1) & ^(salign - 1) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | package unix 9 | 10 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 11 | if val < 0 { 12 | return "-" + uitoa(uint(-val)) 13 | } 14 | return uitoa(uint(val)) 15 | } 16 | 17 | func uitoa(val uint) string { 18 | var buf [32]byte // big enough for int64 19 | i := len(buf) - 1 20 | for val >= 10 { 21 | buf[i] = byte(val%10 + '0') 22 | i-- 23 | val /= 10 24 | } 25 | buf[i] = byte(val + '0') 26 | return string(buf[i:]) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Package unix contains an interface to the low-level operating system 9 | // primitives. OS details vary depending on the underlying system, and 10 | // by default, godoc will display OS-specific documentation for the current 11 | // system. If you want godoc to display OS documentation for another 12 | // system, set $GOOS and $GOARCH to the desired system. For example, if 13 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 14 | // to freebsd and $GOARCH to arm. 15 | // 16 | // The primary use of this package is inside other packages that provide a more 17 | // portable interface to the system, such as "os", "time" and "net". Use 18 | // those packages rather than this one if you can. 19 | // 20 | // For details of the functions and data types in this package consult 21 | // the manuals for the appropriate operating system. 22 | // 23 | // These calls return err == nil to indicate success; otherwise 24 | // err represents an operating system error describing the failure and 25 | // holds a value of type syscall.Errno. 26 | package unix // import "golang.org/x/sys/unix" 27 | 28 | import ( 29 | "bytes" 30 | "strings" 31 | "unsafe" 32 | 33 | "golang.org/x/sys/internal/unsafeheader" 34 | ) 35 | 36 | // ByteSliceFromString returns a NUL-terminated slice of bytes 37 | // containing the text of s. If s contains a NUL byte at any 38 | // location, it returns (nil, EINVAL). 39 | func ByteSliceFromString(s string) ([]byte, error) { 40 | if strings.IndexByte(s, 0) != -1 { 41 | return nil, EINVAL 42 | } 43 | a := make([]byte, len(s)+1) 44 | copy(a, s) 45 | return a, nil 46 | } 47 | 48 | // BytePtrFromString returns a pointer to a NUL-terminated array of 49 | // bytes containing the text of s. If s contains a NUL byte at any 50 | // location, it returns (nil, EINVAL). 51 | func BytePtrFromString(s string) (*byte, error) { 52 | a, err := ByteSliceFromString(s) 53 | if err != nil { 54 | return nil, err 55 | } 56 | return &a[0], nil 57 | } 58 | 59 | // ByteSliceToString returns a string form of the text represented by the slice s, with a terminating NUL and any 60 | // bytes after the NUL removed. 61 | func ByteSliceToString(s []byte) string { 62 | if i := bytes.IndexByte(s, 0); i != -1 { 63 | s = s[:i] 64 | } 65 | return string(s) 66 | } 67 | 68 | // BytePtrToString takes a pointer to a sequence of text and returns the corresponding string. 69 | // If the pointer is nil, it returns the empty string. It assumes that the text sequence is terminated 70 | // at a zero byte; if the zero byte is not present, the program may crash. 71 | func BytePtrToString(p *byte) string { 72 | if p == nil { 73 | return "" 74 | } 75 | if *p == 0 { 76 | return "" 77 | } 78 | 79 | // Find NUL terminator. 80 | n := 0 81 | for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ { 82 | ptr = unsafe.Pointer(uintptr(ptr) + 1) 83 | } 84 | 85 | var s []byte 86 | h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) 87 | h.Data = unsafe.Pointer(p) 88 | h.Len = n 89 | h.Cap = n 90 | 91 | return string(s) 92 | } 93 | 94 | // Single-word zero for use when we need a valid pointer to 0 bytes. 95 | var _zero uintptr 96 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc 6 | // +build aix,ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func Fstat(fd int, stat *Stat_t) error { 41 | return fstat(fd, stat) 42 | } 43 | 44 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 45 | return fstatat(dirfd, path, stat, flags) 46 | } 47 | 48 | func Lstat(path string, stat *Stat_t) error { 49 | return lstat(path, stat) 50 | } 51 | 52 | func Stat(path string, statptr *Stat_t) error { 53 | return stat(path, statptr) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc64 6 | // +build aix,ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // In order to only have Timespec structure, type of Stat_t's fields 41 | // Atim, Mtim and Ctim is changed from StTimespec to Timespec during 42 | // ztypes generation. 43 | // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an 44 | // int32, so the fields' value must be modified. 45 | func fixStatTimFields(stat *Stat_t) { 46 | stat.Atim.Nsec >>= 32 47 | stat.Mtim.Nsec >>= 32 48 | stat.Ctim.Nsec >>= 32 49 | } 50 | 51 | func Fstat(fd int, stat *Stat_t) error { 52 | err := fstat(fd, stat) 53 | if err != nil { 54 | return err 55 | } 56 | fixStatTimFields(stat) 57 | return nil 58 | } 59 | 60 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 61 | err := fstatat(dirfd, path, stat, flags) 62 | if err != nil { 63 | return err 64 | } 65 | fixStatTimFields(stat) 66 | return nil 67 | } 68 | 69 | func Lstat(path string, stat *Stat_t) error { 70 | err := lstat(path, stat) 71 | if err != nil { 72 | return err 73 | } 74 | fixStatTimFields(stat) 75 | return nil 76 | } 77 | 78 | func Stat(path string, statptr *Stat_t) error { 79 | err := stat(path, statptr) 80 | if err != nil { 81 | return err 82 | } 83 | fixStatTimFields(statptr) 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && go1.12 && !go1.13 6 | // +build darwin,go1.12,!go1.13 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | ) 13 | 14 | const _SYS_GETDIRENTRIES64 = 344 15 | 16 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 17 | // To implement this using libSystem we'd need syscall_syscallPtr for 18 | // fdopendir. However, syscallPtr was only added in Go 1.13, so we fall 19 | // back to raw syscalls for this func on Go 1.12. 20 | var p unsafe.Pointer 21 | if len(buf) > 0 { 22 | p = unsafe.Pointer(&buf[0]) 23 | } else { 24 | p = unsafe.Pointer(&_zero) 25 | } 26 | r0, _, e1 := Syscall6(_SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) 27 | n = int(r0) 28 | if e1 != 0 { 29 | return n, errnoErr(e1) 30 | } 31 | return n, nil 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && go1.13 6 | // +build darwin,go1.13 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | 13 | "golang.org/x/sys/internal/unsafeheader" 14 | ) 15 | 16 | //sys closedir(dir uintptr) (err error) 17 | //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) 18 | 19 | func fdopendir(fd int) (dir uintptr, err error) { 20 | r0, _, e1 := syscall_syscallPtr(libc_fdopendir_trampoline_addr, uintptr(fd), 0, 0) 21 | dir = uintptr(r0) 22 | if e1 != 0 { 23 | err = errnoErr(e1) 24 | } 25 | return 26 | } 27 | 28 | var libc_fdopendir_trampoline_addr uintptr 29 | 30 | //go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib" 31 | 32 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 33 | // Simulate Getdirentries using fdopendir/readdir_r/closedir. 34 | // We store the number of entries to skip in the seek 35 | // offset of fd. See issue #31368. 36 | // It's not the full required semantics, but should handle the case 37 | // of calling Getdirentries or ReadDirent repeatedly. 38 | // It won't handle assigning the results of lseek to *basep, or handle 39 | // the directory being edited underfoot. 40 | skip, err := Seek(fd, 0, 1 /* SEEK_CUR */) 41 | if err != nil { 42 | return 0, err 43 | } 44 | 45 | // We need to duplicate the incoming file descriptor 46 | // because the caller expects to retain control of it, but 47 | // fdopendir expects to take control of its argument. 48 | // Just Dup'ing the file descriptor is not enough, as the 49 | // result shares underlying state. Use Openat to make a really 50 | // new file descriptor referring to the same directory. 51 | fd2, err := Openat(fd, ".", O_RDONLY, 0) 52 | if err != nil { 53 | return 0, err 54 | } 55 | d, err := fdopendir(fd2) 56 | if err != nil { 57 | Close(fd2) 58 | return 0, err 59 | } 60 | defer closedir(d) 61 | 62 | var cnt int64 63 | for { 64 | var entry Dirent 65 | var entryp *Dirent 66 | e := readdir_r(d, &entry, &entryp) 67 | if e != 0 { 68 | return n, errnoErr(e) 69 | } 70 | if entryp == nil { 71 | break 72 | } 73 | if skip > 0 { 74 | skip-- 75 | cnt++ 76 | continue 77 | } 78 | 79 | reclen := int(entry.Reclen) 80 | if reclen > len(buf) { 81 | // Not enough room. Return for now. 82 | // The counter will let us know where we should start up again. 83 | // Note: this strategy for suspending in the middle and 84 | // restarting is O(n^2) in the length of the directory. Oh well. 85 | break 86 | } 87 | 88 | // Copy entry into return buffer. 89 | var s []byte 90 | hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s)) 91 | hdr.Data = unsafe.Pointer(&entry) 92 | hdr.Cap = reclen 93 | hdr.Len = reclen 94 | copy(buf, s) 95 | 96 | buf = buf[reclen:] 97 | n += reclen 98 | cnt++ 99 | } 100 | // Set the seek offset of the input fd to record 101 | // how many files we've already returned. 102 | _, err = Seek(fd, cnt, 0 /* SEEK_SET */) 103 | if err != nil { 104 | return n, err 105 | } 106 | 107 | return n, nil 108 | } 109 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && darwin 6 | // +build amd64,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: sec, Nsec: nsec} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: sec, Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint64(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 48 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 51 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && darwin 6 | // +build arm64,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: sec, Nsec: nsec} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: sec, Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint64(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 48 | //sys Lstat(path string, stat *Stat_t) (err error) 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) 51 | //sys Statfs(path string, stat *Statfs_t) (err error) 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && go1.12 6 | // +build darwin,go1.12 7 | 8 | package unix 9 | 10 | import _ "unsafe" 11 | 12 | // Implemented in the runtime package (runtime/sys_darwin.go) 13 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 16 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 17 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 18 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 19 | func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 20 | 21 | //go:linkname syscall_syscall syscall.syscall 22 | //go:linkname syscall_syscall6 syscall.syscall6 23 | //go:linkname syscall_syscall6X syscall.syscall6X 24 | //go:linkname syscall_syscall9 syscall.syscall9 25 | //go:linkname syscall_rawSyscall syscall.rawSyscall 26 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 27 | //go:linkname syscall_syscallPtr syscall.syscallPtr 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && dragonfly 6 | // +build amd64,dragonfly 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && freebsd 6 | // +build 386,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint32(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 60 | return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 61 | } 62 | 63 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 64 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} 65 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 66 | return int(ioDesc.Len), err 67 | } 68 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && freebsd 6 | // +build amd64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 60 | return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 61 | } 62 | 63 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 64 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} 65 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 66 | return int(ioDesc.Len), err 67 | } 68 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && freebsd 6 | // +build arm,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: int32(nsec)} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: int32(usec)} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint32(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} 61 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && freebsd 6 | // +build arm64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} 61 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_alarm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64) 6 | // +build linux 7 | // +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64 8 | 9 | package unix 10 | 11 | // SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH 12 | // values. 13 | 14 | //sys Alarm(seconds uint) (remaining uint, err error) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && linux && gc 6 | // +build amd64,linux,gc 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gc 6 | // +build linux,gc 7 | 8 | package unix 9 | 10 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 11 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 12 | 13 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 14 | // fail. 15 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gc && 386 6 | // +build linux,gc,386 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // Underlying system call writes to newoffset via pointer. 13 | // Implemented in assembly to avoid allocation. 14 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 15 | 16 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && gc && linux 6 | // +build arm,gc,linux 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // Underlying system call writes to newoffset via pointer. 13 | // Implemented in assembly to avoid allocation. 14 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gccgo && 386 6 | // +build linux,gccgo,386 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 16 | var newoffset int64 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | 23 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 24 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 25 | return int(fd), err 26 | } 27 | 28 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 29 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 30 | return int(fd), err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gccgo && arm 6 | // +build linux,gccgo,arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 16 | var newoffset int64 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && netbsd 6 | // +build 386,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && netbsd 6 | // +build amd64,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && netbsd 6 | // +build arm,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && netbsd 6 | // +build arm64,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && openbsd 6 | // +build 386,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && openbsd 6 | // +build amd64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && openbsd 6 | // +build arm,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && openbsd 6 | // +build arm64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_mips64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | func setTimespec(sec, nsec int64) Timespec { 8 | return Timespec{Sec: sec, Nsec: nsec} 9 | } 10 | 11 | func setTimeval(sec, usec int64) Timeval { 12 | return Timeval{Sec: sec, Usec: usec} 13 | } 14 | 15 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 16 | k.Ident = uint64(fd) 17 | k.Filter = int16(mode) 18 | k.Flags = uint16(flags) 19 | } 20 | 21 | func (iov *Iovec) SetLen(length int) { 22 | iov.Len = uint64(length) 23 | } 24 | 25 | func (msghdr *Msghdr) SetControllen(length int) { 26 | msghdr.Controllen = uint32(length) 27 | } 28 | 29 | func (cmsg *Cmsghdr) SetLen(length int) { 30 | cmsg.Len = uint32(length) 31 | } 32 | 33 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 34 | // of OpenBSD the syscall is called sysctl instead of __sysctl. 35 | const SYS___SYSCTL = SYS_SYSCTL 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && solaris 6 | // +build amd64,solaris 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func (iov *Iovec) SetLen(length int) { 19 | iov.Len = uint64(length) 20 | } 21 | 22 | func (msghdr *Msghdr) SetIovlen(length int) { 23 | msghdr.Iovlen = int32(length) 24 | } 25 | 26 | func (cmsg *Cmsghdr) SetLen(length int) { 27 | cmsg.Len = uint32(length) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) && gc && !ppc64le && !ppc64 6 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 7 | // +build gc 8 | // +build !ppc64le 9 | // +build !ppc64 10 | 11 | package unix 12 | 13 | import "syscall" 14 | 15 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 17 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 18 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (ppc64le || ppc64) && gc 6 | // +build linux 7 | // +build ppc64le ppc64 8 | // +build gc 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 15 | return syscall.Syscall(trap, a1, a2, a3) 16 | } 17 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 19 | } 20 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 21 | return syscall.RawSyscall(trap, a1, a2, a3) 22 | } 23 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 24 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux 6 | // +build linux 7 | 8 | package unix 9 | 10 | import "runtime" 11 | 12 | // SysvShmCtl performs control operations on the shared memory segment 13 | // specified by id. 14 | func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { 15 | if runtime.GOARCH == "arm" || 16 | runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" { 17 | cmd |= ipc_64 18 | } 19 | 20 | return shmctl(id, cmd, desc) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin && !ios) || linux 6 | // +build darwin,!ios linux 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | 13 | "golang.org/x/sys/internal/unsafeheader" 14 | ) 15 | 16 | // SysvShmAttach attaches the Sysv shared memory segment associated with the 17 | // shared memory identifier id. 18 | func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { 19 | addr, errno := shmat(id, addr, flag) 20 | if errno != nil { 21 | return nil, errno 22 | } 23 | 24 | // Retrieve the size of the shared memory to enable slice creation 25 | var info SysvShmDesc 26 | 27 | _, err := SysvShmCtl(id, IPC_STAT, &info) 28 | if err != nil { 29 | // release the shared memory if we can't find the size 30 | 31 | // ignoring error from shmdt as there's nothing sensible to return here 32 | shmdt(addr) 33 | return nil, err 34 | } 35 | 36 | // Use unsafe to convert addr into a []byte. 37 | // TODO: convert to unsafe.Slice once we can assume Go 1.17 38 | var b []byte 39 | hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b)) 40 | hdr.Data = unsafe.Pointer(addr) 41 | hdr.Cap = int(info.Segsz) 42 | hdr.Len = int(info.Segsz) 43 | return b, nil 44 | } 45 | 46 | // SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach. 47 | // 48 | // It is not safe to use the slice after calling this function. 49 | func SysvShmDetach(data []byte) error { 50 | if len(data) == 0 { 51 | return EINVAL 52 | } 53 | 54 | return shmdt(uintptr(unsafe.Pointer(&data[0]))) 55 | } 56 | 57 | // SysvShmGet returns the Sysv shared memory identifier associated with key. 58 | // If the IPC_CREAT flag is specified a new segment is created. 59 | func SysvShmGet(key, size, flag int) (id int, err error) { 60 | return shmget(key, size, flag) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_unix_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && !ios 6 | // +build darwin,!ios 7 | 8 | package unix 9 | 10 | // SysvShmCtl performs control operations on the shared memory segment 11 | // specified by id. 12 | func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { 13 | return shmctl(id, cmd, desc) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import "time" 11 | 12 | // TimespecToNSec returns the time stored in ts as nanoseconds. 13 | func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } 14 | 15 | // NsecToTimespec converts a number of nanoseconds into a Timespec. 16 | func NsecToTimespec(nsec int64) Timespec { 17 | sec := nsec / 1e9 18 | nsec = nsec % 1e9 19 | if nsec < 0 { 20 | nsec += 1e9 21 | sec-- 22 | } 23 | return setTimespec(sec, nsec) 24 | } 25 | 26 | // TimeToTimespec converts t into a Timespec. 27 | // On some 32-bit systems the range of valid Timespec values are smaller 28 | // than that of time.Time values. So if t is out of the valid range of 29 | // Timespec, it returns a zero Timespec and ERANGE. 30 | func TimeToTimespec(t time.Time) (Timespec, error) { 31 | sec := t.Unix() 32 | nsec := int64(t.Nanosecond()) 33 | ts := setTimespec(sec, nsec) 34 | 35 | // Currently all targets have either int32 or int64 for Timespec.Sec. 36 | // If there were a new target with floating point type for it, we have 37 | // to consider the rounding error. 38 | if int64(ts.Sec) != sec { 39 | return Timespec{}, ERANGE 40 | } 41 | return ts, nil 42 | } 43 | 44 | // TimevalToNsec returns the time stored in tv as nanoseconds. 45 | func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } 46 | 47 | // NsecToTimeval converts a number of nanoseconds into a Timeval. 48 | func NsecToTimeval(nsec int64) Timeval { 49 | nsec += 999 // round up to microsecond 50 | usec := nsec % 1e9 / 1e3 51 | sec := nsec / 1e9 52 | if usec < 0 { 53 | usec += 1e6 54 | sec-- 55 | } 56 | return setTimeval(sec, usec) 57 | } 58 | 59 | // Unix returns the time stored in ts as seconds plus nanoseconds. 60 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 61 | return int64(ts.Sec), int64(ts.Nsec) 62 | } 63 | 64 | // Unix returns the time stored in tv as seconds plus nanoseconds. 65 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 66 | return int64(tv.Sec), int64(tv.Usec) * 1000 67 | } 68 | 69 | // Nano returns the time stored in ts as nanoseconds. 70 | func (ts *Timespec) Nano() int64 { 71 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 72 | } 73 | 74 | // Nano returns the time stored in tv as nanoseconds. 75 | func (tv *Timeval) Nano() int64 { 76 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/unveil_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Unveil implements the unveil syscall. 13 | // For more information see unveil(2). 14 | // Note that the special case of blocking further 15 | // unveil calls is handled by UnveilBlock. 16 | func Unveil(path string, flags string) error { 17 | pathPtr, err := syscall.BytePtrFromString(path) 18 | if err != nil { 19 | return err 20 | } 21 | flagsPtr, err := syscall.BytePtrFromString(flags) 22 | if err != nil { 23 | return err 24 | } 25 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) 26 | if e != 0 { 27 | return e 28 | } 29 | return nil 30 | } 31 | 32 | // UnveilBlock blocks future unveil calls. 33 | // For more information see unveil(2). 34 | func UnveilBlock() error { 35 | // Both pointers must be nil. 36 | var pathUnsafe, flagsUnsafe unsafe.Pointer 37 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) 38 | if e != 0 { 39 | return e 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("arm", "arm64"). DO NOT EDIT. 2 | 3 | //go:build linux && (arm || arm64) 4 | // +build linux 5 | // +build arm arm64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsArm is the registers used by arm binaries. 12 | type PtraceRegsArm struct { 13 | Uregs [18]uint32 14 | } 15 | 16 | // PtraceGetRegsArm fetches the registers used by arm binaries. 17 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 18 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 19 | } 20 | 21 | // PtraceSetRegsArm sets the registers used by arm binaries. 22 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 23 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 24 | } 25 | 26 | // PtraceRegsArm64 is the registers used by arm64 binaries. 27 | type PtraceRegsArm64 struct { 28 | Regs [31]uint64 29 | Sp uint64 30 | Pc uint64 31 | Pstate uint64 32 | } 33 | 34 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 35 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 36 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 37 | } 38 | 39 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 40 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 41 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtraceRegSet("arm64"). DO NOT EDIT. 2 | 3 | package unix 4 | 5 | import "unsafe" 6 | 7 | // PtraceGetRegSetArm64 fetches the registers used by arm64 binaries. 8 | func PtraceGetRegSetArm64(pid, addr int, regsout *PtraceRegsArm64) error { 9 | iovec := Iovec{(*byte)(unsafe.Pointer(regsout)), uint64(unsafe.Sizeof(*regsout))} 10 | return ptrace(PTRACE_GETREGSET, pid, uintptr(addr), uintptr(unsafe.Pointer(&iovec))) 11 | } 12 | 13 | // PtraceSetRegSetArm64 sets the registers used by arm64 binaries. 14 | func PtraceSetRegSetArm64(pid, addr int, regs *PtraceRegsArm64) error { 15 | iovec := Iovec{(*byte)(unsafe.Pointer(regs)), uint64(unsafe.Sizeof(*regs))} 16 | return ptrace(PTRACE_SETREGSET, pid, uintptr(addr), uintptr(unsafe.Pointer(&iovec))) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("mips", "mips64"). DO NOT EDIT. 2 | 3 | //go:build linux && (mips || mips64) 4 | // +build linux 5 | // +build mips mips64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsMips is the registers used by mips binaries. 12 | type PtraceRegsMips struct { 13 | Regs [32]uint64 14 | Lo uint64 15 | Hi uint64 16 | Epc uint64 17 | Badvaddr uint64 18 | Status uint64 19 | Cause uint64 20 | } 21 | 22 | // PtraceGetRegsMips fetches the registers used by mips binaries. 23 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 24 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 25 | } 26 | 27 | // PtraceSetRegsMips sets the registers used by mips binaries. 28 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 29 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 30 | } 31 | 32 | // PtraceRegsMips64 is the registers used by mips64 binaries. 33 | type PtraceRegsMips64 struct { 34 | Regs [32]uint64 35 | Lo uint64 36 | Hi uint64 37 | Epc uint64 38 | Badvaddr uint64 39 | Status uint64 40 | Cause uint64 41 | } 42 | 43 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 44 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 45 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 46 | } 47 | 48 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 49 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 50 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("mipsle", "mips64le"). DO NOT EDIT. 2 | 3 | //go:build linux && (mipsle || mips64le) 4 | // +build linux 5 | // +build mipsle mips64le 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsMipsle is the registers used by mipsle binaries. 12 | type PtraceRegsMipsle struct { 13 | Regs [32]uint64 14 | Lo uint64 15 | Hi uint64 16 | Epc uint64 17 | Badvaddr uint64 18 | Status uint64 19 | Cause uint64 20 | } 21 | 22 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 23 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 24 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 25 | } 26 | 27 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 28 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 29 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 30 | } 31 | 32 | // PtraceRegsMips64le is the registers used by mips64le binaries. 33 | type PtraceRegsMips64le struct { 34 | Regs [32]uint64 35 | Lo uint64 36 | Hi uint64 37 | Epc uint64 38 | Badvaddr uint64 39 | Status uint64 40 | Cause uint64 41 | } 42 | 43 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 44 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 45 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 46 | } 47 | 48 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 49 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 50 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_x86_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("386", "amd64"). DO NOT EDIT. 2 | 3 | //go:build linux && (386 || amd64) 4 | // +build linux 5 | // +build 386 amd64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegs386 is the registers used by 386 binaries. 12 | type PtraceRegs386 struct { 13 | Ebx int32 14 | Ecx int32 15 | Edx int32 16 | Esi int32 17 | Edi int32 18 | Ebp int32 19 | Eax int32 20 | Xds int32 21 | Xes int32 22 | Xfs int32 23 | Xgs int32 24 | Orig_eax int32 25 | Eip int32 26 | Xcs int32 27 | Eflags int32 28 | Esp int32 29 | Xss int32 30 | } 31 | 32 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 33 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 34 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 35 | } 36 | 37 | // PtraceSetRegs386 sets the registers used by 386 binaries. 38 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 39 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 40 | } 41 | 42 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 43 | type PtraceRegsAmd64 struct { 44 | R15 uint64 45 | R14 uint64 46 | R13 uint64 47 | R12 uint64 48 | Rbp uint64 49 | Rbx uint64 50 | R11 uint64 51 | R10 uint64 52 | R9 uint64 53 | R8 uint64 54 | Rax uint64 55 | Rcx uint64 56 | Rdx uint64 57 | Rsi uint64 58 | Rdi uint64 59 | Orig_rax uint64 60 | Rip uint64 61 | Cs uint64 62 | Eflags uint64 63 | Rsp uint64 64 | Ss uint64 65 | Fs_base uint64 66 | Gs_base uint64 67 | Ds uint64 68 | Es uint64 69 | Fs uint64 70 | Gs uint64 71 | } 72 | 73 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 74 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 75 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 76 | } 77 | 78 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 79 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 80 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall.go -tags darwin,amd64,go1.13 syscall_darwin.1_13.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build darwin && amd64 && go1.13 5 | // +build darwin,amd64,go1.13 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var _ syscall.Errno 15 | 16 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 17 | 18 | func closedir(dir uintptr) (err error) { 19 | _, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0) 20 | if e1 != 0 { 21 | err = errnoErr(e1) 22 | } 23 | return 24 | } 25 | 26 | var libc_closedir_trampoline_addr uintptr 27 | 28 | //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" 29 | 30 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 31 | 32 | func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { 33 | r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) 34 | res = Errno(r0) 35 | return 36 | } 37 | 38 | var libc_readdir_r_trampoline_addr uintptr 39 | 40 | //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go amd64 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | //go:build go1.13 5 | // +build go1.13 6 | 7 | #include "textflag.h" 8 | 9 | TEXT libc_fdopendir_trampoline<>(SB),NOSPLIT,$0-0 10 | JMP libc_fdopendir(SB) 11 | 12 | GLOBL ·libc_fdopendir_trampoline_addr(SB), RODATA, $8 13 | DATA ·libc_fdopendir_trampoline_addr(SB)/8, $libc_fdopendir_trampoline<>(SB) 14 | 15 | TEXT libc_closedir_trampoline<>(SB),NOSPLIT,$0-0 16 | JMP libc_closedir(SB) 17 | 18 | GLOBL ·libc_closedir_trampoline_addr(SB), RODATA, $8 19 | DATA ·libc_closedir_trampoline_addr(SB)/8, $libc_closedir_trampoline<>(SB) 20 | 21 | TEXT libc_readdir_r_trampoline<>(SB),NOSPLIT,$0-0 22 | JMP libc_readdir_r(SB) 23 | 24 | GLOBL ·libc_readdir_r_trampoline_addr(SB), RODATA, $8 25 | DATA ·libc_readdir_r_trampoline_addr(SB)/8, $libc_readdir_r_trampoline<>(SB) 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall.go -tags darwin,arm64,go1.13 syscall_darwin.1_13.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build darwin && arm64 && go1.13 5 | // +build darwin,arm64,go1.13 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var _ syscall.Errno 15 | 16 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 17 | 18 | func closedir(dir uintptr) (err error) { 19 | _, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0) 20 | if e1 != 0 { 21 | err = errnoErr(e1) 22 | } 23 | return 24 | } 25 | 26 | var libc_closedir_trampoline_addr uintptr 27 | 28 | //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" 29 | 30 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 31 | 32 | func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { 33 | r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) 34 | res = Errno(r0) 35 | return 36 | } 37 | 38 | var libc_readdir_r_trampoline_addr uintptr 39 | 40 | //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go arm64 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | //go:build go1.13 5 | // +build go1.13 6 | 7 | #include "textflag.h" 8 | 9 | TEXT libc_fdopendir_trampoline<>(SB),NOSPLIT,$0-0 10 | JMP libc_fdopendir(SB) 11 | 12 | GLOBL ·libc_fdopendir_trampoline_addr(SB), RODATA, $8 13 | DATA ·libc_fdopendir_trampoline_addr(SB)/8, $libc_fdopendir_trampoline<>(SB) 14 | 15 | TEXT libc_closedir_trampoline<>(SB),NOSPLIT,$0-0 16 | JMP libc_closedir(SB) 17 | 18 | GLOBL ·libc_closedir_trampoline_addr(SB), RODATA, $8 19 | DATA ·libc_closedir_trampoline_addr(SB)/8, $libc_closedir_trampoline<>(SB) 20 | 21 | TEXT libc_readdir_r_trampoline<>(SB),NOSPLIT,$0-0 22 | JMP libc_readdir_r(SB) 23 | 24 | GLOBL ·libc_readdir_r_trampoline_addr(SB), RODATA, $8 25 | DATA ·libc_readdir_r_trampoline_addr(SB)/8, $libc_readdir_r_trampoline<>(SB) 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go: -------------------------------------------------------------------------------- 1 | // cgo -godefs types_illumos.go | go run mkpost.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build amd64 && illumos 5 | // +build amd64,illumos 6 | 7 | package unix 8 | 9 | const ( 10 | TUNNEWPPA = 0x540001 11 | TUNSETPPA = 0x540002 12 | 13 | I_STR = 0x5308 14 | I_POP = 0x5303 15 | I_PUSH = 0x5302 16 | I_LINK = 0x530c 17 | I_UNLINK = 0x530d 18 | I_PLINK = 0x5316 19 | I_PUNLINK = 0x5317 20 | 21 | IF_UNITSEL = -0x7ffb8cca 22 | ) 23 | 24 | type strbuf struct { 25 | Maxlen int32 26 | Len int32 27 | Buf *int8 28 | } 29 | 30 | type Strioctl struct { 31 | Cmd int32 32 | Timout int32 33 | Len int32 34 | Dp *int8 35 | } 36 | 37 | type Lifreq struct { 38 | Name [32]int8 39 | Lifru1 [4]byte 40 | Type uint32 41 | Lifru [336]byte 42 | } 43 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/cilium/ebpf v0.8.1 2 | ## explicit; go 1.16 3 | github.com/cilium/ebpf 4 | github.com/cilium/ebpf/asm 5 | github.com/cilium/ebpf/features 6 | github.com/cilium/ebpf/internal 7 | github.com/cilium/ebpf/internal/btf 8 | github.com/cilium/ebpf/internal/epoll 9 | github.com/cilium/ebpf/internal/sys 10 | github.com/cilium/ebpf/internal/unix 11 | github.com/cilium/ebpf/link 12 | github.com/cilium/ebpf/perf 13 | # golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 14 | ## explicit; go 1.17 15 | golang.org/x/sys/internal/unsafeheader 16 | golang.org/x/sys/unix 17 | --------------------------------------------------------------------------------