1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "seccomp-util.h"
27 const char* seccomp_arch_to_string(uint32_t c) {
29 if (c == SCMP_ARCH_NATIVE)
31 if (c == SCMP_ARCH_X86)
33 if (c == SCMP_ARCH_X86_64)
35 if (c == SCMP_ARCH_X32)
37 if (c == SCMP_ARCH_ARM)
43 int seccomp_arch_from_string(const char *n, uint32_t *ret) {
49 if (streq(n, "native"))
50 *ret = SCMP_ARCH_NATIVE;
51 else if (streq(n, "x86"))
53 else if (streq(n, "x86-64"))
54 *ret = SCMP_ARCH_X86_64;
55 else if (streq(n, "x32"))
57 else if (streq(n, "arm"))
65 int seccomp_add_secondary_archs(scmp_filter_ctx *c) {
67 #if defined(__i386__) || defined(__x86_64__)
70 /* Add in all possible secondary archs we are aware of that
71 * this kernel might support. */
73 r = seccomp_arch_add(c, SCMP_ARCH_X86);
74 if (r < 0 && r != -EEXIST)
77 r = seccomp_arch_add(c, SCMP_ARCH_X86_64);
78 if (r < 0 && r != -EEXIST)
81 r = seccomp_arch_add(c, SCMP_ARCH_X32);
82 if (r < 0 && r != -EEXIST)