summaryrefslogtreecommitdiff
path: root/samples/kmsg
diff options
context:
space:
mode:
Diffstat (limited to 'samples/kmsg')
-rw-r--r--samples/kmsg/kmsg-api.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/samples/kmsg/kmsg-api.h b/samples/kmsg/kmsg-api.h
new file mode 100644
index 000000000000..9004acdc526d
--- /dev/null
+++ b/samples/kmsg/kmsg-api.h
@@ -0,0 +1,44 @@
+#ifndef KMSG_API_H
+#define KMSG_API_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <linux/kmsg_ioctl.h>
+
+static inline int kmsg_cmd_buffer_add(int fd, struct kmsg_cmd_buffer_add *cmd)
+{
+ int ret = ioctl(fd, KMSG_CMD_BUFFER_ADD, cmd);
+
+ return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0;
+}
+
+static inline int kmsg_cmd_buffer_del(int fd, int *minor)
+{
+ int ret = ioctl(fd, KMSG_CMD_BUFFER_DEL, minor);
+
+ return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0;
+}
+
+static inline int kmsg_cmd_get_buf_size(int fd, uint32_t *size)
+{
+ int ret = ioctl(fd, KMSG_CMD_GET_BUF_SIZE, size);
+
+ return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0;
+}
+
+static inline int kmsg_cmd_get_read_size_max(int fd, uint32_t *max_size)
+{
+ int ret = ioctl(fd, KMSG_CMD_GET_READ_SIZE_MAX, max_size);
+
+ return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0;
+}
+
+static inline int kmsg_cmd_clear(int fd)
+{
+ int ret = ioctl(fd, KMSG_CMD_CLEAR);
+
+ return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0;
+}
+
+#endif /* KMSG_API_H */