ledmon: control hard disk led for RAID arrays
PATCH v2 1/1 ledmon: control hard disk led for RAID arrays
From: Liwei Song <[email protected]>
Enable LED support for Intel Virtual RAID On CPU.
Fix build with musl
--- ...ad-of-on_exit-for-musl-compatibility.patch | 53 +++++++++++++++++++ ...include-sys-select.h-and-sys-types.h.patch | 43 +++++++++++++++ meta-oe/recipes-bsp/ledmon/ledmon_git.bb | 34 ++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon/0002-include-sys-select.h-and-sys-types.h.patch create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon_git.bb
meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch new file +53 -0
@@ -0,0 +1,53 @@ +From 8aba09b743b4e89ef581a679943ce39a5c7fd4a5 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 9 Apr 2019 21:25:21 -0700 +Subject: [PATCH 1/2] use atexit insead of on_exit for musl compatibility + +musl does not support on_exit which is used in clean up. +Instead use atexit with is supported by musl and glibc. + +Upstream-Status: Pending +Signed-off-by: Khem Raj <[email protected]> +--- + src/ledctl.c | 2 +- + src/ledmon.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/ledctl.c b/src/ledctl.c +index 2aa1abc..2c97dcf 100644 +--- a/src/ledctl.c ++++ b/src/ledctl.c +@@ -689,7 +689,7 @@ int main(int argc, char *argv[]) + status = _init_ledctl_conf(); + if (status != STATUS_SUCCESS) + return status; +- if (on_exit(_ledctl_fini, progname)) ++ if (atexit(_ledctl_fini)) + exit(STATUS_ONEXIT_ERROR); + if (_cmdline_parse(argc, argv)) + exit(STATUS_CMDLINE_ERROR); +diff --git a/src/ledmon.c b/src/ledmon.c +index 0ea2583..2333c7c 100644 +--- a/src/ledmon.c ++++ b/src/ledmon.c +@@ -860,7 +860,7 @@ int main(int argc, char *argv[]) + set_invocation_name(argv[0]); + openlog(progname, LOG_PID | LOG_PERROR, LOG_DAEMON); + +- if (on_exit(_ledmon_status, &terminate)) ++ if (atexit(_ledmon_status)) + return STATUS_ONEXIT_ERROR; + + if (_cmdline_parse_non_daemonise(argc, argv) != STATUS_SUCCESS) +@@ -930,7 +930,7 @@ int main(int argc, char *argv[]) + } + _ledmon_setup_signals(); + +- if (on_exit(_ledmon_fini, progname)) ++ if (atexit(_ledmon_fini)) + exit(STATUS_ONEXIT_ERROR); + list_init(&ledmon_block_list, (item_free_t)block_device_fini); + sysfs_init(); +-- +2.21.0 +
meta-oe/recipes-bsp/ledmon/ledmon/0002-include-sys-select.h-and-sys-types.h.patch new file +43 -0
43 lines not on this page · raw message
meta-oe/recipes-bsp/ledmon/ledmon_git.bb new file +34 -0
@@ -0,0 +1,34 @@ +SUMMARY = "Intel(R) Enclosure LED Utilities" + +DESCRIPTION = "The utilities are designed primarily to be used on storage servers \ + utilizing MD devices (aka Linux Software RAID) for RAID arrays.\ +" +HOMEPAGE = "https://github.com/intel/ledmon" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ +" + +DEPENDS = "sg3-utils udev" + +inherit systemd + +SYSTEMD_SERVICE_${PN} = "ledmon.service" + +SRC_URI = "git://github.com/intel/ledmon;branch=master \ + file://0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch \ + file://0002-include-sys-select.h-and-sys-types.h.patch \ + " + +SRCREV = "ad1304ca1363d727425a1f23703c523e21feae4f" + +COMPATIBLE_HOST = "(i.86|x86_64).*-linux" + +S = "${WORKDIR}/git" +EXTRA_OEMAKE = "CC='${CC}' LDFLAGS='${LDFLAGS}' CFLAGS='${CFLAGS}'" + +do_install_append() { + install -d ${D}/${systemd_unitdir}/system + oe_runmake DESTDIR=${D} install + oe_runmake DESTDIR=${D}${systemd_unitdir}/system install-systemd +}
Signature · 1 line
2.21.0
meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch line 7
Quoted 3 lines · Khem Raj
...
meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch new file +2
-0+musl does not support on_exit which is used in clean up. +Instead use atexit with is supported by musl and glibc.
The functions have different signatures, and this patch introduces bugs for cases that use the parameters of on_exit.
int on_exit(void (*function)(int , void *), void *arg); int atexit(void (*function)(void));
Example:
Quoted 4 lines
...
+- if (on_exit(_ledmon_status, &terminate))
++ if (atexit(_ledmon_status))
...
static void _ledmon_status(int status, void *ignore)
{
if (*((int *)ignore) != 0)
log_info("exit status is %s.", strstatus(status));
else if (status != STATUS_SUCCESS)
log_error("parent exit status is %s.", strstatus(status));
}With the bogus atexit change no parameters are passed to _ledmon_status, and the function uses (and dereferenes) whatever garbage is currently in the stack/registers where function parameters are expected.
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 26 lines · Adrian Bunk
meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch line 7
Quoted 3 lines · Khem Raj
...
meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch new file +2
-0+musl does not support on_exit which is used in clean up. +Instead use atexit with is supported by musl and glibc.The functions have different signatures, and this patch introduces bugs for cases that use the parameters of
on_exit.int
on_exit(void (*function)(int , void *), void *arg); intatexit(void (*function)(void));Example:
Quoted 4 lines
...
+- if (on_exit(_ledmon_status, &terminate)) ++ if (atexit(_ledmon_status))...
static void
_ledmon_status(int status, void *ignore){ if (*((int *)ignore) != 0) log_info("exit status is %s.", strstatus(status)); else if (status != STATUS_SUCCESS) log_error("parent exit status is %s.", strstatus(status)); }
Quoted 3 lines
With the bogus atexit change no parameters are passed to
_ledmon_status, and the function uses (and dereferenes) whatever garbage is currently in the stack/registers where function parameters are expected.
Thanks for looking into it and This is correct somehow I overlooked it i will send a follow up to not rely on arguments for on_exit
Quoted 13 lines
cu
Adrian--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed