aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorJorge Lucangeli Obes <jorgelo@chromium.org>2012-08-07 15:29:20 -0700
committerGerrit <chrome-bot@google.com>2012-08-08 15:35:29 -0700
commita6b034dedfb1109adcd88eb1bcea15a29067824c (patch)
tree3a622455dbd0d057415214ed8f9a0f32ca139f8b /util.h
parent224e4275abc940fa96d8cf8eec69a052957aa7e1 (diff)
downloadminijail-a6b034dedfb1109adcd88eb1bcea15a29067824c.tar.gz
Minijail: extract utility functions.
Extract utility functions and add them, together with logging, to a separate util.(c|h) file. BUG=chromium-os:33361 TEST=unit tests TEST=security_Minijail0, security_Minijail_seccomp, platform_CrosDisksArchive. Change-Id: Ied436a7b27f14ef87198b7bf007634b28cbbd480 Reviewed-on: https://gerrit.chromium.org/gerrit/29492 Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org> Reviewed-by: Elly Jones <ellyjones@chromium.org> Reviewed-by: Kees Cook <keescook@chromium.org> Commit-Ready: Jorge Lucangeli Obes <jorgelo@chromium.org>
Diffstat (limited to 'util.h')
-rw-r--r--util.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/util.h b/util.h
new file mode 100644
index 0000000..8f0fa7b
--- /dev/null
+++ b/util.h
@@ -0,0 +1,33 @@
+/* util.h
+ * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Logging and other utility functions.
+ */
+
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#include <stdlib.h>
+#include <syslog.h>
+
+#define die(_msg, ...) do { \
+ syslog(LOG_ERR, "libminijail: " _msg, ## __VA_ARGS__); \
+ abort(); \
+} while (0)
+
+#define pdie(_msg, ...) \
+ die(_msg ": %s", ## __VA_ARGS__, strerror(errno))
+
+#define warn(_msg, ...) \
+ syslog(LOG_WARNING, "libminijail: " _msg, ## __VA_ARGS__)
+
+#define info(_msg, ...) \
+ syslog(LOG_INFO, "libminijail: " _msg, ## __VA_ARGS__)
+
+int lookup_syscall(const char *name);
+const char *lookup_syscall_name(int nr);
+char *strip(char *s);
+
+#endif /* _UTIL_H_ */