#include <linux/logger.h>
#include <logconfig.h>
#include <logpipe.h>
+#include <zero_copy_backend.h>
#include <stdint.h>
return 0;
}
+static int apply_zero_copy_ioctl(int fd, const char *tag, log_priority prio)
+{
+ int r = ioctl(fd, ZLOGGER_IOCTL_COMMAND_SET_DEFAULT_PRIORITY, (uint32_t)prio);
+ if (r < 0)
+ return -errno;
+
+ r = ioctl(fd, ZLOGGER_IOCTL_COMMAND_SET_DEFAULT_TAG, tag);
+ if (r < 0)
+ return -errno;
+
+ return 0;
+}
+
static int setup_single_zero_copy(log_id_t buffer, const char *tag, log_priority prio, struct log_config *config, int *fd)
{
- return -ENOTSUP;
+ *fd = open(ZERO_COPY_DEVICE_NAME, O_WRONLY);
+ if (*fd < 0)
+ return -errno;
+
+ int r = apply_zero_copy_ioctl(*fd, tag, prio);
+ if (r < 0)
+ return r;
+
+ return 0;
}
int setup_single_unstructed(log_id_t buffer, const char *tag, log_priority prio, int *fd)