go-sandbox/pkg/seccomp/filter.go
2019-09-01 01:36:01 -07:00

23 lines
449 B
Go

// Package seccomp provides a generated filter format for seccomp filter
// +build linux
package seccomp
import (
"syscall"
"unsafe"
)
// Filter is the BPF seccomp filter value
type Filter []byte
// SockFprog converts Filter to SockFprog for seccomp syscall
func (f Filter) SockFprog() *syscall.SockFprog {
b := []byte(f)
return &syscall.SockFprog{
Len: uint16(len(b) / 8),
Filter: (*syscall.SockFilter)(unsafe.Pointer(&b[0])),
}
}