1/* Copyright 2016 The Chromium OS Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6#include <stdio.h> 7 8#include "bpf.h" 9#include "syscall_filter.h" 10#include "util.h" 11 12/* TODO(jorgelo): Use libseccomp disassembler here. */ 13int main(int argc, char **argv) { 14 init_logging(LOG_TO_FD, STDERR_FILENO, LOG_INFO); 15 16 if (argc < 2) { 17 fprintf(stderr, "Usage: %s <policy file>\n", argv[0]); 18 return 1; 19 } 20 21 FILE *f = fopen(argv[1], "r"); 22 if (!f) { 23 pdie("fopen(%s) failed", argv[1]); 24 } 25 26 struct sock_fprog fp; 27 int res = compile_filter(argv[1], f, &fp, 0, 0); 28 if (res != 0) { 29 die("compile_filter failed"); 30 } 31 dump_bpf_prog(&fp); 32 33 free(fp.filter); 34 fclose(f); 35 return 0; 36} 37