emlog: Add recipe

Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Fabio Berton 2019-11-27 10:03:05 -03:00 committed by Khem Raj
parent 36e9b8f5b9
commit 027c7c1ebf
5 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,13 @@
DESCRIPTION = "emlog is a Linux kernel module that makes it easy to access the \
most recent (and only the most recent) output from a process"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
SRC_URI = "git://github.com/nicupavel/emlog.git;protocol=http"
SRCREV = "aee53e8dee862f35291242ba41b0ca88010f6c71"
S = "${WORKDIR}/git"
EXTRA_OEMAKE += " \
CFLAGS='${TARGET_CFLAGS}' \
"

View File

@ -0,0 +1,113 @@
From 41de28a92297f4cb0c5a8d7356cde9190176947b Mon Sep 17 00:00:00 2001
From: Fabio Berton <fabio.berton@ossystems.com.br>
Date: Thu, 14 Mar 2019 19:54:27 -0300
Subject: [PATCH] Drop use of error.h
Organization: O.S. Systems Software LTDA.
The error.h does not work with musl and this project being embedded
friendly it makes sense to avoid glibc-specific code.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
---
mkemlog.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/mkemlog.c b/mkemlog.c
index e3354ed..7bcdfce 100644
--- a/mkemlog.c
+++ b/mkemlog.c
@@ -21,7 +21,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
-#include <error.h>
#include <errno.h>
#define EMLOG_DEVICE "/dev/emlog"
@@ -40,16 +39,16 @@ int main(int argc, char** argv) {
FILE *max_size_file = NULL;
uid_t uid = -1;
if (argc < 2 || argc > 5) {
- error(1 ,0, USAGE);
+ fprintf(stderr, USAGE);
}
file = argv[1];
max_size_file = fopen("/sys/module/emlog/parameters/emlog_max_size", "r");
if (max_size_file == NULL)
- error(1, errno, "Emlog module not loaded\n");
+ fprintf(stderr, "Emlog module not loaded\n");
rc = fscanf(max_size_file, "%d", &emlog_max_size);
if (rc != 1)
- error(1, errno, "Unable to get emlog max size\n");
+ fprintf(stderr, "Unable to get emlog max size\n");
fclose(max_size_file);
max_size_file = NULL;
if (argc > 2 ) {
@@ -57,13 +56,13 @@ int main(int argc, char** argv) {
number = argv[2];
size_of_buffer = strtol(number, &end_of_number, 10);
if (errno) {
- error(1, errno, "Invalid size provided\n" USAGE);
+ fprintf(stderr, "Invalid size provided\n" USAGE);
}
if (end_of_number == number) {
- error(1, 0, "Invalid size provided\n" USAGE);
+ fprintf(stderr, "Invalid size provided\n" USAGE);
}
if (size_of_buffer < 1 || size_of_buffer > emlog_max_size) {
- error(1, 0, "Invalid size provided must be a value between 1 and %d\n" USAGE, emlog_max_size);
+ fprintf(stderr, "Invalid size provided must be a value between 1 and %d\n" USAGE, emlog_max_size);
}
}
if (argc > 3 ) {
@@ -71,10 +70,10 @@ int main(int argc, char** argv) {
number = argv[3];
mode = strtol(number, &end_of_number, 8);
if (errno) {
- error(1, errno, "Invalid mode provided\n" USAGE);
+ fprintf(stderr, "Invalid mode provided\n" USAGE);
}
if (end_of_number == number || S_IFMT & mode) {
- error(1, 0, "Invalid mode provided\n" USAGE);
+ fprintf(stderr, "Invalid mode provided\n" USAGE);
}
}
if (argc > 4 ) {
@@ -82,27 +81,27 @@ int main(int argc, char** argv) {
number = argv[4];
uid = strtol(number, &end_of_number, 10);
if (errno) {
- error(1, errno, "Invalid uid provided\n" USAGE);
+ fprintf(stderr, "Invalid uid provided\n" USAGE);
}
if (end_of_number == number) {
- error(1, 0, "Invalid uid provided\n" USAGE);
+ fprintf(stderr, "Invalid uid provided\n" USAGE);
}
}
rc = stat(EMLOG_DEVICE, &emlog_stat);
if (rc == -1) {
- error(1, errno, "stat: " EMLOG_DEVICE);
+ fprintf(stderr, "stat: " EMLOG_DEVICE);
}
if (!S_ISCHR(emlog_stat.st_mode)) {
- error(1, 0, EMLOG_DEVICE " is not a valid emlog device\n");
+ fprintf(stderr, EMLOG_DEVICE " is not a valid emlog device\n");
}
rc = mknod(file, mode | S_IFCHR, makedev(major(emlog_stat.st_rdev),size_of_buffer));
if (rc == -1) {
- error(1, errno, "mknod: %s", file);
+ fprintf(stderr, "mknod: %s", file);
}
if (uid != -1) {
rc = chown(file, uid, -1);
if (rc == -1) {
- error(1, errno, "chown: %s", file);
+ fprintf(stderr, "chown: %s", file);
}
}
printf("Log device %s created with buffer size of %d KiB\n", file, size_of_buffer);
--
2.20.1

View File

@ -0,0 +1,25 @@
#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin
[ -r /etc/default/emlog ] && . /etc/default/emlog
do_start() {
:
}
do_stop() {
nbcat /dev/emlog > /data/emlog
}
case "$1" in
start)
do_start || exit $?
;;
stop)
do_stop || exit $?
;;
*)
echo "Usage: $0 {stop}" >&2
exit 3
;;
esac

View File

@ -0,0 +1,22 @@
require ${BPN}.inc
SRC_URI += "file://${BPN}.initd"
SRC_URI_append_libc-musl = " file://Drop-use-of-error-h.patch"
inherit update-rc.d
INITSCRIPT_NAME = "${BPN}"
do_compile() {
oe_runmake nbcat
oe_runmake mkemlog
}
do_install() {
install -Dm 0755 ${WORKDIR}/${BPN}.initd ${D}${sysconfdir}/init.d/${BPN}
install -Dm 0755 ${S}/nbcat ${D}${bindir}/nbcat
install -Dm 0755 ${S}/mkemlog ${D}${bindir}/mkemlog
}
RDEPENDS_${PN} += "kernel-module-emlog"

View File

@ -0,0 +1,12 @@
require emlog.inc
inherit module
EXTRA_OEMAKE += " \
KDIR=${STAGING_KERNEL_DIR} \
KVER=${KERNEL_VERSION} \
"
do_compile() {
oe_runmake modules
}