fn install()

in reverie-process/src/seccomp/bpf.rs [133:159]


    fn install(&self, flags: FilterFlags) -> Result<i32, Errno> {
        let len = self.filter.len();

        if len == 0 || len > BPF_MAXINSNS {
            return Err(Errno::EINVAL);
        }

        let prog = libc::sock_fprog {
            // Note: length is guaranteed to be less than `u16::MAX` because of
            // the above check.
            len: len as u16,
            filter: self.filter.as_ptr() as *mut _,
        };

        let ptr = &prog as *const libc::sock_fprog;

        let value = Errno::result(unsafe {
            libc::syscall(
                libc::SYS_seccomp,
                SECCOMP_SET_MODE_FILTER,
                flags.bits(),
                ptr,
            )
        })?;

        Ok(value as i32)
    }