1 .TH "seccomp_export_bpf" 3 "25 July 2012" "paul@paul-moore.com" "libseccomp Documentation"
2 .\" //////////////////////////////////////////////////////////////////////////
4 .\" //////////////////////////////////////////////////////////////////////////
5 seccomp_export_bpf, seccomp_export_pfc \- Export the seccomp filter
6 .\" //////////////////////////////////////////////////////////////////////////
8 .\" //////////////////////////////////////////////////////////////////////////
10 .B #include <seccomp.h>
12 .B typedef void * scmp_filter_ctx;
14 .BI "int seccomp_export_bpf(const scmp_filter_ctx " ctx ", int " fd ");"
15 .BI "int seccomp_export_pfc(const scmp_filter_ctx " ctx ", int " fd ");"
17 Link with \fI\-lseccomp\fP.
19 .\" //////////////////////////////////////////////////////////////////////////
21 .\" //////////////////////////////////////////////////////////////////////////
24 .BR seccomp_export_bpf ()
26 .BR seccomp_export_pfc ()
27 functions generate and output the current seccomp filter in either BPF (Berkley
28 Packet Filter) or PFC (Pseudo Filter Code). The output of
29 .BR seccomp_export_bpf ()
30 is suitable for loading into the kernel, while the output of
31 .BR seccomp_export_pfc ()
32 is human readable and is intended primarily as a debugging tool for developers
33 using libseccomp. Both functions write the filter to the
39 is the value returned by the call to
42 While the two output formats are guaranteed to be functionally equivalent for
43 the given seccomp filter configuration, the filter instructions, and their
44 ordering, are not guaranteed to be the same in both the BPF and PFC formats.
45 .\" //////////////////////////////////////////////////////////////////////////
47 .\" //////////////////////////////////////////////////////////////////////////
48 Returns zero on success, negative errno values on failure.
49 .\" //////////////////////////////////////////////////////////////////////////
51 .\" //////////////////////////////////////////////////////////////////////////
55 int main(int argc, char *argv[])
61 ctx = seccomp_init(SCMP_ACT_KILL);
67 filter_fd = open("/tmp/seccomp_filter.bpf", O_WRONLY);
68 if (filter_fd == \-1) {
73 rc = seccomp_export_bpf(ctx, filter_fd);
87 .\" //////////////////////////////////////////////////////////////////////////
89 .\" //////////////////////////////////////////////////////////////////////////
91 While the seccomp filter can be generated independent of the kernel, kernel
92 support is required to load and enforce the seccomp filter generated by
95 The libseccomp project site, with more information and the source code
96 repository, can be found at https://github.com/seccomp/libseccomp. This tool,
97 as well as the libseccomp library, is currently under development, please
98 report any bugs at the project site or directly to the author.
99 .\" //////////////////////////////////////////////////////////////////////////
101 .\" //////////////////////////////////////////////////////////////////////////
102 Paul Moore <paul@paul-moore.com>
103 .\" //////////////////////////////////////////////////////////////////////////
105 .\" //////////////////////////////////////////////////////////////////////////
106 .BR seccomp_init (3),
107 .BR seccomp_release (3)