]>
Commit | Line | Data |
---|---|---|
8351ceae LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2012 Lennart Poettering | |
7 | ||
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. | |
12 | ||
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. | |
17 | ||
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/>. | |
20 | ***/ | |
21 | ||
22 | #include <sys/syscall.h> | |
23 | #include <string.h> | |
24 | ||
25 | #include "util.h" | |
26 | ||
27 | #include "syscall-list.h" | |
28 | ||
131c01db ZJS |
29 | static const struct syscall_name* lookup_syscall(register const char *str, |
30 | register unsigned int len); | |
8351ceae LP |
31 | |
32 | #include "syscall-to-name.h" | |
33 | #include "syscall-from-name.h" | |
34 | ||
35 | const char *syscall_to_name(int id) { | |
843fc7f7 | 36 | id = SYSCALL_TO_INDEX(id); |
8351ceae LP |
37 | if (id < 0 || id >= (int) ELEMENTSOF(syscall_names)) |
38 | return NULL; | |
39 | ||
40 | return syscall_names[id]; | |
41 | } | |
42 | ||
43 | int syscall_from_name(const char *name) { | |
44 | const struct syscall_name *sc; | |
45 | ||
46 | assert(name); | |
47 | ||
48 | sc = lookup_syscall(name, strlen(name)); | |
49 | if (!sc) | |
50 | return -1; | |
51 | ||
52 | return sc->id; | |
53 | } | |
54 | ||
55 | int syscall_max(void) { | |
56 | return ELEMENTSOF(syscall_names); | |
57 | } |