summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2014-05-09 09:24:20 -0400
committerPaul Moore <pmoore@redhat.com>2014-05-09 09:54:43 -0400
commit8139f5f7b71044fe21969e944d162e9e98c6e5eb (patch)
treefc115d79eebaaa833c66cc59fce081f30bbc9d30 /tools
parent7eb16b2bfa9dfd42226b84f171a26afb290a9c0d (diff)
downloadlibseccomp-8139f5f7b71044fe21969e944d162e9e98c6e5eb.tar.gz
tools: convert the tools over to the public APIs
Signed-off-by: Paul Moore <pmoore@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/scmp_sys_resolver.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/tools/scmp_sys_resolver.c b/tools/scmp_sys_resolver.c
index 58b47bd..58a1625 100644
--- a/tools/scmp_sys_resolver.c
+++ b/tools/scmp_sys_resolver.c
@@ -26,12 +26,7 @@
#include <string.h>
#include <unistd.h>
-#include "../src/arch.h"
-#include "../src/arch-x86.h"
-#include "../src/arch-x86_64.h"
-#include "../src/arch-x32.h"
-#include "../src/arch-arm.h"
-#include "../src/arch-mips.h"
+#include <seccomp.h>
/**
* Print the usage information to stderr and exit
@@ -55,27 +50,18 @@ int main(int argc, char *argv[])
{
int opt;
int translate = 0;
- const struct arch_def *arch = arch_def_native;
+ uint32_t arch;
int sys_num;
const char *sys_name;
+ arch = seccomp_arch_native();
+
/* parse the command line */
while ((opt = getopt(argc, argv, "a:ht")) > 0) {
switch (opt) {
case 'a':
- if (strcmp(optarg, "x86") == 0)
- arch = &arch_def_x86;
- else if (strcmp(optarg, "x86_64") == 0)
- arch = &arch_def_x86_64;
- else if (strcmp(optarg, "x32") == 0)
- arch = &arch_def_x32;
- else if (strcmp(optarg, "arm") == 0)
- arch = &arch_def_arm;
- else if (strcmp(optarg, "mips") == 0)
- arch = &arch_def_mips;
- else if (strcmp(optarg, "mipsel") == 0)
- arch = &arch_def_mipsel;
- else
+ arch = seccomp_arch_resolve_name(optarg);
+ if (arch == 0)
exit_usage(argv[0]);
break;
case 't':
@@ -95,13 +81,14 @@ int main(int argc, char *argv[])
/* perform the syscall lookup */
if (isdigit(argv[optind][0]) || argv[optind][0] == '-') {
sys_num = atoi(argv[optind]);
- sys_name = arch_syscall_resolve_num(arch, sys_num);
+ sys_name = seccomp_syscall_resolve_num_arch(arch, sys_num);
printf("%s\n", (sys_name ? sys_name : "UNKNOWN"));
+ } else if (translate) {
+ sys_num = seccomp_syscall_resolve_name_rewrite(arch,
+ argv[optind]);
+ printf("%d\n", sys_num);
} else {
- sys_num = arch_syscall_resolve_name(arch, argv[optind]);
- if (translate != 0)
- /* ignore errors and just output the resolved number */
- arch_syscall_rewrite(arch, 0, &sys_num);
+ sys_num = seccomp_syscall_resolve_name_arch(arch, argv[optind]);
printf("%d\n", sys_num);
}