util: move parse_syscall_and_errno() to seccomp-util.c
This makes parse-util.c independent of seccomp-util.c, which is located in src/shared.
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
#include "missing_network.h"
|
||||
#include "parse-util.h"
|
||||
#include "process-util.h"
|
||||
#if HAVE_SECCOMP
|
||||
#include "seccomp-util.h"
|
||||
#endif
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@@ -317,46 +314,6 @@ int parse_errno(const char *t) {
|
||||
return e;
|
||||
}
|
||||
|
||||
#if HAVE_SECCOMP
|
||||
int parse_syscall_and_errno(const char *in, char **name, int *error) {
|
||||
_cleanup_free_ char *n = NULL;
|
||||
char *p;
|
||||
int e = -1;
|
||||
|
||||
assert(in);
|
||||
assert(name);
|
||||
assert(error);
|
||||
|
||||
/*
|
||||
* This parse "syscall:errno" like "uname:EILSEQ", "@sync:255".
|
||||
* If errno is omitted, then error is set to -1.
|
||||
* Empty syscall name is not allowed.
|
||||
* Here, we do not check that the syscall name is valid or not.
|
||||
*/
|
||||
|
||||
p = strchr(in, ':');
|
||||
if (p) {
|
||||
e = seccomp_parse_errno_or_action(p + 1);
|
||||
if (e < 0)
|
||||
return e;
|
||||
|
||||
n = strndup(in, p - in);
|
||||
} else
|
||||
n = strdup(in);
|
||||
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
|
||||
if (isempty(n))
|
||||
return -EINVAL;
|
||||
|
||||
*error = e;
|
||||
*name = TAKE_PTR(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *mangle_base(const char *s, unsigned *base) {
|
||||
const char *k;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user