mirror of
https://github.com/criyle/go-sandbox.git
synced 2025-11-04 14:49:53 +08:00
23 lines
449 B
Go
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])),
|
|
}
|
|
}
|